Re: Shadows show through or flicker in later graphics cards
  Home FAQ Contact Sign in
microsoft.public.win32.programmer.directx.graphics only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: Shadows show through or flicker in later graphics cards         

Group: microsoft.public.win32.programmer.directx.graphics · Group Profile
Author: Jan Bruns
Date: Aug 28, 2008 23:40

First of all, the technique you're presenting here
doesn't use stencil-shadowing (that's the thing
with geometry of shadow casters beeing extruded in
light-direction to the frustrum's bounds, then even/odd
testing the number of shadow-surfaces actually drawn
behind the scene).

Also it looks like you're using the non-hw sccelerated
version of shadow maps (FP-Textures carrying depth,
instead of real hardware depth-buffers, moving the
depth-comparison and weighting step the the hardware).

So if you disable Z-testing, the outcome should
look like always when you disabkle z-testing, at least
without any respect to shadows.

Maybe you should first take a look at wich format
your shadow maps are really using (does it depend
on the cards used?).

Gruss

Jan Bruns

"Noley Edge" gmail.com> schrieb im Newsbeitrag news:bcceedb9-0277-4d50-935f-3f425c6fb4d6@i20g2000prf.googlegroups.com...
>I am rendering shadows using depth stencil buffers and a shadow map.
> I am using a floating point texture for the shadow map. The shadow
> map size is 1024. On older video cards, or cards that have only 256MB
> ram, everything works fine. However, when I try to render the shadows
> to a newer card with more than 256MB, the shadows flicker and exhibit
> something that looks like Z-fighting. I was able to cure this, by
> explicitly disabling fixed function Z buffering in my pixel shader
> (ZEnable = FALSE). But this then led to the shadows showing through
> all objects, whether the occluder was in front of them or not. This
> effect makes it look like objects who have a shadow cast on them, are
> transparent! You can see shadows straight through them.
>
> So, I either get nasty flickering, or objects that are transparent
> with regard to shadows.
> But in cards that are older and less advanced, it works perfect as
> long as I comment out the ZENABLE = FALSE!? If ZEnable is left at
> FALSE, then shadows show through objects in both types of graphics
> cards.
> GeForce 6800 GO Ultra(256MB) - works GeForce 8300 GS - flicker or
> transparency
>
> Anyone ever experience this? Thanks in advance.
>
> My pixel shader is below:
>
> float4 ShadowPixelShader(float4 tex : TEXCOORD0,
> float depth : TEXCOORD2) : COLOR
> {
> // Shadow mapping with 2x2 percentage-closer filtering.
> float4 accum;
> accum.x = offsetLookup(ShadowMap, tex, float2(0.0f, 0.0f));
> accum.y = offsetLookup(ShadowMap, tex, float2(0.0f, 1.0f));
> accum.z = offsetLookup(ShadowMap, tex, float2(1.0f, 0.0f));
> accum.w = offsetLookup(ShadowMap, tex, float2(1.0f, 1.0f));
>
> accum.x = depth - accum.x;
> accum.y = depth - accum.y;
> accum.z = depth - accum.z;
> accum.w = depth - accum.w;
> accum = (accum >= 0.0) ? Shadow : Light;
>
> float2 weight = frac((tex.xy / tex.w) + TexelSize);
>
> float shadow = lerp(lerp(accum.x, accum.y, weight.x),
> lerp(accum.z, accum.w, weight.x),
> weight.y);
>
> // spot map.
> float4 spot = tex2Dproj(SpotMap, tex);
>
> return (tex.w > 0 && depth <= 1) ? shadow + spot + Ambient : White;
>
> }
>
> Which is proceeded by this technique:
>
> technique ShadowScene_FP
> {
> pass P0
> {
> // shaders
> VertexShader = compile vs_1_1 VS_ShadowVertexShader();
> PixelShader = compile ps_2_0 ShadowPixelShader();
>
> // setup alpha blend.
> AlphaBlendEnable = TRUE;
> SrcBlend = DESTCOLOR;
> DestBlend = ZERO;
> ZEnable = FALSE; //prevents flickering in 08 graphics cards. but
> causes object transparency!!!!!
>
> }
> }
>
> Here is the vertex shader:
> struct vOut
> {
> float4 pos : POSITION; // projected-space position.
> float4 tex0 : TEXCOORD0; // shadow map texture coords.
> float4 tex1 : TEXCOORD1; // shadow map texture coords.
> float depth : TEXCOORD2; // light-space depth.
> };
>
> vOut ShadowVertexShader(const vIn i)
> {
> vOut o;
>
> // Transform position.
> o.pos = mul(i.pos, WorldViewProject);
>
> // Compute shadow map texture coordinates.
> o.tex0 = mul(i.pos, ShadowMapTex);
> o.tex1 = o.tex0;
>
> // Compute light-space depth.
> float4 lPos = mul(i.pos, ShadowMapMVP);
> o.depth = lPos.z / lPos.w - 0.001;
>
> return o;
> }
no comments
diggit! del.icio.us! reddit!