EngineApplyShaderToWorldTexture: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function applies a [[shader]] to one or more world textures. The shader inherits the render states of the original when it is drawn, so texture stage 0 will already be set to the original texture.
This function applies a [[shader]] to one or more world textures.
 
''Note: The shader inherits the render states of the original when it is drawn, so texture stage 0 will already be set to the original texture.''


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool engineApplyShaderToWorldTexture ( element shader, string textureName )
bool engineApplyShaderToWorldTexture ( element shader, string textureName [, element targetElement ] )
</syntaxhighlight>  
</syntaxhighlight>  


Line 12: Line 14:
*'''textureName:''' The name of the world texture to apply the shader to. Wildcard matching e.g. "ro?ds*" can be used to apply to more than one texture at a time.
*'''textureName:''' The name of the world texture to apply the shader to. Wildcard matching e.g. "ro?ds*" can be used to apply to more than one texture at a time.


===Optional Arguments===
{{New feature/item|4.0140|1.3.0|4140|
*'''targetElement:''' The element to restrict applying the shader to. If this is not set the shader will be applied to everything using the texture name. Valid element types for targetElement are [[vehicle|vehicles]] and [[Object|objects]].
}}
===Returns===
===Returns===
Returns ''true'' if the shader was successfully applied, ''false'' otherwise.
Returns ''true'' if the shader was successfully applied, ''false'' otherwise.
Line 21: Line 27:
engineApplyShaderToWorldTexture( myShader, "des_logwall" )
engineApplyShaderToWorldTexture( myShader, "des_logwall" )
</syntaxhighlight>
</syntaxhighlight>
==Changelog==
{{ChangelogHeader}}
{{ChangelogItem|1.3.0-9.04140|Added targetElement argument}}


==See Also==
==See Also==
{{Engine_functions}}
{{Engine_functions}}
{{Drawing_functions}}
{{Drawing_functions}}

Revision as of 16:21, 24 May 2012

This function applies a shader to one or more world textures.

Note: The shader inherits the render states of the original when it is drawn, so texture stage 0 will already be set to the original texture.

Syntax

bool engineApplyShaderToWorldTexture ( element shader, string textureName [, element targetElement ] )

Required Arguments

  • shader: The shader which is to be applied
  • textureName: The name of the world texture to apply the shader to. Wildcard matching e.g. "ro?ds*" can be used to apply to more than one texture at a time.

Optional Arguments

ADDED/UPDATED IN VERSION 1.3.0 r4140:
  • targetElement: The element to restrict applying the shader to. If this is not set the shader will be applied to everything using the texture name. Valid element types for targetElement are vehicles and objects.

Returns

Returns true if the shader was successfully applied, false otherwise.

Example

This example will apply a shader to the "des_logwall" world texture (which is used by the house near the 'play' gamemode spawn point)

myShader = dxCreateShader( "hello.fx" )
engineApplyShaderToWorldTexture( myShader, "des_logwall" )

Changelog

Version Description
1.3.0-9.04140 Added targetElement argument

See Also