Render State: Difference between revisions
| Line 13: | Line 13: | ||
=== Scalars === | === Scalars === | ||
[[Get Altitude]] | [[Get Altitude]] - Signed distance from Position in Geometry to Position along the direction of Normal in Geometry | ||
[[Get Altitude in Texture]] | [[Get Altitude in Texture]] | ||
Revision as of 08:12, 2 May 2011
Overview
The Render State is a collection of variables and functions that shaders access and modify during rendering. It is the main point of communication between shaders and the rendering of an image. Whenever a shader is asked to do something, e.g displace a point or tell the renderer what colour a pixel should be, the shader gets information about the point to shade from the Render State. In turn the shader sends information back to the renderer by modifying values in the Render State, and this is how the renderer knows what colour to draw or what shape a surface should be. This is usually done on a point-by-point basis. Roughly speaking, the renderer works on a single pixel or a single micro-polygon at a time, and asks all the shaders to modify that point.
Some shaders modify the state so that they can change the behaviour of other shaders which are called later. This is how the Warp Shader can change the shape of other shaders connected to its "Shader" branch, for example.
Shaders do all this without exposing the details to the user. However, many of the variables in the Render State can be accessed using "Get" function nodes, allowing you to do things that aren't possible with the built-in shaders alone.
"Get" Functions
The following nodes provide read-only access to some of the variables in the Render State. The values they return may depend on rendering context, and may depend on which shaders have been called before these functions are called.
Scalars
Get Altitude - Signed distance from Position in Geometry to Position along the direction of Normal in Geometry
Positions (vectors)
Get Camera Position - Position of the main camera in world space, independent of current shading context
Get Position - Position of the point in world space, with displacement
Get Position in Geometry - Position of the point in world space prior to displacement
Get Position in Texture - Texture coordinates set by object, often modified by other shaders e.g. Compute Terrain, Tex Coords From XYZ, Transform Shader, Warp Shader
Get Ray Origin - Position of viewer or origin of the current ray in world space
Normals (vectors)
Get Normal - Surface normal including most recent modification by shaders or renderer
Get Normal in Geometry - Surface normal prior to displacement
Get Normal in Texture - Surface normal set by object, Compute Terrain or Compute Normal
Colours
Some, of all, of the following colour variables may have been set with useful information, depending on what shaders were called prior to executing them.
Get Diffuse Colour - Surface diffuse coefficient, before lighting
Get Emitted Colour - Surface emission (luminous) component
Get Final Alpha - Surface final output alpha
Get Final Colour - Surface final output colour
Get Final Opacity - Surface final opacity (1 - transparency)
Get Specular Colour - Surface specular component