Terrain_Util

Description

sealed class Tinman.Engine.Shaders.Terrain.Terrain_Util

Derived from

GpuCode abstract

Full source code is included in the Tinman 3D SDK download.

Helper methods for common terrain functionality.

Public / Methods

Displacement


[Pure]
public static method Displacement → (3)

displacement in : DisplacementFixed

The per-vertex displacement data.

materialWeights in : float4

The material weights.

computeDelta in : bool

Compute error delta values?

returns → DisplacementVarying

The per-pixel displacement data.

Computes per-pixel displacement data.

Displacement​Fade


[Pure]
public static method DisplacementFade → (2)

displacement in : float32

The displacement value, in terrain-space.

distance in : float32

The distance from the vertex to the camera position.

returns → float32

The faded displacement value.

Fades the given displacement value to zero when reaching the end of the layer blend range.

This will avoid Z-fighting artefacts with adjacent, non-displacement terrain layers.

Highlight​Color


[If("SHADER_PS")] [Pure]
public static method HighlightColor → (1)

color in : float4

The input color.

returns → float4

The highlighted output color.

Applies the terrain highlight.

Layer​Blend​Clip


[If("SHADER_PS")] [Pure]
public static method LayerBlendClip → (1)

distance in : float32

Distance from fragment to camera.

returns → float32

The blend factor.

Computes the distance-based layer blend factor.

The current fragment is discarded if the resulting blend factory is less than zero.

Material​Color


[If("SHADER_PS")] [Pure]
public static method MaterialColor → (9)

albedo in : float3

The albedo color (linear sRGB).

occlusion in : float32

Scale factor for ambient occlusion, in the range [0..1].

reflectivity in : float3

The material reflectivity (linear sRGB).

gloss in : float32

The material glossiness.

emissive in : float3

The emissive color (linear sRGB).

eye in : float3

The unit-length eye vector.

normal in : float3

The unit-length normal vector.

distance in : float32

The camera distance.

shadow in : float32

The shadow factor: 0 = full shadow, 1 = no shadow.

returns → float3

The resulting color.

Computes the resulting light for the given terrain material properties.

Material​Coords


[Pure]
public static method MaterialCoords → (6)

in : int32

The material index.

position in : float3

The vertex position.

normal in : float3

The unit-length vertex normal vector.

out : float2

Texture coordinates for the YZ-plane.

out : float2

Texture coordinates for the XZ-plane.

out : float2

Texture coordinates for the XY-plane.

Constructs texture coordinates for tri-planar texture mapping.

The material texture coordinate scale factors of g_materialSettings are applied.

Material​Rotation


[Pure]
public static method MaterialRotation → ()

returns → float2x2

The matrix.

Returns the rotation matrix for material coordinates.