## Recommended Posts

I followed NVIDIA's tutorial (CSM and PSSM pdf) and sample project but I'm confused how to compare depth with split distances.

uniform sampler2DArrayShadow uShadMap;

int  i;

for (i = 0; i < SHAD_SPLIT; i++) {
break;
}

return 1.0;

}

uShadDist contains distances in view space e.g. [ 12.818679, 26.606153, 46.403923, 100.000061 ] but I guess I need to convert them to clip space coord: [ 0 : 1 ] before comparing with gl_FragCoord.z, right?

Here NVIDIA's code:

// f[i].fard is originally in eye space - tell's us how far we can see.
// Here we compute it in camera homogeneous coordinates. Basically, we calculate
// cam_proj * (0, 0, f[i].fard, 1)^t and then normalize to [0; 1]
far_bound[i] = 0.5f*(-f[i].fard*cam_proj[10]+cam_proj[14])/f[i].fard + 0.5f;

I don't understand what (or how) it does  I tried to multiply split dist with camera's perspective proj but I always get >= 1, Can someone explain what value should I compare with gl_FragCoord.z?

One another question is that I'm using Practical Split Scheme but I don't understand what lambda value should I use, I used 0.5.  C  = (Clog + Cuni) * 0.5f . But I'm not sure if it is best value or not.

##### Share on other sites

Ok I think the I found the error about first question, I was used wrong index:

/* wrong */
0.5f * (-C * camProj[2][3] + camProj[3][3]) / C + 0.5f

/* fixed */
0.5f * (-C * camProj[2][2] + camProj[3][2]) / C + 0.5f

now I got colorful scene, I will try to understand the simple math used here

## Create an account

Register a new account

1. 1
Rutin
45
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633407
• Total Posts
3011699
• ### Who's Online (See full list)

There are no registered users currently online

×