Jump to content
  • Advertisement

Archived

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

Roquqkie

Shadowmaps....again :)

This topic is 6036 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

Hi...again! As you probably know already, I´m trying to create shadows, using shadowmaps! Thx to all the ppl that have guided me to a bunch of NVidia papers, they have helped me, but It´s still unclear to me how I should implement it myself. I have a MD3-model, a terrain and 1 light (lets call it the "sun"). I want to cast the models shadow onto the terrain, so I have decided to use shadow maps. I have read a lot of papers on the subject on NVidia and other''s homepages, but I still can''t figure out how it works... This is what I think I should do so far: Disable Textures. Goto light´s position. Draw my Model. Enable Textures. Save the depth-buffer to texture memory. Goto cameraes position. Clear the screen. Draw Model again w/textures. Draw Terrain. Project depth-buffer texture. <-- !??? Im not at all sure wether this pseudo-code is correct!? If it is how should I then Project my depth-buffer texture? If it isent correct please write the correct pseudo-code and how to project the final depth-buffer texture (if that´s the way to do it)! Best regards Roquqkie PS. please no more links to NVidia, only links to less confusing code!

Share this post


Link to post
Share on other sites
Advertisement
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
SetupCam(light);

something like this.. go for projected textures.. never have i done this, but its supported in gl. good luck. hope someone can help more precicely

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
The depth texture projection is not a separate pass, it''s included in your DrawModel and DrawTerrain passes. It uses multitexturing on an additional texture unit.

You have to use projective texture mapping. You have different options to create the required texture coordinates. The easiest is simply to feed the 3D position of your vertex (the one you give to glVertex() or similar) also to the textue coordinates of the shadowmap unit: just assign s=x, t=y, r=z, q=1. For that to work, you''ll have to load the projection matrix you used to render the view from the light into the texture matrix, including the premultiplied modelview matrix. The s,t,r,q coordinates will now be transformed and projected, just the same way they were when you rendered the light. The difference is, that now they are texture coordinates.

You''ll have to do some range and offset adjustments to your texture projection matrix, so that the projection and the rendered lightview match. Once you have that working, all you have to do is enable the shadowmap test through SGIX_shadow and create an appropriate combiner environment, so that you can see the shadow effect (best done through register combiners).

/ Yann

Share this post


Link to post
Share on other sites
when I suggested textur based shadows in the other topic, I did not mean shadow depth textures. It''s my opinion they are more a gimmik than really useful.
All I meant was draw the model black, on a white background (no depth writing/teststing needed) then render it onto the terrain as a lightmap. Will run on any hardware, and be a LOT faster, while looking just as good. Just you''d have to do the alpha component trick I mentioned.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!