DxCreateShader: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element, string dxCreateShader ( string filepath[, float priority = 0, float maxDistance ] ) | element, string dxCreateShader ( string filepath [, float priority = 0, float maxDistance = 0, bool layered = false, string elementTypes = "world,vehicle,object,other" ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 14: | Line 14: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
'' | ''All the following optional arguments are only relevant when the shader is used with [[engineApplyShaderToWorldTexture]]'' | ||
*'''priority:''' If more than one shader is matched to a world texture, the shader with the highest priority will be used. If there is more than one shader with the same highest priority, the most recently | *'''priority:''' If more than one shader is matched to a world texture, the shader with the highest priority will be used. If there is more than one shader with the same highest priority, the most recently created shader is used. | ||
*'''maxDistance:''' If | *'''maxDistance:''' If non-zero, the shader will be applied to textures nearer than maxDistance only. This can speed up rendering, but (to look good) may require the shader to fade out it's own effect as the texture reaches maxDistance. | ||
{{New feature/item|4.0140|1.3.0|4435| | |||
*'''layered:''' When set to true, the shader will be drawn in a separate render pass. Several layered shaders can be drawn on the same world texture. | |||
*'''elementTypes:''' A comma seperated list of element types to restrict this shader to. Valid element types are: | |||
** world - Textures in the GTA world | |||
** ped - Player and ped textures | |||
** vehicle - Vehicles textures | |||
** object - Objects textures | |||
** other - Element textures which are not peds, vehicles or objects | |||
** all - Everything | |||
}} | |||
===Returns=== | ===Returns=== | ||
Line 44: | Line 55: | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==Changelog== | |||
{{ChangelogHeader}} | |||
{{ChangelogItem|1.3.0-9.04435|Added layered and elementTypes arguments}} | |||
==See Also== | ==See Also== | ||
{{Drawing_functions}} | {{Drawing_functions}} |
Revision as of 17:57, 31 July 2012
This function creates a shader element that can be used in the dxDraw functions. Successful shader creation is not guaranteed unless the Effect File contains a fallback technique which will work on every PC in the universe.
It is highly recommended that dxSetTestMode is used when writing and testing scripts using dxCreateShader.
Syntax
element, string dxCreateShader ( string filepath [, float priority = 0, float maxDistance = 0, bool layered = false, string elementTypes = "world,vehicle,object,other" ] )
Required Arguments
- filepath: The filepath of the shader Effect File(.fx) file
Optional Arguments
All the following optional arguments are only relevant when the shader is used with engineApplyShaderToWorldTexture
- priority: If more than one shader is matched to a world texture, the shader with the highest priority will be used. If there is more than one shader with the same highest priority, the most recently created shader is used.
- maxDistance: If non-zero, the shader will be applied to textures nearer than maxDistance only. This can speed up rendering, but (to look good) may require the shader to fade out it's own effect as the texture reaches maxDistance.
Returns
- element: A shader element if successful, false if invalid arguments were passed to the function. You should always check to see if this function has returned false.
- string: The name of the technique that will be used.
Example
addEventHandler( "onClientRender", root, function() if myShader then dxDrawImage( 100, 350, 300, 350, myShader ) end end ) -- Use 'toggle' command to switch shader on and off addCommandHandler( "toggle", function() if not myShader then myShader = dxCreateShader( "fancything.fx" ) -- Create shader else destroyElement( myShader ) -- Destroy shader myShader = nil end end )
Changelog
Version | Description |
---|
1.3.0-9.04435 | Added layered and elementTypes arguments |
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource