Shader: Create Synchronous
Compile a shader using the source currently stored in its Vertex and Pixel properties. Use it after loading or editing your drawing shader sources. Changing source text alone does not compile it; inspect a raised error to diagnose a compilation failure.
Luau
Shader:Create() -> ()Parameters
Call this method with a Shader receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
This function takes no arguments.
Returns
()This function returns no values.
Usage notes
Set the shader source before calling Create. Compilation failures raise an error.
Example
Luau
-- Supply compatible vertex and pixel shader source files first.
local vertex = readfile("shaders/example.vertex")
local pixel = readfile("shaders/example.pixel")
local shader = Drawing.new("Shader")
shader.Vertex = vertex
shader.Pixel = pixel
local ok, message = pcall(function()
shader:Create()
end)
print(ok and "Shader compiled" or message)
shader:Remove()