ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. dxCreateShader

Function

dxCreateShader

Creates a shader from a resource .fx file or from code given as a string. In Trilogy Hub a shader performs texture replacement: the image set with dxSetShaderValue under a texture parameter replaces the world textures chosen with engineApplyShaderToWorldTexture (e.g. custom billboards, signs on buildings, car wraps). The game material stays (lighting, reflections); only the image changes. Pixel and vertex effects from HLSL code are not executed.

Syntax

element, string dxCreateShader(string filepath [, int priority = 0, float maxDistance = 0, bool layered = false, string elementTypes = "world,vehicle,object,other"])

Arguments

filepathstring
Path to a .fx file in the resource, or the shader code.
priorityint, optional = 0
Priority when several shaders hit the same texture.Different type in MTA:SA: table macros = {}
maxDistancefloat, optional = 0
For compatibility with existing scripts.
layeredbool, optional = false
For compatibility with existing scripts.Different type in MTA:SA: float maxDistance = 0
elementTypesstring, optional = "world,vehicle,object,other"
For compatibility with existing scripts.Different type in MTA:SA: bool layered = false

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.
  • These MTA:SA arguments are not here: string elementTypes = "world,vehicle,object,other"

In MTA:SA

dxCreateShader(string filepath/raw_data, table macros = {}, float priority = 0, float maxDistance = 0, bool layered = false, string elementTypes = "world,vehicle,object,other")

Returns

A shader element and the technique name from the file, or false when the file cannot be loaded.

Example

local shader = dxCreateShader("texture gTexture; technique replace { pass P0 { Texture[0] = gTexture; } }")
local image = dxCreateTexture("billboard.png")
dxSetShaderValue(shader, "gTexture", image)
engineApplyShaderToWorldTexture(shader, "heat_02")

See also