lovr.graphics.newShader

Creates a new Shader.

Create a Shader with custom GLSL code.

shader = lovr.graphics.newShader(vertex, fragment, options)

Arguments

NameTypeDefaultDescription
vertexstringThe code or filename of the vertex shader. If nil, the default vertex shader is used.
fragmentstringThe code or filename of the fragment shader. If nil, the default fragment shader is used.
optionstable{}Optional settings for the Shader.
.flagstable{}A table of key-value options passed to the Shader.
.stereobooleantrueWhether the Shader should be configured for stereo rendering (Currently Android-only).

Returns

NameTypeDescription
shaderShaderThe new Shader.

Create a new instance of a built-in Shader.

shader = lovr.graphics.newShader(default, options)

Arguments

NameTypeDefaultDescription
defaultDefaultShaderA builtin shader to use for the shader code.
optionstable{}Optional settings for the Shader.
.flagstable{}A table of key-value options passed to the Shader.
.stereobooleantrueWhether the Shader should be configured for stereo rendering (Currently Android-only).

Returns

NameTypeDescription
shaderShaderThe new Shader.

Notes

The flags table should contain string keys, with boolean or numeric values. These flags can be used to customize the behavior of Shaders from Lua, by using the flags in the shader source code. Numeric flags will be available as constants named FLAG_<flagName>. Boolean flags can be used with #ifdef and will only be defined if the value in the Lua table was true.

The following flags are used by shaders provided by LÖVR:

Currently, up to 32 shader flags are supported.

The stereo option is only necessary for Android. Currently on Android, only stereo shaders can be used with stereo Canvases, and mono Shaders can only be used with mono Canvases.

See also