Render State: Difference between revisions
No edit summary |
|||
| Line 3: | Line 3: | ||
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. | 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. | 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 or what shaders have been called before these functions are called. | |||
=== Scalars === | === Scalars === | ||
[[Get Altitude]] | [[Get Altitude]] | ||
Revision as of 05:25, 2 May 2011
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 how far a surface should be displaced at a particular location.
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 or what shaders have been called before these functions are called.
Scalars
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 (3-part alpha channel)
Get Final Colour - Surface final output colour
Get Final Opacity - Surface final opacity (1 - transparency)
Get Specular Colour - Surface specular component (may not be treated consistently between shaders)