   Variance shadowmaps
  Hi Me again.I figured I might get an answer faster if i post it in a new topic.Im applying variance shadowmaps but without success.I tried to multiply the value of the variance shadowmap with the diffuselight contribution (calculated with blinn phong) but no effect.I calculate the diffuse factor as followsThe vertexshader//Diffuse technique pixelshaderDiffuseVertexOut v_Output = (DiffuseVertexOut)0;v_Output.Position = mul(Input.Position,WorldViewProjection);v_Output.Normal = mul(Input.Normal,WorldInverseTranspose);v_Output.Light = LightPosition - mul(Input.Position,World);v_Output.CamView = CameraPosition - mul(Input.Position,World);v_Output.WorldPosition = mul(Input.Position,World);if(DropShadow)//Use the shadowmap{ //If a point light, calculate the direction to be in  //the direction of the current object always.if(CalculateLightViewProjection){LightViewProjection = LightWorld * LookAtLH(LightPosition,Input.Position,LightUp) * LightProjection;}v_Output.ShadowProjection = mul(Input.Position,LightViewProjection);}The Pixelshader//Diffuse technique pixelshaderPixelOut DiffusePixel(DiffuseVertexOut Input){PixelOut v_Output = (PixelOut)0;float3 v_Norm = normalize(Input.Normal);float3 v_LightDir = normalize(Input.Light);// Get ambient lightAmbientIntensity *= MaterialAmbient;AmbientColor *= AmbientIntensity;// Get diffuse lightDiffuseIntensity *= MaterialDiffuse;DiffuseColor = ( DiffuseIntensity * DiffuseColor) * saturate(dot(v_LightDir,v_Norm));float3 v_Half = normalize(v_LightDir + normalize(Input.CamView));float v_Specular = pow(saturate(dot(v_Norm,v_Half)),25);SpecularIntensity *= MaterialSpecular;SpecularColor *= SpecularIntensity;SpecularColor *= v_Specular;v_Output.Color = AmbientColor + DiffuseColor + SpecularColor;   //if the shadowmap should be used use it.if(DropShadow){   v_Output.Color *= ApplyShadowMapPixel(Input);}return v_Output;}This is how the shadowmap is appliedfloat ApplyShadowMapPixel(DiffuseVertexOut In){//PixelOut v_Out = (PixelOut)0;float2 v_TexCoords;v_TexCoords[0] = In.ShadowProjection.x/In.ShadowProjection.w/2.0f +0.5f;v_TexCoords[1]= -In.ShadowProjection.y/In.ShadowProjection.w/2.0f +0.5f;float len = length(LightPosition - In.WorldPosition) / LightRange;   float4 color = 1.0f - len;   float4 moments = tex2D(ShadowMapSampler, v_TexCoords);    float E_x2 = moments.r;    float Ex_2 = moments.a * moments.a;    float variance = min(max(E_x2 - Ex_2, 0.0) + 0.0001f, 1.0);    float m_d = (moments.a - len);    float p = variance / (variance + m_d * m_d);    float shadow = max(len <= moments.a, p);  // float4 mask = tex2D(maskSampler, ProjectedTexCoords);  // shadow *= mask;   return shadow;//this value is multiplied with the blinn phong value}Any idea what goes wrong?Thanx in advance   
  Have you used PIX to debug your shaders, and make sure that the contents of your shadowmap texture look correct?   ;  Hi there my shadowmap looks as follows:http://yfrog.com/0rshadowlvjI use a bool to determin if the application should use the shadowmapif(DropShadow)//Use the shadowmapThe result is the same with or without dropshadow = true//if the shadowmap should be used use it.if(DropShadow){   v_Output.Color *= ApplyShadowMapPixel(Input);}Maybe my shadowmap is wrong.I create it like this:Vertex shaderShadowMapVertexOut ShadowMapVertex(VertexIn In){ShadowMapVertexOut v_Output = (ShadowMapVertexOut)0;v_Output.Position = mul(In.Position,WorldViewProjection);v_Output.WorldPosition = mul(In.Position,World);v_Output.WorldPosition /= v_Output.WorldPosition.w;return v_Output;}PixelshaderPixelOut ShadowMapPixel(ShadowMapVertexOut In){PixelOut v_Out = (PixelOut)0;float v_Depth = length(LightPosition - In.WorldPosition) / LightRange;   v_Out.Color = float4(v_Depth, v_Depth * v_Depth, 0, 0);return v_Out;}BTW I use vista and directx 9 but PIX always crashes when i click on debug pixel.Common?   ;Quote:Original post by mast10BTW I use vista and directx 9 but PIX always crashes when i click on debug pixel.Common?Pix crashing? Yes.Try moving TEMP to a folder without spaces and non-ASCII characters.Might help, might not.Pix here wont run while TEMP has a parent folder with spaces.It's the software that Microsoft forgot :)   