openexr-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-user] again about lighting scenes with exr files...


From: Enrico Borrione
Subject: [Openexr-user] again about lighting scenes with exr files...
Date: 10 Mar 2004 16:45:40 +0100

hi all,
my experiments with exr images proceed: 
I loaded the image and i made a try to build a diffuse illumination
map... useless to say it didn't worked, so now i am seeking the error.
See what am i doin' and lemme know where is the (conceptual) error.

Now the idea is to build a cubemap holding the value of total light
energy coming from a certain direction... i calculate the amount of
energy this way:

1) i build a virtual cubemap, so my 6 exr images work as a global light
source.
2) i build a smaller empty cubemap. here i will store the luminace
values that i am gonna compute.
now for every empty texel of th cubemap:
3) i use the vector coming from the center of the cube to the empty
texel as a "viewing direction". When my map will be full this vector
will be the surface normal.
and for every texel of the image cubemap:
4)i compute the vector from the center of the cube to the exr texel
5)i dot product between the empty and the exr vector (it should simulate
the L*N cosine factor, as the texel was a point light source).
6)if the dot is < 0, then no contribute is taken (the texel is in the
"back" direction of my texel, so it can't lit it).
7)if dot > 0 then i compute the total visible pixels "radiance" of the
exr texel with a formula like:
 
 if (dot>0)
 //sum of all the visible pixels...
 total_color.x += (pixels[scanimage].r);   //r value
 total_color.y += (pixels[scanimage].g);   //g value
 total_color.z += (pixels[scanimage].b);   //b value
 total_texels++;  //number of visible pixels

8) when i passed trough all the exrcub i just compute the total
luminace:

 //average pixel's color value...
 total_color = total_color/total_texels;

 // luminance!
yvalue[latox][latoy]=total_color.x*0.2125+total_color.y*0.7154+total_color.z*0.0721;

9)store the computed y into the small cubemap and save it to file...

now i get a table of values ranging from 0 to ~4.0f
When i put all the stuff into OpenGL i use an algo like

*get Y incoming from Normal direction
*diffuse_color * Y
*exposure
*gamma
*scaling

Unfortunately all i get is an flat, light gray sphere, if we except some
darker spots on the mesh... 
What is wrong? I have the feeling the problem is in computing the
incoming light energy (points 7 and 8 in the prev list).

Anyone willing to help? =)
I promise you at least a screenshot when all the stuff will be running
:)))
Thx far any help,
enrico





reply via email to

[Prev in Thread] Current Thread [Next in Thread]