Jump to content
  • Advertisement
Sign in to follow this  
gcard28

Projected Texture Shadows a fatal flaw :(

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

I have projected shadows running in my engine.... but they are dog slow..... Here is what I do, each item that is shadowed has it's own render target texture, so I switch from one render target to the next to draw the shadows for each character that is visible. This is KILLING and I mean KILLING my framerate. I was thinking that well have one render target texture that all the shadowed entities render to. Each entity renders to a section of this large render target. Now here comes my question. I am using DirectX9 and I have absolutely no idea how to do this. Is it even possible? Say I have a 512x512 texture and each shadowed entry uses 128x128 textures. That means I can have 16 entities stored in this one render texture.... The thing is how do I render into a subsection of this large texture? I would GREATLY appreciate any help anyone can give me. Perhaps some simple sample code or pointers to information or even if it is even possible. Many thanks to anyone kind enough to give some assistance

Share this post


Link to post
Share on other sites
Advertisement
You propably want to use IDirect3DDevice9::SetViewport(). Have a look into the DX documentation to see how to use it.

Bye, Thomas

Share this post


Link to post
Share on other sites
You shouldn't think of it as how many objects you can fit into a shadow texture, but rather how big of an AREA you can fit into the shadow texture. It shouldn't matter what objects are there. Simply set up the viewport to grab a given area around the camera and render those objects into the shadow texture. Any that lie outside of that can either not be shadowed, or you can look into Perspective Shadow Maps, Cascading Shadow Maps, Light Space Shadow Maps, etc..

Share this post


Link to post
Share on other sites
But from what I gather he's not using shadow maps, but projected shadow textures, which are somewhat different. As in Halflife2, each oject casts an independent shadow. While the efficiency of a method like this is questionable, the OP wants to know how to pack multiple renders onto a single surface.

This is a useful method for other things as well like imposters. Here is some sample code from my tree imposter code that does this..its renders 256 128*128 views of trees into a a 1024*4096 surface:


nFrame=i+(treetype*8);

viewport_imp.X = DWORD( (nFrame % 8 ) * 128 );
viewport_imp.Y = DWORD( (nFrame / 16 ) *128 );
viewport_imp.Width = 128;
viewport_imp.Height = 128;
viewport_imp.MinZ = 0.0f;
viewport_imp.MaxZ = 1.0f;

//set viewport
pd3ddev->SetViewport(&viewport_imp);

Share this post


Link to post
Share on other sites
Hi yes,

Thank you for everyones help. I wasn't aware you could resize the viewport to anything other than the full dimensions of the render target.

I know there are better ways of doing shadows than projected textures, but this is the method I started with and it is not possible for me to start from scratch for shadows.

But thanks for the suggestion of setting the viewport.

Many thanks to everyone

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!