DxSetShaderValue: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Client function}} __NOTOC__ {{New feature|3.0110|1.1| Only available in 1.1 }} This sets a named parameter for a shader element ==Syntax== <syntaxhighlight lang="lua"> bool shaderSetVal...")
 
 
(18 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
{{New feature|3.0110|1.1|
Only available in 1.1
}}
This sets a named parameter for a [[shader]] element
This sets a named parameter for a [[shader]] element
{{Important Note|It's enough to set the texture only once if it's a render target}}


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool shaderSetValue ( element shader, string parameterName, mixed value )
bool dxSetShaderValue ( element theShader, string parameterName, mixed value )
</syntaxhighlight>  
</syntaxhighlight>  
{{OOP||[[shader]]:setValue}}


===Required Arguments===  
===Required Arguments===  
*'''shader:''' The shader element whose parameter is to be changed
*'''theShader:''' The shader element whose parameter is to be changed
*'''parameterName:''' The name of parameter
*'''parameterName:''' The name of parameter
*'''value:''' The value to set, which can be a [[texture]], a bool, a number, a table of numbers or a list of numbers
*'''value:''' The value to set, which can be a [[texture]], a bool, a number or a list of numbers('''max 16 floats(numbers)''')


===Returns===
===Returns===
Line 21: Line 21:
==Example==  
==Example==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
myShader = createShader( "hello.fx" )
myShader = dxCreateShader( "hello.fx" )
myTexture = createTexture( "man.png" )
myTexture = dxCreateTexture( "man.png" )
setShaderValue( myShader, "texure0", myTexture )                -- Set a texture
dxSetShaderValue( myShader, "texture0", myTexture )                -- Set a texture
setShaderValue( myShader, "bShowThing", true )                  -- Set a bool                   
dxSetShaderValue( myShader, "bShowThing", true )                  -- Set a bool                   
setShaderValue( myShader, "speed", 2.4 )                        -- Set a number
dxSetShaderValue( myShader, "speed", 2.4 )                        -- Set a float
setShaderValue( myShader, "positionOfCheese", 100, 200, 300 )  -- Set a list of numbers
dxSetShaderValue( myShader, "positionOfCheese", 100, 200, 300 )  -- Set a list of numbers, with max 16 numbers. Btw, this is a float: 3.4. This can be used to fill an array in HLSL.
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Drawing_functions}}
{{Drawing_functions}}
[[hu:dxSetShaderValue]]

Latest revision as of 14:00, 4 February 2021

This sets a named parameter for a shader element


[[{{{image}}}|link=|]] Important Note: It's enough to set the texture only once if it's a render target

Syntax

bool dxSetShaderValue ( element theShader, string parameterName, mixed value )

OOP Syntax Help! I don't understand this!

Method: shader:setValue(...)


Required Arguments

  • theShader: The shader element whose parameter is to be changed
  • parameterName: The name of parameter
  • value: The value to set, which can be a texture, a bool, a number or a list of numbers(max 16 floats(numbers))

Returns

Returns true if the shader element's parameter was successfully changed, false otherwise.

Example

myShader = dxCreateShader( "hello.fx" )
myTexture = dxCreateTexture( "man.png" )
dxSetShaderValue( myShader, "texture0", myTexture )                -- Set a texture
dxSetShaderValue( myShader, "bShowThing", true )                  -- Set a bool                  
dxSetShaderValue( myShader, "speed", 2.4 )                        -- Set a float
dxSetShaderValue( myShader, "positionOfCheese", 100, 200, 300 )   -- Set a list of numbers, with max 16 numbers. Btw, this is a float: 3.4. This can be used to fill an array in HLSL.

See Also