PDA

View Full Version : Point Lighting



XaVinci
03-14-2003, 09:30 PM
Does any one know how to implement a point light in volume rendering?

XaVinci
03-14-2003, 11:18 PM
I have managed to implement shading using directional light with the lookat as the camera position.

From my understanding, to make it a point light, i got to include attenuation like

1 - (distance from light to pixel / radius of area of light influence)^2

If so, how do I get the position for each pixel in the case of volume rendering?
Do I have to do lighting computation in the texture space and how?

JustHanging
03-16-2003, 10:17 PM
Hi,

I haven't done much volume rendering, but I think it's something like this:

Precalculate object-space normals and store them into a 3d texture. In addition to this you need a cubemap that gives you the light's direction vector, after that it's just a matter of taking a dot product between the light dir and the normal.

The cubemap is almost similar to a normalization cubemap, it's supposed to return for each vector a normalized vector in the opposite direction. You use texgen to generate texture coordinates for this cubemap, and it returns the light->fragment vector for each fragment. The texgen is as simple as

s=x-light.x
t=y-light.y
r=z-light.z

-Ilkka