ShaderProgram

Up and coming: shot check knows this class and its members today, and programs run it once the native runtime lands.

Up and coming

Write a GLSL effect once and run it over any picture, or draw instanced geometry in one call.

Load one with GpuService:LoadShaderAsync, or put a ShaderProgram in the project tree whose Fragment and Vertex are ShaderModules. RunAsync is one full-picture pass into one or several textures; DrawAsync draws instanced geometry, with blending and depth set per draw. Uniforms take numbers, booleans, vectors, colours, CFrames, number lists and textures.

Made with Instance.new("ShaderProgram") or Clone().

Properties

NameTypeDefaultDescription
FragmentShaderModule?The fragment ShaderModule a program in the project tree is compiled from, on first use.
VertexShaderModule?The vertex ShaderModule; nil uses the built-in full-picture vertex shader, which hands the fragment shader SamplePosition from 0 to 1.
Sourcestringread-onlyRead-only: the folder, file or module path the program was compiled from.
HotReloadbooleanFalse by default; true recompiles when its files or modules change, for tuning a look while it is on screen.
Diagnostics{ ShaderDiagnostic }read-onlyRead-only: the compile's problems, each with Path, Line, Column and Message.
Uniforms{ string }read-onlyRead-only: the uniform names the compiled program uses.

Methods

NameArgumentsReturnsDescription
SetUniform(name: string, value: UniformValue)()Sets a uniform that stays until changed, without yielding; a GpuTexture becomes a sampler, its slot given by name.
RunAsync
yields
(output: GpuTexture | { GpuTexture }, uniforms: { [string]: UniformValue }?)(boolean, string?)Runs one full-picture pass into the output and waits for it; several outputs go to layout(location = n) in order.
DrawAsync
yields
(options: DrawOptions)(boolean, string?)Draws instanced geometry from VertexBuffers into the Targets, with Blend, DepthTest and Clear set per draw, and waits for it.

Events

NamePassesDescription
Recompiled(boolean)Fires after a hot reload, passing true when it worked; on false the last good program stays and Diagnostics say why.
From ShotInstance 33