Blitz3D+ Command Reference

CameraEffectEnabled camera,shader[,enabled]

Parameters

camera - camera handle

shader - post shader already attached to this camera

enabled (optional) - True runs the effect, False bypasses it; True (default)

Description

Temporarily turns a camera effect on or off without removing it.

Bypassing keeps the effect's position in the stack and all its parameter values, so re-enabling restores exactly what you had - ideal for a graphics options menu, a photo-mode toggle, or pausing an expensive effect during heavy scenes. A bypassed effect costs nothing to render, and when the last effect using an expensive optional resource (such as depth or history buffers) is bypassed, the renderer releases those resources after a bounded delay.

The shader must already be attached to this camera with CameraEffect; otherwise a runtime error is raised. To take an effect out of the stack entirely, use RemoveCameraEffect.

For the full story, see camera-effect stacks in the shader guide.

Requires Extended mode.

See also: CameraEffect, RemoveCameraEffect, LoadShader.

Example

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

cube=CreateCube()
EntityColor cube,255,80,20

; Attach a greyscale post effect to the camera
effect=LoadShader("assets/help_post.b3shader")
CameraEffect camera,effect

While Not KeyDown(1)

    ; Hold Space to bypass the effect without detaching it
    enabled=Not KeyDown(57)
    CameraEffectEnabled camera,effect,enabled

    TurnEntity cube,0.2,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,"Hold Space: bypass the effect   Arrow keys: move camera   Esc: exit"
    Text 0,20,"CameraEffectEnabled camera,effect,"+enabled

    Flip

Wend

FreeShader effect
End

Index