EngineApplyShaderToWorldTexture
From Multi Theft Auto: Wiki
This function applies a shader to one or more world textures.
Tip:
|
Syntax
bool engineApplyShaderToWorldTexture ( element shader, string textureName [, element targetElement = nil, bool appendLayers = true ] )
OOP Syntax Help! I don't understand this!
- Method: shader:applyToWorldTexture(...)
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
- 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, objects and peds.
- appendLayers: allows two or more layered shaders to be applied in the same texture. You may want to modify the DepthBias in the technique pass to avoid Z-fighting artifacts when using this.
Returns
Returns true if the shader was successfully applied, false otherwise.
Example
This example will replace the texture of a group of common explosions (grenades, rockets, etc) with a custom explosion effect
theTechnique = dxCreateShader("shader.fx") explosionTexture = dxCreateTexture( "tex/Explosion.png") function replaceEffect() engineApplyShaderToWorldTexture(theTechnique, "fireball6") dxSetShaderValue (theTechnique, "gTexture", explosionTexture) end addEventHandler("onClientResourceStart",resourceRoot,replaceEffect)
This example will apply a shader to the "des_logwall" world texture (which is used by the house near the 'play' gamemode spawn point)
theTechnique = dxCreateShader("shader.fx") engineApplyShaderToWorldTexture(theTechnique, "des_logwall")
This example will apply a shader to the current vehicle of the local player
theTechnique = dxCreateShader( "shader.fx" ) function applyShader(thePlayer, seat) local theVehicle = source if seat == 0 and thePlayer == localPlayer then engineApplyShaderToWorldTexture(theTechnique, "vehiclegrunge256", theVehicle) engineApplyShaderToWorldTexture(theTechnique, "?emap*", theVehicle) end end addEventHandler("onClientVehicleEnter", getRootElement(), applyShader) function removeShader(thePlayer, seat) local theVehicle = source if seat == 0 and thePlayer == localPlayer then engineRemoveShaderFromWorldTexture(theTechnique, "vehiclegrunge256", theVehicle) engineRemoveShaderFromWorldTexture(theTechnique, "?emap*", theVehicle) end end addEventHandler("onClientVehicleExit", getRootElement(), removeShader)
Basic texture replacement shader example (compatible with all script examples on this page):
texture gTexture; technique TexReplace { pass P0 { Texture[0] = gTexture; } }
- Save the above code as [shadername].fx
See Also
- engineApplyShaderToWorldTexture
- engineGetModelIDFromName
- engineGetModelLODDistance
- engineGetModelNameFromID
FROM VERSION 1.5.7 r19626 ONWARDS
FROM VERSION 1.5.7 r20147 ONWARDS
- engineGetModelTextureNames
- engineGetVisibleTextureNames
- engineImportTXD
- engineLoadCOL
- engineLoadDFF
- engineLoadIFP
- engineLoadTXD
- engineRemoveShaderFromWorldTexture
- engineReplaceAnimation
- engineReplaceCOL
- engineReplaceModel
- engineRestoreAnimation
- engineRestoreCOL
- engineRestoreModel
- engineSetAsynchronousLoading
- engineSetModelLODDistance
- engineSetSurfaceProperties
- engineGetSurfaceProperties
- engineResetSurfaceProperties
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
FROM VERSION 1.5.7 r19626 ONWARDS
- dxDrawMaterialSectionLine3D
- dxDrawRectangle
- dxDrawText
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource