Blitz3D+ Command Reference

RemoveCameraEffect camera,shader

Parameters

camera - camera handle

shader - post shader to detach from this camera

Description

Removes a post-processing effect from a camera.

The effect is taken out of the camera's stack and the remaining effects close ranks in their existing order. Your script handle is untouched - the shader keeps its parameter values and can be attached again later, though a re-attach appends it at the end of the stack rather than restoring its old position. If you expect to turn the effect back on soon, CameraEffectEnabled is the better tool because it keeps the position.

Removing a shader that is not attached to the camera does nothing. Only post shaders are accepted; passing a material shader raises a runtime error.

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

Requires Extended mode.

See also: CameraEffect, CameraEffectEnabled, FreeShader.

Example

; RemoveCameraEffect 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
attached=True

While Not KeyDown(1)

    ; Press Space to remove the effect, or attach it again
    If KeyHit(57)
        If attached
            RemoveCameraEffect camera,effect
        Else
            CameraEffect camera,effect
        EndIf
        attached=Not attached
    EndIf

    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,"Space: remove / re-attach the effect   Arrow keys: move camera   Esc: exit"
    If attached Then Text 0,20,"Effect attached - Space calls RemoveCameraEffect camera,effect" Else Text 0,20,"RemoveCameraEffect camera,effect was called - colours are back"

    Flip

Wend

FreeShader effect
End

Index