; BrushOcclusionMap Example ; ------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,0,-5 light=CreateLight() RotateEntity light,35,-30,0 ; Occlusion darkens image-based ambient light, so give the brush ; a bright environment map to be occluded environment=CreateTexture(64,32,1+8+32) SetBuffer TextureBuffer(environment) ClsColor 200,210,235 Cls SetBuffer BackBuffer() ; Draw the occlusion map: white (open) with dark baked-shadow spots ao=CreateTexture(64,64,1+8) SetBuffer TextureBuffer(ao) ClsColor 255,255,255 Cls Color 70,70,70 Oval 16,16,32,32,True SetBuffer BackBuffer() brush=CreateStandardBrush(220,170,100) BrushEnvironmentMap brush,environment sphere=CreateSphere(32) strength#=1.0 While Not KeyDown(1) ; Press [ / ] to change the occlusion strength If KeyDown(26) And strength>0 Then strength=strength-0.01 If KeyDown(27) And strength<1 Then strength=strength+0.01 ; Apply the ambient-occlusion map and repaint the sphere BrushOcclusionMap brush,ao,0,strength PaintEntity sphere,brush TurnEntity sphere,0,0.3,0 ; 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 Color 255,255,255 Text 0,0,"[ / ] : strength Arrow keys: move camera Esc: exit" Text 0,20,"BrushOcclusionMap brush,ao,0,"+strength+" (0 disables the map)" Flip Wend FreeBrush brush End