CameraAmbientOcclusion
Darkens creases and corners.
CameraAmbientOcclusion camera,enable[,intensity#][,radius#]
Parameters
- camera
- camera handle
- enable
- True to switch ambient occlusion on, False to switch it off
- intensity# (optional)
- how dark the occluded areas become. Defaults to 4.
- radius# (optional)
- how far, in world units, surfaces look for nearby geometry. Defaults to 2.
Description
Ambient occlusion darkens the creases, corners and gaps where surfaces meet - the bottom of a wall, the floor around a crate, the space between two boxes - the way real light struggles to reach them. It gives scenes a feeling of weight and depth. , off unless a program switches it on.
It is worked out from what the camera sees each frame, so it applies to everything in view with no extra work for each model. Set the radius to suit the size of your world: about the size of the gaps you want darkened.
Ambient occlusion is set for each camera. It is not available on phones and tablets, where the command is ignored.
Example
; Ambient occlusion and glow example (ArcBasic extensions); A toggles ambient occlusion, G toggles glow, Escape quitsGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,4,-9TurnEntity camera,20,0,0CameraClsColor camera,10,10,25AmbientLight 120,120,130light=CreateLight()RotateEntity light,60,40,0LightColor light,140,140,140ground=CreatePlane()EntityColor ground,180,180,180For i=0 To 2 box=CreateCube() PositionEntity box,-3+i*3,1,2+(i Mod 2) EntityColor box,200,200,200Next; this ball gives off its own light, so it glowslava=CreateSphere(16)PositionEntity lava,-1.5,1,-1EntityColor lava,255,80,40EntityGlow lava,2ball=CreateSphere(16)PositionEntity ball,1.5,1,-1EntityColor ball,60,160,255ao=True : glow=TrueCameraAmbientOcclusion camera,aoCameraGlow camera,glowWhile Not KeyDown(1) If KeyHit(30) Then ao=Not ao : CameraAmbientOcclusion camera,ao If KeyHit(34) Then glow=Not glow : CameraGlow camera,glow RenderWorld Text 0,0,"A: ambient occlusion G: glow" FlipWendEnd
