shadows problem

Started by
3 comments, last by The Wizard Of Oz 21 years, 5 months ago
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
follow the yellow brick road
Advertisement
I am working on something simmilar(still got lot''s of problems though)

Can you describe your problem more precicly

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
follow the yellow brick road
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
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.

This topic is closed to new replies.

Advertisement