BrushOcclusionMap brush[,texture][,frame][,strength#]
Parameters
|
brush - brush handle texture (optional) - ambient-occlusion texture, or 0 to remove the map (default) frame (optional) - frame of an animated texture; 0 (default) strength# (optional) - occlusion strength from 0 to 1; 1.0 (default) |
Description
|
Darkens the crevices of a Standard material with a baked ambient-occlusion map. Ambient occlusion is the soft shading that gathers in pits, seams and corners. Baking it into a texture grounds a model: without it, ambient and environment lighting reach every point equally and the model looks strangely floaty. The map's red channel is used, read as linear data, and it darkens only ambient and image-based lighting - direct light from scene lights is untouched, which is physically the right behaviour. This is the same red channel a packed glTF ORM texture uses, so the texture you give BrushMetallicRoughnessMap can be reused here directly. Strength fades the effect: 0 disables it, 1 applies the map fully. Pass 0 as the texture to remove the map. Calling this command attaches the Standard material to the brush automatically. For the full map set, see Standard material maps in the shader guide. Requires Extended mode. See also: BrushMetallicRoughnessMap, BrushEnvironmentMap, BrushNormalMap. |
Example
; 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
Index