Jump to content
  • Advertisement
Sign in to follow this  
coba2

OpenGL Create Shadow

This topic is 4048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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???

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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'.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!