PDA

View Full Version : Near plane



XeviaN
10-08-2003, 10:23 PM
Hi all!

In D3DXMatrixPerspectiveFovLH why did i have to set then near plane to 0.1 and not to 0.0 otherwise the render is not correct? (z-buffer artifact)

Could someone explain this? :roll:

Clootie
10-08-2003, 11:50 PM
Because you'll get W precision lost (division by ZERO)!!!
Minimum recommended near clip plane settings == 1.0
Your value of 0.1 will probably lead to Z artifacts at way to FAR Z-plane too.

Matrix used for D3DXMatrixPerspectiveFovLH:

w 0 0 0
0 h 0 0
0 0 zf/(zf-zn) 1
0 0 -zn*zf/(zf-zn) 0
where:
h is the view space height. It is calculated from
h = cot(fovY/2);

w is the view space width. It is calculated from
h = w / Aspect

If you look at "-zn*zf/(zf-zn)" with Znear == 0 you will get W~0. So later in pixel pipelene you Z value will be calculated as Z=Z'/W -- where Z' - is camera space Z -- so precision lost.

XeviaN
11-08-2003, 03:44 PM
Thanks, now i realize.