; BrushMetallicRoughnessMap 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 ; Draw a packed map in glTF layout: green=roughness, blue=metallic. ; Four quadrants: smooth metal, rough metal, smooth paint, rough paint. packed=CreateTexture(64,64,1+8) SetBuffer TextureBuffer(packed) Color 0,20,255 Rect 0,0,32,32,True Color 0,255,255 Rect 32,0,32,32,True Color 0,20,0 Rect 0,32,32,32,True Color 0,255,0 Rect 32,32,32,32,True SetBuffer BackBuffer() ; The map multiplies the factors set by BrushPBR, so use 1,1 brush=CreateStandardBrush(210,160,80) BrushPBR brush,1,1 sphere=CreateSphere(32) mapped=True While Not KeyDown(1) ; Press Space to attach or remove the packed map If KeyHit(57) Then mapped=Not mapped ; Set the map (texture zero removes it) and repaint the sphere If mapped Then BrushMetallicRoughnessMap brush,packed Else BrushMetallicRoughnessMap brush,0 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,"Space: toggle map Arrow keys: move camera Esc: exit" If mapped Then Text 0,20,"BrushMetallicRoughnessMap brush,packed" Else Text 0,20,"BrushMetallicRoughnessMap brush,0 (map removed)" Flip Wend FreeBrush brush End