Skip to main content
gamedev.net
🔒 Locked

Create Shadow

Started by coba2 Jun 14, 2007 at 10:42 PM 8 replies 1.1k views
Original Post
coba2
coba2
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
Ingrater
Ingrater
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
coba2
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???
Exomondo
Exomondo
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.
coba2
coba2
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...
Exomondo
Exomondo
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'.
GreyHound
GreyHound
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.
Eternal
Eternal
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).
GreyHound
GreyHound
8*6 = bad performance ;)

thx
_the_phantom_
_the_phantom_
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.