lovr.graphics.newShader

Edit

Creates a Shader, which is a small program that runs on the GPU.

Shader code is usually written in GLSL and compiled to SPIR-V bytecode. SPIR-V is faster to load but requires a build step. Either form can be used to create a shader.




Create a graphics shader. It has a vertex stage that computes vertex positions, and a fragment stage that computes pixel colors.

Arguments

NameTypeDescription
vertexstring A string, path to a file, or Blob containing GLSL or SPIR-V code for the vertex stage. Can also be a DefaultShader to use that shader's vertex code.
fragmentstring A string, path to a file, or Blob containing GLSL or SPIR-V code for the fragment stage. Can also be a DefaultShader to use that shader's fragment code.
optionstable Shader options.
.flagstable A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader.
.labelstring A label to use for the shader in debugging tools.

Returns

NameTypeDescription
shaderShader The new shader.

Create a compute shader.

Arguments

NameTypeDescription
computestring A string, path to a file, or Blob containing GLSL or SPIR-V code for the compute stage.
optionstable Shader options.
.flagstable A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader.
.labelstring A label to use for the shader in debugging tools.

Returns

NameTypeDescription
shaderShader The new shader.

Create a copy of one of the default shaders (used to provide different flags).

Arguments

NameTypeDescription
defaultDefaultShader The default shader to use.
optionstable Shader options.
.flagstable A table of shader flags. The keys of the table should be flag names or flag ID numbers. The values can be numbers or booleans, depending on the type of the flag as declared in the shader.
.labelstring A label to use for the shader in debugging tools.

Returns

NameTypeDescription
shaderShader The new shader.

See also