View Full Version : Blending+Lightning+Shadows

02-25-2001, 03:59 AM
Ok i am just starting
but i want to make my head clear http://www.opengl.org/discussion_boards/ubb/smile.gif

1. can you make light that shines through a blended wall, and changes a bit from color depending on the colors of that "glass"?

2. Can you make Shadows? and second can you make those shadows shine on objecs??
like, look at nehe's Shadow Tutorial, the shadow does not shine on the second round item....

if you know what i mean

3. Is there a way to not draw the back side of a texture in 3d space... the nehe tutorials draw both sides which takes memory and fps while it might never been seen....(the backface...)

thank you very much,

may god be with you!


[This message has been edited by Janneke (edited 02-25-2001).]

02-25-2001, 05:15 AM
1. No, not automatically at least. OpenGL is not a scenegraph api. It knows nothing about the relationship and relative positions of the polygons in the scene. As far as OpenGL is concerned, there is only one polygon in the scene, the one it is drawing right now.

2. If by "make shadows shine" you mean cast shadows. Procedurally, yes. Using stenciled shadows is quite easy. And NeHe's tutorial on shadows, does cast shadows onto the sphere. But the sphere itself does not cast a shadow. This was by design of the tutorial authors.

3. Sure, enable back face culling.

[This message has been edited by DFrey (edited 02-25-2001).]

02-25-2001, 05:40 AM

so where could i find more info about light+blending, and/or shadows...??

i appreciate your attention
(sorry for my bad english!)


02-25-2001, 07:27 AM
i made a theory but i am not sure if it's right.

When you have a light, and a blended object,
and you want to make reflection on the outside ground,
you would do something like this:

if Red color of light is the same as the red color of the glass or higer, it will use the red of the glass.. if it's lower it will use the one of the light

and so on for green and blue

is this right??

if so,
you would have to let it count every frame for each point on a texture...
wouldn't that be a bit slow....?

or do i have to do it different...

My regards...


02-25-2001, 08:13 AM
Eh, it is a bit more complicated than that. You have to subtract the normalized complement of the color of the glass from the normalized color of the light passing through it. After normalizing the result, you can scale the color by the product of the light's brightness and the glass' transparency. You can then position substitute this color for the original light (slightly moved if including refraction) for objects that are beyond the glass. To actually cast an image of the window onto the surrounding geometry is a bit more involved. Start with the basics first.

That's one way. You may multiply the colors of the light and glass instead of subtracting (this is easier since it does not require the colors to be normalized or scaled).

[This message has been edited by DFrey (edited 02-25-2001).]