Blitz3D+ Command Reference

BrushFX brush,fx

Parameters

brush - brush handle
fx - effect flags, added together:
0: none (default)
1: full-bright - ignore lighting, draw at full colour
2: use vertex colours instead of the brush colour
4: flat shaded - no smoothing between vertex normals
8: disable fog
16: disable backface culling - triangles visible from both sides
32: force alpha-blending - required for per-vertex alpha

Description

Sets miscellaneous effect flags for a brush.

Add flags together to combine effects: 3 gives a full-bright, vertex-coloured material. Each call replaces the previous flags rather than adding to them.

The two most-used combinations: flag 1 for things that should ignore the scene's lights (skyboxes, HUD props, glowing pickups), and flags 2+32 to let VertexColor drive both colour and per-vertex transparency for effects meshes. Flag 16 suits thin geometry like leaves and fences that must show from both sides.

This is the brush-level twin of EntityFX - build the effect into a material, then paint it with PaintSurface, PaintMesh or PaintEntity.

See also: EntityFX, VertexColor, BrushBlend, CreateBrush, PaintMesh.

Example

; BrushFX Example
; ---------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()

; Fog tints distant objects, so the disable-fog flag is easy to spot
CameraFogMode camera,1
CameraFogRange camera,1,15
CameraFogColor camera,100,100,140
CameraClsColor camera,100,100,140

light=CreateLight()
RotateEntity light,45,45,0

; A green orb to paint. A brush is a 'paint recipe' applied with PaintEntity.
orb=CreateSphere(16)
PositionEntity orb,0,0,10

brush=CreateBrush(0,255,0)

mode=0

While Not KeyDown(1)

    ; Space cycles through the fx modes
    If KeyHit(57) Then mode=(mode+1) Mod 6

    ; Each mode is a single flag: 0,1,2,4,8,16 (flags may also be added together)
    If mode=0 Then fx=0 Else fx=1 Shl (mode-1)
    fx_name$="nothing (default)"
    If fx=1 Then fx_name="full-bright"
    If fx=2 Then fx_name="use vertex colors"
    If fx=4 Then fx_name="flatshaded"
    If fx=8 Then fx_name="disable fog"
    If fx=16 Then fx_name="disable backface culling"

    ; Set the brush fx, then repaint the orb so the change shows
    BrushFX brush,fx
    PaintEntity orb,brush

    TurnEntity orb,0,1,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

    Text 0,0,"Space: next fx mode   Arrows: camera   Esc: exit"
    Text 0,20,"BrushFX brush,"+fx+"  ("+fx_name+")"

    Flip

Wend

End

Index