Pass:setShader

Edit

Sets the active shader. In a render pass, the Shader will affect all drawing operations until it is changed again. In a compute pass, the Shader will be run when Pass:compute is called.




Arguments

NameTypeDescription
shaderShader The shader to use.

Returns

Nothing

Use one of the default shaders for drawing.

Arguments

NameTypeDescription
defaultDefaultShader One of the default shaders to use.

Returns

Nothing

Switch back to using an automatic shader for drawing.

Arguments

None

Returns

Nothing

Notes

Changing the shader will preserve resource bindings (the ones set using Pass:send) unless the new shader declares a resource for a binding number using a different type than the current shader. In this case, the resource "type" means one of the following:

If the new shader doesn't declare a resource in a particular binding number, any resource there will be preserved.

If there's a clash in resource types like this, the variable will be "cleared". Using a buffer variable that has been cleared is not well-defined, and may return random data or even crash the GPU. For textures, white pixels will be returned. Samplers will use linear filtering and the repeat wrap mode.

Changing the shader will not clear push constants set in the Constants block.

See also