love
love copied to clipboard
Potential gamma correction problem with Canvases
I think this should be displaying the same brightness for each of the three textures rendered, but in LÖVE 12 the last two are darker and in LÖVE 11 the last one is darker when gamma correction is enabled in love.conf:
local id1 = love.image.newImageData(64, 64)
id1:mapPixel(function() return .5, .5, .5, 1 end)
local img1 = love.graphics.newImage(id1)
local canvas1 = love.graphics.newCanvas(64, 64, { format = "rgba8" })
canvas1:renderTo(function() love.graphics.draw(img1) end)
local id2 = canvas1:newImageData()
local img2 = love.graphics.newImage(id2)
function love.draw()
love.graphics.draw(img1)
love.graphics.draw(canvas1, 64)
love.graphics.draw(img2, 128)
end
However it's possible I'm misremembering how/when sRGB <-> linear conversions are supposed to happen.
Ideally, you want no conversions happening anywhere in the rendering chain, obviously. This can be accomplished if all source data is statically converted to linear space, and the final render is converted back to gamma space. In my opinion implementing a mechanism that does exactly this to all graphics, colors and output image automatically is a way to go about it.
The color error I think is because at certain stage the renderer assumes that the source image was in gamma space while in fact it was already in linear space, so it gets gamma-corrected twice. I don't think it's possible to create 100% reliable dynamic conversion system so static conversion gets my vote (plus it's better performance, sans loading stage).
Ideally, you want no conversions happening anywhere in the rendering chain, obviously.
That's not correct. Intermediate sRGB-encoded render targets are both desired and supported.
I'd appreciate it if you stop making authoritative statements on topics you aren't an expert on, in this issue tracker.
Having the same format everywhere prevents conversion errors by default because there aren't any conversions, and prevents wasting processing power on said conversions. I'd appreciate if you weren't an ass but I guess that's not a possibility.
The 12.0-specific bug has been fixed already, and 8c13943 adds a way for ImageData to keep a hint for whether a Texture created from it should use a linear pixel format when gamma-correct rendering is enabled, so now all 3 rendered textures in the example code above render the same.