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

4.12.1.2 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 more. Each shader uses a number of variables usually provided by the material, while also a number of variables are automatically supplied by the engine and other components. This section commonly used variables of both kinds.

Variables from Materials

These variables are usually provided by materials. It is also possible to add custom variables that you can then use in your own materials with your own shaders. Variable names can be arbitrary, however, if you want to add a parameter to allow customization of a shader, you should first look into this list whether there might be a name that is already used for the purpose you desire. If you use custom names, it's a good idea to try to somewhat stick to the same conventions as used here.

`tex diffuse'

diffuse texture

`tex normal'

normal map texture

`tex height'

height map texture for parallax shading

Variables from the Crystal Space Components

These variables are defined by various components and are mostly useful when writing custom shaders.

Utility textures

`standardtex normalization map'

Normalization cube map.

`standardtex white'

1x1 white texture. Mostly useful as a "dummy" texture.

Buffers

`vertices'

Render buffer with mesh vertices.

`texture coordinates'

Render buffer with texture coordinates.

`colors'

Render buffer with per-vertex colors.

Transforms

`world2camera transform'
`object2world transform'

Lighting

`N' denotes the light number. The first light is light number 0. The upper limit for the value of `N' depends on the shader as well as the render loop.

`light ambient'

Ambient lighting color.

`light N position'

Light position in camera space.

`light N position world'

Light position in world space.

`light N transform'

Light transformation in camera space. Mostly relevant as some lights might be rotated.

`light N transform world'

Light transformation in world space.

`light N diffuse'

Light diffuse color.

`light N specular'

Light specular color.

`light N attenuation'

Light attenuation coefficients.

`light N attenuationtex'

Light attenuation texture.

`light N type'

Light type, one of the csLightType enumerants.

`light N inner falloff'

Inner falloff for spotlights as the cosine of the angle.

`light N outer falloff'

Outer falloff for spotlights as the cosine of the angle.

Terrain related

`texture lod distance'
`splat alpha map'

Miscelleanous

`mat flatcolor'

Flat color of the material. To be used if no diffuse texture was specified.

`standard time'

Current ticks in seconds. Useful for animations.

`tex lightmap'

Lightmap texture. Present if a mesh uses lightmap lighting.

`texture coordinates lightmap'

Buffer with lightmap texture coordinates. Present if a mesh uses lightmap lighting.

`point radius'

Radius when point sprites are rendered.

`point scale'

Scale when point sprites are rendered.

Fog

Crystal Space provides some shader "snippets" to deal with fog, it's recommended to use these to add fog support to some shader.

`fogplane'
`fog density'
`fog color'
`fog start'
`fog end'
`fog mode'
`standardtex fog'

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

This document was generated using texi2html 1.76.