Archived

This topic is now archived and is closed to further replies.

The Wizard Of Oz

shadows problem

Recommended Posts

hi! i''m working on a terrain generator and i''d like to add some shadows... now, i''ve read through lesson 28 many times, but when i implement it in my code it just doesn''t work... i''d like to make a crate that casts shadows on my terrain.. does anybody know where i can find a good tutorial on this? or maybe give me any sugestions on why my code woun''t work? thanks in advance follow the yellow brick road

Share this post


Link to post
Share on other sites
well, i''ve re-written it from beginning to the end and got a beautiful landscape, some neat looking vehicles, a crate and NO shadows...
i don''t know what i''m doing wrong...
i''ve even remembered to replace 0 with 1 in CreateGLWindow() function regarding stencil buffer...



follow the yellow brick road

Share this post


Link to post
Share on other sites
I don''t know how exactly you are doing it, but, if you don''t plan to add dynamic lights, then, by all means, precalculate all the shadows before, using some ray tracing, and store the shadows (on or off) on each vertex (height), then, if the shadow is on, on that vertex, change the color of that vertex, if not let it use the default color. Sure, it won''t look THAT nice, especially if your terrain is too scalled, but hey, it''s fast and easy

Share this post


Link to post
Share on other sites
Don''t know if this will help but this is how i do it.
But i render the object after i have made the shadow stencil map

my stencilbuffer is cleared to 1 instead of 0 and i do a z buffer render first

first frontface
glFrontFace(GL_CCW);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);

then backface
glFrontFace(GL_CW);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);

then render everything.
This takes longer time but enabels me to do dynamic shadows a la DOOM3.

The rendering of the shadow is usuarly not the problem it''s figuring out the shadow volume, fiddle with it and see what happens.

Share this post


Link to post
Share on other sites