-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenerateMips on sRGB Textures averaging in gamma space? #142
Comments
Right. I should add a inverse gamma/regamma in this case to the sahder... |
Presumably the other option would be to use a regular pixel shader pipeline, like the post processing functions, where the sRGB formats are directly supported as both SRVs and RenderTargets to move the conversion before the filtering in the sampler? I don't know whether having the compute shader version do 4 point samples, gamma converting, taking the average and regammaing would result in any overall performance difference compared with using the built-in pixel shader functions though. |
GenerateMips has always been a bug-farm, and on Direct3D 11 the implementation was very driver-dependent. It does seem like the only "correct" way to solve this is to do as you say and create yet another generatemips codepath using classic texture down-sizing on the GPU. |
MiniEngine does it with the compute shader, so I'll crib that. |
Hi,
Reviewing the implementation of GenerateMips for sRGB textures it looks like the implementation is doing a reinterpret copy into a linear texture format and then using a bilinear sampler in the ComputeShader to perform the average.
Unless I'm missing something about the math for this case it seems like doing the linear arithmetic on gamma encoded values in the sampler is going to result in color errors in the output mips, as demonstrated by this GLTF test case; https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/TextureLinearInterpolationTest
The text was updated successfully, but these errors were encountered: