Render State

From Planetside Software Wiki
Jump to: navigation, search

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 shaderA 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. is asked to do something, e.g displaceLiterally, 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 point or tell the renderer what colour a pixelA 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. should be, the shaderA 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. gets information about the point to shade from the Render State. In turn the shaderA 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. 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 pixelA 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. 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. For a planet this basically means the altitude of the current point being rendered, including displacementLiterally, 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..

Get Altitude in Texture - Signed distance from Position in Geometry to Position in Texture along the direction of Normal in Geometry. For a planet this basically means the altitude of the current texture coordinates.

Get Frame Number

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 displacementLiterally, 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.

Get Position in Geometry - Position of the point in world space prior to displacementLiterally, 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.

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 displacementLiterally, 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.

Get Normal in Texture - Surface normal set by object, Compute Terrain or Compute Normal

Colours

Some, or 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