Skip to main content
gamedev.net
🔒 Locked

Shadow Volume Final Rendering

Started by XVincentX 1 reply 900+ views
Original Post
XVincentX
XVincentX
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?
jollyjeffers
jollyjeffers
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
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
XVincentX
XVincentX
I tried, but results are not very good:

http://img301.imageshack.us/img301/8916/47063122vw7.jpg

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.