Render State

From Terragen Documentation from Planetside Software
Revision as of 05:01, 2 May 2011 by Matt (talk | contribs) (Created page with 'The Render State is a collection of variables and functions that shaders have access to during rendering. It is the main point of communication between shaders and the rendering ...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Render State is a collection of variables and functions that shaders have access to 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.

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]

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.