ShaderInt shader,parameter$,value
Parameters
|
shader - shader handle parameter$ - name of an integer parameter declared by the shader asset value - new value |
Description
|
Sets a named integer parameter of a shader. Integer parameters are typically modes, switches and counts rather than smooth dials. The expensive built-in effects share one convention worth knowing: a Quality parameter where 0 is low, 1 is balanced and 2 is high - the knob to reach for when SSAO or depth of field costs too much on a target machine. Names are matched without regard to case and the value affects only this instance. The asset must declare the name as an int; 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, ShaderVector, ShaderColor, ShaderTexture, LoadShader. |
Example
; ShaderInt 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 an integer parameter named Mode shader=LoadShader("assets/help_surface.b3shader") EntityShader cube,shader mode=1 While Not KeyDown(1) ; Press 1 / 2 to pick the shader's mode switch If KeyHit(2) Then mode=0 If KeyHit(3) Then mode=1 ; Send the integer switch to the shader ShaderInt shader,"Mode",mode 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 mode_name$="plain tint" If mode=1 Then mode_name="tint plus glow" Color 255,255,255 Text 0,0,"1 / 2 : mode Arrow keys: move camera Esc: exit" Text 0,20,"ShaderInt shader,"+Chr$(34)+"Mode"+Chr$(34)+","+mode+" ("+mode_name+")" Flip Wend FreeShader shader End
Index