Sign in to follow this  
XVincentX

Shadow Volume Final Rendering

Recommended Posts

Hello. I finally have created a shadow volume, but now i do not know how to render it propely I create a black quad, and i render it on the screen. At first,i render the original geometry, then the shadow volume and finally the quad. But really i'm not able to see a decent shadow. Here is how i'm working Geometry Rendering: simple Vertex and Pixel Shader, with this values
DepthStencilState DefaultDepth
{
    DepthEnable = true;
    DepthFunc = LESS;
    DepthWriteMask = ALL;
    StencilEnable = false;
};

 

BlendState NoBlend
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
    RenderTargetWriteMask[0] = 0x0F;
};

Shadow Volume rendering: Simple Vertex and Pixel shader, an extruding Geometry Shader that works.
 RasterizerState DisableCulling
{
    CullMode = NONE;
    FillMode = SOLID;
};

DepthStencilState StencilShadow
{
    DepthEnable = true;
    DepthWriteMask = ZERO;
    DepthFunc = LESS;
    
    StencilEnable = true;
    StencilReadMask = 0xFFFFFFFF;
    StencilWriteMask = 0xFFFFFFFF;
    
    FrontFaceStencilFunc = ALWAYS;
    FrontFaceStencilPass = INCR;
    FrontFaceStencilFail = Keep;
    
    BackFaceStencilFunc = ALWAYS;
    BackFaceStencilPass = DECR;
    BackFaceStencilFail = Keep;
};

Quad Rendering: Simple Vertex and Pixel Shader (Vertex shader simply returns position, pixel returns 0), with this values (stencil ref = 1)
 RasterizerState EnableCulling
{
    CullMode = BACK;
    FillMode = SOLID;
    FrontCounterClockwise = FALSE;
};

DepthStencilState StencilMask
{
    DepthEnable = false;
    DepthWriteMask = ZERO;
    DepthFunc = LESS;
    
    StencilEnable = true;
    StencilReadMask = 0xFFFFFFFF;
    StencilWriteMask = 0xFFFFFFFF;
    
    FrontFaceStencilFunc = LESS_EQUAL;
    FrontFaceStencilPass = Keep;
    FrontFaceStencilFail = Zero;
    
    BackFaceStencilFunc = ALWAYS;
    BackFaceStencilPass = Keep;
    BackFaceStencilFail = Zero;
};
 

What about you? Now i would ask: what is and why do i need additive blending?

Share this post


Link to post
Share on other sites
You may want to look at the ShadowVolume SDK sample (or for a different angle, my older D3D9 shadow volume example).

Quote:
what is and why do i need additive blending?
Additive blending is very common in lighting implementations - light is, funnily enough, additive [smile]. Use of the word 'blending' in the name is a bit misleading as it doesn't really blend in the more conventional alpha/transparency blending, instead it does a straight-up addition of the new and previous pixel colours.

Typically you'll only use additive blending for lighting separated over multiple passes. Depending on your chosen method you may or may not need it.


hth
Jack

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this