WBuffer enable
Parameters
| enable - true to enable w-buffer rendering, false to disable. Classically defaulted to true in 16-bit colour mode, false in 24-bit and 32-bit. |
Description
|
Enables or disables w-buffering. A legacy command from the 16-bit depth-buffer era. Depth buffering is how 3D objects hide each other correctly on screen. On old hardware the standard z-buffer was imprecise in 16-bit modes, causing distant surfaces to flicker through each other ('z-fighting'); w-buffering was an alternative depth technique that spread precision more evenly, at the cost of patchier hardware support. On the modern DirectX 12 renderer this command is accepted for compatibility but has no effect - depth buffering always uses a full-precision 32-bit depth buffer, which is at least as accurate as a w-buffer ever was. If you still see z-fighting in a scene, the fix today is a sensible CameraRange (keep far/near small) or moving near-coplanar surfaces slightly apart. See also: CameraRange, Dither, AntiAlias. |
Example
; WBuffer Example ; --------------- ; A 16-bit depth setting makes depth-precision errors easiest to see Graphics3D 640,480,16,2 SetBuffer BackBuffer() camera=CreateCamera() AmbientLight 255,255,255 ; Two nearly co-planar panels a long way from the camera - if depth values ; are imprecise they flicker into each other ('z-fighting') green_panel=CreateCube() ScaleEntity green_panel,4,4,0.01 PositionEntity green_panel,0,0,80 EntityColor green_panel,0,255,0 blue_panel=CreateCube() ScaleEntity blue_panel,3,3,0.01 PositionEntity blue_panel,0,0,79.9 EntityColor blue_panel,0,0,255 enable=1 While Not KeyDown(1) ; Space toggles w-buffer depth testing If KeyHit(57) Then enable=1-enable ; Enable or disable w-buffering (more accurate depth in 16-bit modes) WBuffer enable ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Space: toggle w-buffer Arrow keys: move camera Esc: exit" If enable Then Text 0,20,"WBuffer True" Else Text 0,20,"WBuffer False" Text 0,40,"The blue panel should sit cleanly in front of the green one" Text 0,60,"On modern 32-bit depth buffers both settings can look identical" Flip Wend End
Index