Jump to content
  • Advertisement
Sign in to follow this  
MikeyO

OpenGL Perspective based shadow mapping

This topic is 4852 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've been trying (for the last several days) to implement different kinds of perspective based shadow maps by following the Nvidia SDK's examples.. and I've had little luck so far. Could someone maybe outline the steps for creating a trapezoidal shadow map or perspective shadow map and then use them? By my error, it kind of looks like I'm not transforming the texture coordinates correctly during the useshadowmap pass.. at the same time I must not be creating the LightViewProjection matrix correctly for the first pass either, based on this image: Standard shadow mapping does work with basically the same shaders, just calculating a different LightViewProjection. It would be nice to have a step-by-step or otherwise if anyone has suggestions or links that might help? I could definitely use some more DirectX source code, since all I've been able to find on google relating to TSMs or PSMs is OpenGL. Here is some troublesome code I wasn't sure if I was converting correctly (to C# from C++):
//Nvidia's C++ version:
#define FLT_AS_DW(F) (*(DWORD*)&(F))
#define ALMOST_ZERO(F) ((FLT_AS_DW(F) & 0x7f800000L)==0)
if ( !(ALMOST_ZERO(boxWidth) || ALMOST_ZERO(boxHeight)) )

//C# version:
if( !(((uint)boxWidth & 0x7f800000L) == 0) || (((uint)boxHeight & 0x7f800000L) == 0))

////////////////////////////////////
//Nvidia's C++ version:
const D3DXPLANE& p0 = (i&1)?camPlanes[4] : camPlanes[5];
const D3DXPLANE& p1 = (i&2)?camPlanes[3] : camPlanes[2];
const D3DXPLANE& p2 = (i&4)?camPlanes[0] : camPlanes[1];

//C# Version:
Plane p0 = ((i&1U) != 0U) ? camPlanes[4] : camPlanes[5];
Plane p1 = ((i&2U) != 0U) ? camPlanes[3] : camPlanes[2];
Plane p2 = ((i&4U) != 0U) ? camPlanes[0] : camPlanes[1];

////////////////////////////////////
//Nvidia's C++ version:
#define ALMOST_ZERO(F) ((FLT_AS_DW(F) & 0x7f800000L)==0)
#define IS_SPECIAL(F)  ((FLT_AS_DW(F) & 0x7f800000L)==0x7f800000L)
if ( ALMOST_ZERO(cosTheta) || IS_SPECIAL(cosTheta) )
    return FALSE;

//C# Version
if((((uint)cosTheta & 0x7f800000L) == 0) || (((uint)cosTheta & 0x7f800000L) == 0x7f800000L))

Share this post


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