I am trying to implement the full screen glare effect that is visible when looking directly at the sun.
The relevant ini settings are:
Code: Select all
[Weather]
Sun Glare Fader Max=0.5
Sun Glare Fader Angle Max=30.0
Sun Glare Fader Color=222,095,039
The effect appears to be implemented as an additive full screen quad with a solid color.
My first guess was to use a color of Sun Glare Fader Color * Sun Glare Fader Max, then scale that linearly based on the angle to the sun. That doesn't look correct at all. It's way too bright and too red as well.
I was wondering if it's a gamma correction issue, so I implemented gamma correction and the results are a little better, but still not correct. It's still slightly too bright, and the color tone is slightly off as well. I played around with the gamma value a bit (currently 2.2) but couldn't find one that's any better.
Code: Select all
const float sunGlareFaderMax = 0.5f;
float fade = value * sunGlareFaderMax;
const float gamma = 2.2;
fade = pow(fade, gamma); // gamma correction
sunGlareFaderColor *= fade; // do fading in linear space
for (int i=0; i<4; ++i)
sunGlareFaderColor[i] = std::pow(sunGlareFaderColor[i], 1.0/gamma); // back to gamma space
mat->setEmission(osg::Material::FRONT_AND_BACK, sunGlareFaderColor);
By taking two vanilla screenshots (with and without the glare), loading those into GIMP then setting the second layer to Difference mode I determined the effective color addition in vanilla to be: (60, 45, 18
). The color I have in OpenMW right now with the above formula is (120, 81, 54).
I changed the Sun Glare Fader Color to full white, then repeated the process. The resulting difference (from a shot with no glare) was gray, so I don't suppose that any other colors are coming into play here.
Any insight on how these INI settings are supposed to be used would be very helpful.