Create Shadow

Started by
8 comments, last by _the_phantom_ 16 years, 10 months ago
Hai friend... can you explain to me how we can create a shadow with OpenGL?? Is in OpenGL, has a code to automaticly create a shadow, or how?? Thanx
Advertisement
There are 3 ways of creating shadows.

projeciton matrix onto a plane. Only suitable if objects should drop a shadow onto a single plane. No selfshadowing.

stencil shadows. Search for "robust stencil shadows". Very accuarte shadows, this means no soft shadow edges. A lot of effort is neccessary to get a robust stencil shadow implementation, because der are a lot of problems with stencil shadows themselefs. Also certain functionalities of the stencil buffer are differntly implemented on ati / nvidia graphics cards, so you have to write the code twice.

Shadow mapping. Most common technique, requires the whole scene to be rendert into an texture in the view of the lightsource. Soft shadows are possible, but it is again a little bit tricky to get it work on nvidia and ati. For render to Texture look at the frame buffer objet 101 and frame buffer object 201 Article from phantom on this page.
http://3d.benjamin-thaut.de
OK2.. I know about that algorithm.. but I want to know how We draw the shadow using OpenGL code. Can you help me to explain about the step to draw a shadow from an object???
Quote:Original post by coba2
OK2.. I know about that algorithm.. but I want to know how We draw the shadow using OpenGL code. Can you help me to explain about the step to draw a shadow from an object???


Read up on those techniques, once you fully understand them you will be able to implement the techniques in OpenGL. Sorry there is no CreateShadow() function, youll have to write one yourself.
OK2.. so there is no function to create shadow in OpenGL. We must to use some algorithm. So, maybe if we create a shadow using a shadow mapping. The shadow of from the object will be create from a texture projection from the object. It's right?? Thanx anyway...
Quote:Original post by coba2
OK2.. so there is no function to create shadow in OpenGL. We must to use some algorithm.


Correct.

Quote:So, maybe if we create a shadow using a shadow mapping. The shadow of from the object will be create from a texture projection from the object. It's right?? Thanx anyway...


from a texture projection from the 'light source'.
when we talk about directional light i can clearly see how shadow mapping is done since the light has a unique direction so but how would it be if i wanted to use point lights? Would i render the scene with a fov of 360? That´s a question i asked myself quite often but i´m not far enought to quickly try this myself.
You use cubemaps (or a 2D texture representing a cubemap) for pointlights and render the scene 6 times, once for each cubemap face with the lightview always facing one of the primary axes (+/- X/Y/Z).
8*6 = bad performance ;)

thx
which is why you don't try to update all the faces of a cubemap every frame, instead you do it over a number of frames and/or perform some kinda of choice as to what is updated when.

This topic is closed to new replies.

Advertisement