[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.11.1 Shaders

A shader is a piece of code that is typically run on the 3D card. It is this code that is responsible for actually rendering the surface attributes using the material data. A material and a shader work closely together.

#### Shader Variables

Shaders need to use shader variables to be able to access the resources they need to do what they have to do. This includes things like the texture, the ambient color, the light transformation, and so on. Here is a list of all currently supported shader variables and their source in Crystal Space. In addition to the variables listed here it is often possible to add user variables that you can then use in your own shaders.

Shader variables from OpenGL renderer:

- ``standardtex fog'`, type texture, texture class 'lookup'
- ``standardtex normalization map'`, type texture (cubemap), texture class 'lookup'
- ``standardtex white'`, type texture, 1x1 white texture
- ``vertices'`, type render buffer
- ``texture coordinates'`, type render buffer
- ``colors'`, type render buffer
- ``indices'`, type render buffer
- ``world2camera transform'`, type transform
- ``tex diffuse'`, type texture

Shader variables from null3d renderer:

- ``standardtex fog'`, type texture, texture class 'lookup'
- ``standardtex normalization map'`, type texture (cubemap), texture class 'lookup'
- ``standardtex attenuation'`, type texture

Shader variables from software renderer:

- ``indices'`, type render buffer
- ``vertices'`, type render buffer
- ``texture coordinates'`, type render buffer
- ``colors'`, type render buffer
- ``world2camera transform'`, type transform

Shader variables from shader manager:

- ``standard time'`, type float (current ticks in seconds)

Shader variables from materials:

- ``mat diffuse'`, type float
- ``mat ambient'`, type float
- ``mat reflection'`, type float
- ``mat flatcolor'`, type color, flat color of the material
- ``tex diffuse'`, default diffuse texture
- various textures as defined in the material section

Shader variables from lightiterator renderstep:

- ``light 0 position'`, type vector4
- ``light 0 position world'`, type vector4
- ``light 0 transform'`, type transform
- ``light 0 transform world'`, type transform
- ``light 0 diffuse'`, type vector4
- ``light 0 specular'`, type vector4
- ``light 0 attenuation'`, type vector4
- ``light 0 attenuationtex'`, type texture
- ``light 0 inner falloff'`, type float
- ``light 0 outer falloff'`, type float

Shader variables from brute terrain mesh:

- ``texture lod distance'`, type vector3
- ``splat alpha map'`, type texture

Shader variables from thing mesh:

- ``tex lightmap'`, type texture

Shader variables from particles mesh:

- ``point radius'`, type float
- ``point scale'`, type float

Shader variables for procedural textures:

- ``position'`, type vector2

Shader variables from portals:

- ``fogplane'`, type vector4
- ``fog density'`, type float
- ``fog color'`, type vector3

Shader variables from fat renderloop:

- ``fogplane'`, type vector4
- ``fog density'`, type float
- ``fog color'`, type vector3
- ``object2world transform'`, type transform

Shader variables from generic renderloop:

- ``object2world transform'`, type transform
- ``light 0 type'`, type integer
- ``light ambient'`, type color
- ``fogplane'`, type vector4
- ``fog density'`, type float
- ``fog color'`, type vector3
- ``fog start'`, type float
- ``fog end'`, type float
- ``fog mode'`, type int

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.