TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

struct TextureTile in Tinman.Terrain.Rendering

Represents a texture tile in a texture atlas.

struct TextureTile  

Remarks

In order to get correct texture coordinates, the following steps must be performed:

  1. Provide per-vertex texture coordinates (e.g. by using HeightmapCoordinates).
  2. Call TileLookup to check if a tile texture is available for the given pyramid tile coordinates.
  3. Call TileSetup to obtain the texturing coefficient vectors Offset, U and V.
  4. Render geometry separately per cubemap face.
  5. Use the following formulae to transform cubemap texture coordinates X, Y and Z to tile texture coordinates S and T:
    S := ([X, Y, Z] * U + Offset.X) + Offset.Z
    T := ([X, Y, Z] * V + Offset.Y) + Offset.W
    The Z and W components of Offset hold the float delta of X resp. Y (see FloatDelta). On the CPU, tile texture coordinates can be computed by using one of the Compute methods.
  6. Clamp S and T to Bounds in order to avoid color bleeding at the tile edges:
    Bounds.X <= S <= Bounds.Y
    Bounds.Z <= T <= Bounds.W
    Clamping should be done on the GPU to avoid distortions between vertex positions and texture coordinates.
The formulae above are free of precision issues as long as the GPU is capable of handling at least 24 effective floating-point mantissa bits during vertex processing.

See also:

VertexFormat.HeightmapCoordinates

Public / Attributes

Bounds

Output texturing coefficient vector (see remarks).

public readonly field Bounds
type Vec4F

Offset

Output texturing coefficient vector (see remarks).

public readonly field Offset
type Vec4F

Texture

The texture to use or null if the texture for the given pyramid tile is not ready yet or does not exist.

public readonly field Texture
type ITexture2D

U

Output texturing coefficient vector (see remarks).

public readonly field U
type Vec3F

V

Output texturing coefficient vector (see remarks).

public readonly field V
type Vec3F

Public / Methods

Compute

Computes texture tile coordinates S and T.

[Pure]
public method Compute (Vec3D coords)
type Vec2F
params coords Cubemap coordinates, in the range [0..1].
returns The texture tile coordinates.

Computes texture tile coordinates S and T.

[Pure]
public method Compute (Vec3I coords, int32 n = MappingUtil.MaxSize)
type Vec2F
params coords Cubemap coordinates.
  n Maximum cubemap coordinate. Defaults to MaxSize.
returns The texture tile coordinates.

Computes texture tile coordinates S and T.

[Pure]
public method Compute (float64 x, float64 y, float64 z)
type Vec2F
params x Cubemap X-coordinate, in the range [0..1].
  y Cubemap Y-coordinate, in the range [0..1].
  z Cubemap Z-coordinate, in the range [0..1].
returns The texture tile coordinates.

Computes texture tile coordinates S and T.

[Pure]
public method Compute (int32 x, int32 y, int32 z, int32 n = MappingUtil.MaxSize)
type Vec2F
params x Cubemap X-coordinate.
  y Cubemap Y-coordinate.
  z Cubemap Z-coordinate.
  n Maximum cubemap coordinate. Defaults to MaxSize.
returns The texture tile coordinates.