ShaderFloat shader,parameter$,value#
Parameters
|
shader - shader handle parameter$ - name of a float parameter declared by the shader asset value# - new value |
Description
|
Sets a named number parameter of a shader. Floats are the everyday knobs of a shader's public interface - Strength, Radius, Amount, WaveHeight. Names are matched without regard to case, and the change affects only this instance, so two copies of one shader can hold different values. Setting one per frame is cheap, which makes this the natural way to animate an effect: sweep a dissolve's Amount from 0 to 1 as an enemy dies, or ease a vignette's Strength up as health drops. The asset must declare the name as a float. A misspelled name or a wrong-type setter raises a runtime error - deliberately strict, so typos surface at the line that caused them. Check the parameter's exact name and type in the asset's documentation or the built-in catalogue. For the full story, see named parameters in the shader guide. Requires Extended mode. See also: ShaderInt, ShaderVector, ShaderColor, ShaderTexture, LoadShader. |
Example
; ShaderFloat 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() ; The shader declares a float parameter named Amount (tint mix) shader=LoadShader("assets/help_surface.b3shader") EntityShader cube,shader amount#=0.75 While Not KeyDown(1) ; Press [ / ] to change the Amount parameter If KeyDown(26) And amount>0 Then amount=amount-0.01 If KeyDown(27) And amount<1 Then amount=amount+0.01 ; Send the new float value to the shader ShaderFloat shader,"Amount",amount 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,"[ / ] : amount Arrow keys: move camera Esc: exit" Text 0,20,"ShaderFloat shader,"+Chr$(34)+"Amount"+Chr$(34)+","+amount Flip Wend FreeShader shader End
Index