Difference between revisions of "Render State"

From Terragen Documentation from Planetside Software
Jump to: navigation, search
(Colours)
Line 36: Line 36:
  
 
=== Colours ===
 
=== 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 Diffuse Colour]] - Surface diffuse coefficient, before lighting

Revision as of 05:23, 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. The following nodes provide read-only access to some of the variables in the Render State:


Scalars[edit]

Get Altitude

Get Altitude in Texture

Get Frame Number

Positions (vectors)[edit]

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)[edit]

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[edit]

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)

A shader is a program or set of instructions used in 3D computer graphics to determine the final surface properties of an object or image. This can include arbitrarily complex descriptions of light absorption and diffusion, texture mapping, reflection and refraction, shadowing, surface displacement and post-processing effects. In Terragen 2 shaders are used to construct and modify almost every element of a scene.

Literally, to change the position of something. In graphics terminology to displace a surface is to modify its geometric (3D) structure using reference data of some kind. For example, a grayscale image might be taken as input, with black areas indicating no displacement of the surface, and white indicating maximum displacement. In Terragen 2 displacement is used to create all terrain by taking heightfield or procedural data as input and using it to displace the normally flat sphere of the planet.

A single element of an image which describes values for color and/or intensity, depending on the color system which the image uses. Groups of ordered pixels together form a raster image.

Literally, to change the position of something. In graphics terminology to displace a surface is to modify its geometric (3D) structure using reference data of some kind. For example, a grayscale image might be taken as input, with black areas indicating no displacement of the surface, and white indicating maximum displacement. In Terragen 2 displacement is used to create all terrain by taking heightfield or procedural data as input and using it to displace the normally flat sphere of the planet.