- Documentation
- Client functions
- dxSetShaderValue
Function
dxSetShaderValue
Sets a shader parameter. When the parameter is a texture declared in the .fx code (or the shader has none) and the value is a texture (dxCreateTexture, render target, browser) or an image path, that image becomes the new texture swapped into the world. Numbers and vectors are stored for compatibility with existing scripts.
Syntax
bool dxSetShaderValue(element theShader, string parameterName, any value [, float ...])Arguments
theShaderelement- The shader.
parameterNamestring- Parameter name from the .fx code.
valueany- A texture, image path, number or table of numbers.
...float, optional- Further vector numbers.
Returns
true on success, false for an unknown material.
Example
local shader = dxCreateShader("texture gTexture; technique t { pass P0 { Texture[0] = gTexture; } }")
local target = dxCreateRenderTarget(512, 256)
dxSetShaderValue(shader, "gTexture", target)
engineApplyShaderToWorldTexture(shader, "heat_02")
See also
dxCreateShaderCreates 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 withdxSetShaderValueunder a texture parameter replaces the world textures chosen withengineApplyShaderToWorldTexture(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.dxCreateTextureCreates a texture: from a resource image file, from pixels (plain,png,jpeg,dds) or an empty one of a given size. The texture is a material fordxDrawImage,dxDrawMaterial*3Dand shaders.