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 variable values (the ones set using Pass:send) unless the new shader declares a variable with the same as one in the old shader, but a different type. The variable "type" means one of the following:

If there's a clash in types, the variable will be reset to use a default resource:

Uniform variables with basic types like float, vec3, mat4, etc. will have their data preserved as long as both shaders declare the variable with the same name and type.

See also