Jump to content
  • Advertisement
Sign in to follow this  
fs1

Shadows Beginner Question

This topic is 961 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 am new to Shadows in D3D9/10/11

 

I have been following this tutorial which is quite clear:

 

https://takinginitiative.wordpress.com/2011/05/15/directx10-tutorial-10-shadow-mapping/

 

Let's say you have drawn the scene with couple hundred of draw calls and you are about to render the shadows. The vertex shader is defined as:

struct PS_INPUT
{
    float4 pos : SV_POSITION;
    float4 lpos : TEXCOORD0;        //vertex with regard to light view
    float3 normal : NORMAL;
};
 
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
PS_INPUT VS( VS_INPUT input )
{
    PS_INPUT output;
    output.pos = mul( input.pos, mul( world, viewProj ) );
    output.normal = input.normal;
 
    //store worldspace projected to light clip space with
    //a texcoord semantic to be interpolated across the surface
    output.lpos = mul( input.pos, mul( world, lightViewProj ) );
 
    return output;
}

My question is, do you need to pass all Draw Calls again as a second pass, or there is a way to get the vertices previously drawn from the GPU or somehwere else? The former seems quite expensive in terms of performance.

 

Any clarification is highly appreciated.

 

Thanks !

Share this post


Link to post
Share on other sites
Advertisement

The vertices are transformed by different matrices when you're drawing the shadow map vs drawing the scene (i.e. the vertex shader output is different). So yes, generally you need to do the draw calls a second time.

 

Unless you're talking about rendering the shadows (not shadow map) and rest of the lighting together. That you should be able to accomplish with a single pass.

 

At any rate, processing all vertices twice is only an issue if vertex processing is your bottleneck. 

Share this post


Link to post
Share on other sites

I don't think you're understanding phil_t completely.  You will need a minimum of two passes.  One for the shadow map one for using the shadow map to shadow/light the scene.

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!