; BrushNormalMap 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 bumpy tangent-space normal map: flat blue with random dents SeedRnd MilliSecs() normal=CreateTexture(64,64,1+8) SetBuffer TextureBuffer(normal) ClsColor 128,128,255 Cls For i=1 To 40 Color Rand(68,188),Rand(68,188),255 Oval Rand(0,56),Rand(0,56),8,8,True Next SetBuffer BackBuffer() brush=CreateStandardBrush(200,120,70) sphere=CreateSphere(32) scale#=1.0 While Not KeyDown(1) ; Press [ / ] to change the bump strength If KeyDown(26) And scale>0 Then scale=scale-0.02 If KeyDown(27) And scale<3 Then scale=scale+0.02 ; Apply the normal map and repaint the sphere BrushNormalMap brush,normal,0,scale 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,"[ / ] : bump scale Arrow keys: move camera Esc: exit" Text 0,20,"BrushNormalMap brush,normal,0,"+scale Flip Wend FreeBrush brush End