Shader Specification

Leadwerks shaders have specific rules[1] that apply to them. These rules are loosely documented through forum posts, so this page serves the purpose of bringing all of that information together.

Uniforms

int

cameradrawmode
draw mode of the camera
cameraprojectionmode
projection mode of the camera

float

currenttime
the current time in seconds
isbackbuffer
evaluates to true if currently backbuffer
tessstrength
the tessellation strength of the world
camerazoom
the zoom level of the camera

vec2

buffersize
the size of the buffer in pixels. x is the number of pixels horizontally, and y is the number of pixels vertically
camerarange
the range of the camera. x is the near clip plane distance, and y is the far clip plane distance.

vec3

cameraposition
position of the camera

vec4

drawcolor
graphics drivers current color
ambientlight
the color of the ambient light
lighting_ambient
ambient light (not sure what this does)

mat3

cameranormalmatrix
the camera normal matrix
camerainversenormalmatrix
the inverse of the camera normal matrix

mat4

drawmatrix
matrix used for drawing post-processing effects primarily
projectioncameramatrix
active camera projection matrix
cameramatrix
matrix of the active camera
prevprojectioncameramatrix
the previous camera project matrix
camerainversematrix
the inverse of the camera matrix

G-Buffer

The G-buffer is the buffer that stores various fragments in order to later (deferred) apply lighting to those fragments. This is a feature of a deferred renderer, so all fragment shaders should write to various buffers (fragDataN).

fragData0

Diffuse buffer

fragData1

Normal buffer. The alpha channel stores material flags.

fragData2

Specular buffer

Post Processing Textures

Most post processing effects use one or more textures.

texture0

Depth texture

texture1

Diffuse texture

texture2

Normal texture

References

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License