Blitz3D+ Command Reference

CameraFogColor camera,red#,green#,blue#

Parameters

camera - camera handle

red# - red value of fog, in the range 0-255
green# - green value of fog, in the range 0-255
blue# - blue value of fog, in the range 0-255

Description

Sets a camera's fog colour. Defaults to 0,0,0 (black).

Distant geometry blends towards this colour as it approaches the far fog distance. Match it to the scene's backdrop for a natural look: grey-white for mist, the sky colour for outdoor haze, near-black for a dark dungeon. Setting CameraClsColor to the same colour makes geometry melt into the background with no visible horizon line.

The colour only shows once fog is switched on with CameraFogMode - CameraFogColor on its own displays no fog. Set where the fade starts and ends with CameraFogRange.

See also: CameraFogMode, CameraFogRange, CameraClsColor.

Example

; CameraFogColor Example
; ----------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,2,0

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 colour clearly
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 set its range
CameraFogMode camera,1
CameraFogRange camera,5,50

red=128
green=128
blue=128

While Not KeyDown(1)

    ; Hold keys 1/2, 3/4, 5/6 to lower and raise the red, green and blue values
    If KeyDown(2) And red>0 Then red=red-1
    If KeyDown(3) And red<255 Then red=red+1
    If KeyDown(4) And green>0 Then green=green-1
    If KeyDown(5) And green<255 Then green=green+1
    If KeyDown(6) And blue>0 Then blue=blue-1
    If KeyDown(7) And blue<255 Then blue=blue+1

    ; Apply the fog colour to the camera
    CameraFogColor camera,red,green,blue

    ; Match the clear colour to the fog so the horizon blends smoothly
    CameraClsColor camera,red,green,blue

    ; 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,"Keys 1-6: change red/green/blue   Arrow keys: move camera   Esc: exit"
    Text 0,20,"CameraFogColor camera,"+red+","+green+","+blue

    Flip

Wend

End

Index