Page 1 of 1

Mipmapping with gamma correction

Posted: Sun Apr 22, 2018 7:25 am
by Hybrid Dog
https://github.com/minetest/minetest/issues/6867
How can I enable gamma correct downscaling for mipmap generation?

Re: Mipmapping with gamma correction

Posted: Sun Apr 22, 2018 8:25 am
by hendu
You cannot. The mipmap generation is done by your hardware, and both the alpha and srgb details are handled there. There is no option for tuning either.

However, you can compute mipmaps manually in software and do whatever calculations you like. Naturally that's slower vs the hardware generation. That's what Niko's blog entry did, and that's what BAW does too.

Re: Mipmapping with gamma correction

Posted: Sun Apr 22, 2018 9:33 am
by devsh
Correction: IrrBAW lets you upload parts of the mipmap chain explicitly, so i.e. you can come with your own mipmaps with formats such as the .dds (and khr soon), we never calculate mip maps ourselves in software.

Its mostly for purposes of better lowpass filtering such as using a sinc filter when generating mip-maps or when you intend to use the mipmap chain for other weird purposes (Hierarchical depth Min/Max Z)

But we do support automatic mipmap generation, but thats after a texture is uploaded and in functions other than IVideoDriver::getTexture() it needs to be triggered explicitly.

Re: Mipmapping with gamma correction

Posted: Mon Apr 23, 2018 12:45 am
by Mel
All this reminds me of an effect i saw with regard to uploading diferent mip images into a texture, from when the hardware didn't run pixel shaders :)
http://blog.mecheye.net/2018/03/deconst ... -sunshine/

Re: Mipmapping with gamma correction

Posted: Sat May 05, 2018 1:18 pm
by Hybrid Dog
If I understand that correctly, the internal format of a texture can be set to GL_SRGB to enable gamma correction:
https://www.reddit.com/r/opengl/comment ... on_issues/
https://learnopengl.com/Advanced-Lighti ... Correction

Re: Mipmapping with gamma correction

Posted: Tue May 08, 2018 12:54 am
by Mel
There is a toggle on the Irrlicht device creation parameters structure that enables the sRGB color space in textures automatically

http://irrlicht.sourceforge.net/docu/st ... eters.html

it is called "HandleSRGB"

Re: Mipmapping with gamma correction

Posted: Tue May 08, 2018 9:15 am
by devsh
In my opinion it works rather badly and only affects the framebuffer OUTPUT.

For sRGB(A) you'd need to set the internal format correctly on the texture, and irrlicht supports a very limited subset of internal formats.

Re: Mipmapping with gamma correction

Posted: Wed May 09, 2018 10:20 pm
by Mel
Yeah... i mistook it by my own engine, i handle the sRGB as texture format indeed...

It wouldn't harm to have some sRGB texture formats, as well as being able to load and have mipmaps for floating point textures. but either i haven't found them, or D3D9 doesn't support sRGB texture formats, only changing the output gamma ramp.

Re: Mipmapping with gamma correction

Posted: Sat Aug 25, 2018 12:41 pm
by Hybrid Dog
HandleSRGB indeed gives wrong results.
Image

Re: Mipmapping with gamma correction

Posted: Sat Aug 25, 2018 4:52 pm
by devsh
In my opinion it works rather badly and only affects the framebuffer OUTPUT.