Shadows Beginner Question

Started by
3 comments, last by fs1 8 years, 1 month ago

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 !

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.

Thanks phil_t

Makes sense,I will try one pass as well.

Regards!

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.

-potential energy is easily made kinetic-

Ok, I understand the logic behind what you are recommending.
Thanks so much.

This topic is closed to new replies.

Advertisement