Blitz3D+ Command Reference

BrushNormalMap brush[,texture][,frame][,scale#]

Parameters

brush - brush handle

texture (optional) - tangent-space normal map, or 0 to remove the map (default)

frame (optional) - frame of an animated texture; 0 (default)

scale# (optional) - strength of the bump detail; 1.0 (default)

Description

Adds small surface detail to a Standard material with a normal map.

A normal map makes light catch grooves, rivets, panel lines and rough stone that are not really in the geometry - big visual detail for zero extra polygons. Use the standard tangent-space maps (the light-blue looking ones) exported by any modern art tool; the texture is read as linear data, not colour.

The scale parameter exaggerates or softens the bumps: values above 1 deepen them, values towards 0 flatten the surface. If a mesh has no tangents of its own, Blitz3D generates them automatically using MikkTSpace, so loaded and built-in meshes both just work.

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: BrushBaseColorMap, BrushMetallicRoughnessMap, BrushClearcoatNormalMap, BrushPBR.

Example

; 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

Index