ShaderColor shader,parameter$,red#,green#,blue#[,alpha#]
Parameters
|
shader - shader handle parameter$ - name of a color parameter declared by the shader asset red#, green#, blue# - colour components from 0 to 255 alpha# (optional) - alpha component from 0 to 255; 255 (default) |
Description
|
Sets a named colour parameter of a shader. Colours use the familiar Blitz 0-255 components and are converted to the shader's internal 0-to-1 floats for you. Typical uses: a rim-light's RimColor, a dissolve's EdgeColor, a vignette's Color, a force-field tint - anywhere an effect exposes a colour to match your game's palette. Names are matched without regard to case and the value affects only this instance, so copies of one shader can wear different colours. The asset must declare the name as a color; a missing name or wrong-type setter raises a runtime error. For the full story, see named parameters in the shader guide. Requires Extended mode. See also: ShaderFloat, ShaderInt, ShaderVector, ShaderTexture, LoadShader. |
Example
; ShaderColor 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 sphere=CreateSphere(32) ; The shader declares a colour parameter named Tint shader=LoadShader("assets/help_surface.b3shader") EntityShader sphere,shader angle#=0 paused=False While Not KeyDown(1) ; Press Space to pause the colour cycle If KeyHit(57) Then paused=Not paused If Not paused Then angle=angle+1 ; Feed a cycling colour into the shader's Tint parameter red=128+Sin(angle)*127 green=128+Sin(angle+120)*127 blue=128+Sin(angle+240)*127 ShaderColor shader,"Tint",red,green,blue TurnEntity sphere,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: pause colour cycle Arrow keys: move camera Esc: exit" Text 0,20,"ShaderColor shader,"+Chr$(34)+"Tint"+Chr$(34)+","+red+","+green+","+blue Flip Wend FreeShader shader End
Index