CameraFogRange camera,near#,far#
Parameters
|
camera - camera handle near# - distance in front of the camera at which fog starts; 1 (default) far# - distance in front of the camera at which fog reaches full strength; 1000 (default) |
Description
|
Sets the camera fog range. The near parameter is the distance where the fogging effect begins - everything closer is unfogged. The far parameter is the distance where fog reaches full strength - everything beyond it is completely fogged out to the fog colour. The band between near and far controls the mood: a narrow band close to the camera gives thick pea-soup fog; a wide band ending at the horizon gives gentle atmospheric haze. To hide pop-up at the camera's far clipping range, set the fog far just inside the CameraRange far value so geometry has fully faded before it is clipped. Fog must be switched on with CameraFogMode before the range has any visible effect. See also: CameraFogMode, CameraFogColor, CameraRange. |
Example
; CameraFogRange Example ; ---------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,0 ; Grey clear colour matches the fog colour so fogged pillars blend into the sky CameraClsColor camera,128,128,128 light=CreateLight() RotateEntity light,45,45,0 ; Textured ground plane gives a sense of distance plane=CreatePlane() ground_tex=LoadTexture("media/MossyGround.BMP") ScaleTexture ground_tex,4,4 EntityTexture plane,ground_tex ; An avenue of pillars marching into the distance shows the fog thickening For z=10 To 150 Step 10 pillar=CreateCylinder() ScaleEntity pillar,0.5,3,0.5 PositionEntity pillar,-4,3,z pillar=CreateCylinder() ScaleEntity pillar,0.5,3,0.5 PositionEntity pillar,4,3,z Next ; Switch linear fog on and give it a colour CameraFogMode camera,1 CameraFogColor camera,128,128,128 fog_far#=40 While Not KeyDown(1) ; Press [ / ] to pull the fog closer or push it further away If KeyDown(26) And fog_far>5 Then fog_far=fog_far-0.5 If KeyDown(27) And fog_far<200 Then fog_far=fog_far+0.5 ; Fog fades in from the near distance and is solid at the far distance CameraFogRange camera,2,fog_far ; 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,"Arrow keys: move camera [ / ]: change fog distance Esc: exit" Text 0,20,"CameraFogRange camera,2,"+fog_far Flip Wend End
Index