10/12/2007

VRay exposure control formula

While browsing some code, I remembered that I wanted to share some code reproducing VRay exponential exposure control.

I had to work out the formula myself as I did not find any documentation about their 'dark multiplier' and 'bright multiplier'.

This is what I eventually found out (GLSL code) :

uniform float exposure_gain;
uniform float exposure;
uniform float dark_multiplier;
uniform float bright_multiplier;

vec3 exposure_control(vec3 base_color)
{
vec3 dark = vec3(0.5) - base_color;
dark = 0.25 - (dark * dark);
vec3 bright = base_color - dark;

vec3 color = dark_multiplier * dark + bright_multiplier * bright;
color = exposure_gain * (vec3(1.0) - exp( -exposure * color ));

return color;
}

Edit:: to those you that come here by accident, looking for 'vray' and 'sea', all I can tell you is to look at this, even though it is probable that it won't help you !

No comments: