int ShadowValue = (step((LightToVecDist/FarClip),SpotShadow.x) && Atten != 0);
float lit = (float2)0.0f;
float E_x2 = SpotShadow.y;
float Ex_2 = SpotShadow.x * SpotShadow.x;
float variance = E_x2 - Ex_2;
float mD = SpotShadow.x - (LightToVecDist/FarClip);
float mD_2 = mD * mD;
float p = variance / (variance + mD_2);
lit = max( p, ShadowValue );
LightToVec = In.WPos - LightInfo.xyz;
LightToVecDist = length(LightToVec);
float CubeShadow = Cubemap.Sample(SamplText,(LightToVec/LightToVecDist));
int CubeValue = step((LightToVecDist / FarClip),CubeShadow);
float4 SpotLight = (Atten * dot( In.Nor, LightToVecDirection ));
return ((PointLight * CubeValue) + (SpotLight * lit) + 0.1f) * BaseColor;
return float2(depth,pow(depth,2)); But it does not work: the shadow remains perfectly the same. BTW, a concept is not really clear to me. Why have i to store depth^2 in the second channel and retrive it? Can't i compute it directly in Pixel shader retriving original depth? http://img125.imageshack.us/img125/6706/imgm.jpg As i imagined, E_x2 = E2_x