gunslinger

03-11-2004, 04:23 AM

I am trying to light a scene recovering radiance values from a cubemap. So

in my OpenGL app I just set the textures and pass the whole stuff to the

vertex and fragment program. Now the program should:

1) extract the luminace value from the cubemap

2) set up the correct exposure (using the formula 2^(exposure+2,47393)

3) gamma correct the lit color value

4) map the result so that the 0.18 middle_gray is 3.5 f-stops below the

full 1.0 white.

my fragment program is:

PARAM exposure = program.local[0];

PARAM one_over_gamma = {0.4545,0,0,0};

PARAM middle_gray = {0.332,0.332,0.332,1.0};

TEMP texelColor,luminance, m_exp, t_exp, temp_inColor, temp_outColor,

temp_inColor2;

#retrive luminance value

TEX luminance, inTexCoord2, texture[1], CUBE;

#get the unexposured lit color (it may be out of the [0,1] range)

MUL temp_inColor, inColor, luminance;

************************************************** ********************************************* #exposure stuff

#t_exp should be set at the value exposure+2.47...

ADD t_exp, exposure.xxxx, 2.47393;

#m_exp should be 2^t_exp = 2^(exposure+2.47)

EX2 m_exp, t_exp.x;

#compute the exposured lit pixel value (not gamma corrected,neither

clamped to [0,1]

MUL temp_inColor2, temp_inColor, m_exp;#.xxxx;

************************************************** ********************************************* #gamma correct the pixel using the formula

#gamma_corr_pix=pixel^one_over_gamma

POW temp_outColor.x, temp_inColor2.x, one_over_gamma.x;

POW temp_outColor.y, temp_inColor2.y, one_over_gamma.x;

POW temp_outColor.z, temp_inColor2.z, one_over_gamma.x;

************************************************** ********************************************* #map the pixel color so the .18 mid gray is

#mapped on 0.332

MUL outColor, temp_outColor, middle_gray;

(all the pixel processing is extracted from some paper teaching how to

compute correct exposure settings coming from exr pictures)

the problem is that id doesn't work, so i am afraid i am doing something

sintattically wrong. I can tell you that is isn' working because

computing the same thing by hand i have:

using exposure=0, color=1,1,1 and luminance=2:

1) temp_inColor * luminance=2,2,2

2) t_exp = exposure+2.47 = 2.47

3) m_exp = 2^t_exp = 5.55

4) temp_inColor2 = temp_inColor * m_exp = 5.55

5) temp_outColor = temp_inColor2^0.4545 = 2.98

6) outColor = temp_outColor * 0.332 = 0.99

so my output color should be a full white... instead OpenGL display an

almost black sphere, and even if i pass different luminance values

(ranging from 1 to 5) the sphere remains of the same constant dark gray

(just like the luminance wasn't changing at all)...

where my program is failing? Am i the last human being who uses assembler programs on this planet?

Thanks guys, the gunslinger

in my OpenGL app I just set the textures and pass the whole stuff to the

vertex and fragment program. Now the program should:

1) extract the luminace value from the cubemap

2) set up the correct exposure (using the formula 2^(exposure+2,47393)

3) gamma correct the lit color value

4) map the result so that the 0.18 middle_gray is 3.5 f-stops below the

full 1.0 white.

my fragment program is:

PARAM exposure = program.local[0];

PARAM one_over_gamma = {0.4545,0,0,0};

PARAM middle_gray = {0.332,0.332,0.332,1.0};

TEMP texelColor,luminance, m_exp, t_exp, temp_inColor, temp_outColor,

temp_inColor2;

#retrive luminance value

TEX luminance, inTexCoord2, texture[1], CUBE;

#get the unexposured lit color (it may be out of the [0,1] range)

MUL temp_inColor, inColor, luminance;

************************************************** ********************************************* #exposure stuff

#t_exp should be set at the value exposure+2.47...

ADD t_exp, exposure.xxxx, 2.47393;

#m_exp should be 2^t_exp = 2^(exposure+2.47)

EX2 m_exp, t_exp.x;

#compute the exposured lit pixel value (not gamma corrected,neither

clamped to [0,1]

MUL temp_inColor2, temp_inColor, m_exp;#.xxxx;

************************************************** ********************************************* #gamma correct the pixel using the formula

#gamma_corr_pix=pixel^one_over_gamma

POW temp_outColor.x, temp_inColor2.x, one_over_gamma.x;

POW temp_outColor.y, temp_inColor2.y, one_over_gamma.x;

POW temp_outColor.z, temp_inColor2.z, one_over_gamma.x;

************************************************** ********************************************* #map the pixel color so the .18 mid gray is

#mapped on 0.332

MUL outColor, temp_outColor, middle_gray;

(all the pixel processing is extracted from some paper teaching how to

compute correct exposure settings coming from exr pictures)

the problem is that id doesn't work, so i am afraid i am doing something

sintattically wrong. I can tell you that is isn' working because

computing the same thing by hand i have:

using exposure=0, color=1,1,1 and luminance=2:

1) temp_inColor * luminance=2,2,2

2) t_exp = exposure+2.47 = 2.47

3) m_exp = 2^t_exp = 5.55

4) temp_inColor2 = temp_inColor * m_exp = 5.55

5) temp_outColor = temp_inColor2^0.4545 = 2.98

6) outColor = temp_outColor * 0.332 = 0.99

so my output color should be a full white... instead OpenGL display an

almost black sphere, and even if i pass different luminance values

(ranging from 1 to 5) the sphere remains of the same constant dark gray

(just like the luminance wasn't changing at all)...

where my program is failing? Am i the last human being who uses assembler programs on this planet?

Thanks guys, the gunslinger