Blitz3D+ Command Reference

BrushStandard brush[,enable]

Parameters

brush - brush handle

enable (optional) - True attaches the built-in Standard material, False returns the brush to classic rendering; True (default)

Description

Turns the built-in Standard material on or off for a brush.

The Standard material gives an ordinary Blitz brush modern physically based lighting. You rarely need to enable it explicitly, because every Standard brush command (BrushPBR, the map commands, the layer commands) attaches it automatically - so this command's main jobs are switching a brush back to classic rendering, and making intent obvious in code.

Disabling leaves the ordinary brush state - colour, alpha, textures, blend and FX flags - intact, so the brush simply renders the classic way again. The gotcha is the other direction: enabling again starts from a fresh Standard material with default values, so any maps, PBR factors and layers you had set must be set again. Note the fresh defaults are metallic 1, roughness 1.

Enabling also replaces any custom shader stored with BrushShader.

For the full story, see the Standard material in the shader guide.

Requires Extended mode.

See also: CreateStandardBrush, BrushPBR, BrushShader, CreateBrush.

Example

; BrushStandard 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

; Start from an ordinary classic brush
brush=CreateBrush(255,120,40)
sphere=CreateSphere(32)

standard=True

While Not KeyDown(1)

    ; Press Space to switch between Standard and classic rendering
    If KeyHit(57) Then standard=Not standard

    ; Enable or disable the Standard material on the brush
    BrushStandard brush,standard

    ; Enabling Standard starts from defaults, so set the factors again
    If standard Then BrushPBR brush,0,0.45
    PaintEntity sphere,brush

    TurnEntity sphere,0,0.4,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 Standard material   Arrow keys: move camera   Esc: exit"
    If standard Then Text 0,20,"BrushStandard brush,1 (physically based)" Else Text 0,20,"BrushStandard brush,0 (classic rendering)"

    Flip

Wend

FreeBrush brush
End

Index