CameraEffect camera,shader
Parameters
|
camera - camera handle shader - post-processing shader handle |
Description
|
Attaches a post-processing shader to a camera. Post effects work on the camera's finished 3D picture: bloom, vignette, grayscale, depth fog, screen-space reflections and so on. Each call appends the shader to the camera's effect stack, and effects run in attachment order with each result feeding the next - attach bloom before colour grading and the glow gets graded too. Effects that declare a pipeline stage (scene-linear, display-linear, presentation) are additionally kept in stage order around the engine's tone-map pass. Effects are confined to the camera's viewport, and 2D drawing done after RenderWorld is never affected. Only post shaders attach - a material shader raises a runtime error and belongs on entities or brushes instead. The camera retains the attached instance, so freeing your handle is safe. Attaching one handle to two cameras shares its parameter values; use CopyShader first when each camera needs its own settings. Toggle an attached effect with CameraEffectEnabled and detach it with RemoveCameraEffect. For the full story, see camera-effect stacks in the shader guide. Requires Extended mode. See also: CameraEffectEnabled, RemoveCameraEffect, LoadShader, CopyShader. |
Example
; CameraEffect Example ; -------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() ; Two cameras render the same scene side by side for comparison left_camera=CreateCamera() PositionEntity left_camera,0,0,-7 CameraViewport left_camera,0,0,320,480 CameraClsColor left_camera,25,50,110 right_camera=CreateCamera() PositionEntity right_camera,0,0,-7 CameraViewport right_camera,320,0,320,480 CameraClsColor right_camera,25,50,110 light=CreateLight() RotateEntity light,35,-30,0 cube=CreateCube() PositionEntity cube,-1.5,0,0 EntityColor cube,255,55,25 sphere=CreateSphere(24) EntityColor sphere,40,230,80 cone=CreateCone(24) PositionEntity cone,1.5,0,0 EntityColor cone,40,100,255 ; Attach a greyscale post effect to the right-hand camera only effect=LoadShader("assets/help_post.b3shader") CameraEffect right_camera,effect strength#=1.0 While Not KeyDown(1) ; Press [ / ] to change the effect's Strength parameter If KeyDown(26) And strength>0 Then strength=strength-0.01 If KeyDown(27) And strength<1 Then strength=strength+0.01 ShaderFloat effect,"Strength",strength TurnEntity cube,0.2,0.4,0 TurnEntity sphere,0.1,-0.35,0 TurnEntity cone,0.25,0.3,0 RenderWorld Color 255,255,255 Text 160,12,"ORIGINAL",True Text 480,12,"CAMERA EFFECT",True Text 0,440,"[ / ] : effect strength Esc: exit" Text 0,460,"CameraEffect right_camera,effect Strength "+strength Flip Wend FreeShader effect End
Index