Advertisement Jump to content
Sign in to follow this  

Shadows Beginner Question

This topic is 1060 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:


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 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

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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!