@c -*-texinfo-*-
@node Shaders, Alpha Textures, Materials, Materials
@subsection Shaders
@cindex Shader
@cindex @code{iShader}

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.

@subsubheading Shader Variables
@cindex 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:

@itemize @bullet
@item @samp{standardtex fog}, type texture, texture class 'lookup'
@item @samp{standardtex normalization map}, type texture (cubemap), texture class 'lookup'
@item @samp{standardtex white}, type texture, 1x1 white texture
@item @samp{vertices}, type render buffer
@item @samp{texture coordinates}, type render buffer
@item @samp{colors}, type render buffer
@item @samp{indices}, type render buffer
@item @samp{world2camera transform}, type transform
@item @samp{tex diffuse}, type texture
@end itemize

Shader variables from null3d renderer:

@itemize @bullet
@item @samp{standardtex fog}, type texture, texture class 'lookup'
@item @samp{standardtex normalization map}, type texture (cubemap), texture class 'lookup'
@item @samp{standardtex attenuation}, type texture
@end itemize

Shader variables from software renderer:

@itemize @bullet
@item @samp{indices}, type render buffer
@item @samp{vertices}, type render buffer
@item @samp{texture coordinates}, type render buffer
@item @samp{colors}, type render buffer
@item @samp{world2camera transform}, type transform
@end itemize

Shader variables from shader manager:

@itemize @bullet
@item @samp{standard time}, type float (current ticks in seconds)
@end itemize

Shader variables from materials:

@itemize @bullet
@item @samp{mat diffuse}, type float
@item @samp{mat ambient}, type float
@item @samp{mat reflection}, type float
@item @samp{mat flatcolor}, type color, flat color of the material
@item @samp{tex diffuse}, default diffuse texture
@item various textures as defined in the material section
@end itemize

Shader variables from lightiterator renderstep:

@itemize @bullet
@item @samp{light 0 position}, type vector4
@item @samp{light 0 position world}, type vector4
@item @samp{light 0 transform}, type transform
@item @samp{light 0 transform world}, type transform
@item @samp{light 0 diffuse}, type vector4
@item @samp{light 0 specular}, type vector4
@item @samp{light 0 attenuation}, type vector4
@item @samp{light 0 attenuationtex}, type texture
@item @samp{light 0 inner falloff}, type float
@item @samp{light 0 outer falloff}, type float
@end itemize

Shader variables from brute terrain mesh:

@itemize @bullet
@item @samp{texture lod distance}, type vector3
@item @samp{splat alpha map}, type texture
@end itemize

Shader variables from thing mesh:

@itemize @bullet
@item @samp{tex lightmap}, type texture
@end itemize

Shader variables from particles mesh:

@itemize @bullet
@item @samp{point radius}, type float
@item @samp{point scale}, type float
@end itemize

Shader variables for procedural textures:

@itemize @bullet
@item @samp{position}, type vector2
@end itemize

Shader variables from portals:

@itemize @bullet
@item @samp{fogplane}, type vector4
@item @samp{fog density}, type float
@item @samp{fog color}, type vector3
@end itemize

Shader variables from fat renderloop:

@itemize @bullet
@item @samp{fogplane}, type vector4
@item @samp{fog density}, type float
@item @samp{fog color}, type vector3
@item @samp{object2world transform}, type transform
@end itemize

Shader variables from generic renderloop:

@itemize @bullet
@item @samp{object2world transform}, type transform
@item @samp{light 0 type}, type integer
@item @samp{light ambient}, type color
@item @samp{fogplane}, type vector4
@item @samp{fog density}, type float
@item @samp{fog color}, type vector3
@item @samp{fog start}, type float
@item @samp{fog end}, type float
@item @samp{fog mode}, type int
@end itemize

