Difference between revisions of "Shader Variables"

(Created page)
 
m
Line 3: Line 3:
  
 
== Global built-in variables ==
 
== Global built-in variables ==
{{param|vec4|VaryingTexCoord|The interpolated per-vertex texture coordinate. Automatically set to the value of <code>VertexTexCoord</code> in the vertex shader before the <code>position</code> function is called. Used as the third argument to the <code>effect</code> function. Writable in the vertex shader.}}
 
{{param|vec4|VaryingColor|The interpolated per-vertex color. Automatically set to the value of <code>VertexColor</code> in the vertex shader before the <code>position</code> function is called. Used as the first argument to the <code>effect</code> function. Writable in the vertex shader.}}
 
 
{{param|mat4|TransformMatrix|The transformation matrix affected by [[love.graphics.translate]] and friends.}}
 
{{param|mat4|TransformMatrix|The transformation matrix affected by [[love.graphics.translate]] and friends.}}
 
{{param|mat4|ProjectionMatrix|The orthographic projection matrix.}}
 
{{param|mat4|ProjectionMatrix|The orthographic projection matrix.}}
 
{{param|mat4|TransformProjectionMatrix|The combined transform and projection matrices. Used as the first argument to the <code>position</code> function.}}
 
{{param|mat4|TransformProjectionMatrix|The combined transform and projection matrices. Used as the first argument to the <code>position</code> function.}}
 +
 +
{{param|vec4|VaryingTexCoord|The interpolated per-vertex texture coordinate. Automatically set to the value of <code>VertexTexCoord</code> in the vertex shader before the <code>position</code> function is called. Used as the third argument to the <code>effect</code> function. Writable in the vertex shader.}}
 +
{{param|vec4|VaryingColor|The interpolated per-vertex color. Automatically set to the value of <code>VertexColor</code> in the vertex shader before the <code>position</code> function is called. Used as the first argument to the <code>effect</code> function. Writable in the vertex shader.}}
  
 
== Vertex Shader built-in variables ==
 
== Vertex Shader built-in variables ==

Revision as of 06:02, 16 August 2013

Available since LÖVE 0.9.0
These built-in shader variables are not supported in earlier versions.

There are several built-in variables LÖVE provides in vertex and pixel shaders. All built-in variables are read-only unless otherwise specified.

Global built-in variables

mat4 TransformMatrix
The transformation matrix affected by love.graphics.translate and friends.
mat4 ProjectionMatrix
The orthographic projection matrix.
mat4 TransformProjectionMatrix
The combined transform and projection matrices. Used as the first argument to the position function.
vec4 VaryingTexCoord
The interpolated per-vertex texture coordinate. Automatically set to the value of VertexTexCoord in the vertex shader before the position function is called. Used as the third argument to the effect function. Writable in the vertex shader.
vec4 VaryingColor
The interpolated per-vertex color. Automatically set to the value of VertexColor in the vertex shader before the position function is called. Used as the first argument to the effect function. Writable in the vertex shader.

Vertex Shader built-in variables

vec4 VertexPosition
The pre-transformed position of the vertex. The third and fourth components of the vector are normally (0, 1).
vec4 VertexTexCoord
The texture coordinate of the vertex. The third and fourth components of the vector are normally (0, 1). Geometry objects allow for custom texture coordinates.
vec4 VertexColor
The global color set with love.graphics.setColor, or the color of the vertex if a Geometry with per-vertex colors is drawn.

See Also

Other Languages