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

class RenderingUtil in Tinman.Terrain.Rendering

Provides some helpful methods for rendering.

static class RenderingUtil  

Public / Methods

MemoryConsumptionOfTexture

Computes the memory consumption of a texture.

[Pure]
public static method MemoryConsumptionOfTexture (int32 width, int32 height, int32 bitsPerTexel, int32 blockSize = 1, int32 mipmaps = 0)
type int32
params width [>0] The texture width, in texels.
  height [>0] The texture height, in texels.
  bitsPerTexel [>0] The bits per texel.
  blockSize [>=1] The texel block size. Defaults to 1.
  mipmaps [>=0] The mipmap levels. If 0, the mipmap level count will be inferred from width and height. Defaults to 0.
returns [>=0] The texture memory consumption.

MipmapForCone

Computes the mipmap level of a cubemap texture where the texel cones correspond to the given cone opening angle.

[Pure]
public static method MipmapForCone (float64 angle, int32 size)
type float64
params angle [>=0] The cone opening angle, in degrees.
  size [pow2] The cubemap texture size.
returns [>=0] The zero-based mipmap level index.

MipmapLevelsCheck

Checks the given mipmap level count and fixes it if necessary.

public static method MipmapLevelsCheck (int32 width, int32 height, int32 mipmaps)
type int32
params width [>0] Width of texture image.
  height [>0] Height of texture image.
  mipmaps [>=0] The number of mipmap levels (including the full-resolution level). If 0 the number of levels will be inferred from width and height (see MipmapLevelsRect). Defaults to 1.
returns [>=1] The number of mipmap levels.

MipmapLevelsRect

Returns the number of mipmap levels of the given texture image.

public static method MipmapLevelsRect (int32 width, int32 height)
type int32
params width [>0] Width of texture image.
  height [>0] Height of texture image.
returns [>=1] The number of mipmap levels.

Remarks:

This method uses the floor convention as the dimension reduction rule for each successively smaller mipmap level (just like Direct3D and OpenGL do): the mipmap width resp. height is divided by two and round down to the next integer.
https://www.opengl.org/registry/specs/ARB/texture_non_power_of_two.txt

MipmapLevelsSquare

Computes the number of mipmap levels.

public static method MipmapLevelsSquare (int32 textureSize, int32 smallestMipmapSize = 1)
type int32
params textureSize [pow2] The texture size.
  smallestMipmapSize [pow2] The smallest mipmap level size. Defaults to 1.
returns [>=1] The number of mipmap levels.

PrimitiveCount

Returns the number of renderable primitives for the given primitive type and vertex count.

[Pure]
public static method PrimitiveCount (Primitive primitive, int32 vertexCount)
type int32
params primitive The primitive type.
  vertexCount [>=0] The vertex count.
returns [>=0] The number of renderable primitives.

ValidateTextureSize

Adjust the given texture size to make it valid in terms of the given texture size restrictions.

public static method ValidateTextureSize (int32 width, int32 height, int32 maximum, bool mustBeSquare, bool mustBePow2)
type Vec2I
params width The texture width.
  height The texture height.
  maximum Maximum texture size.
  mustBeSquare Width and height must be equal.
  mustBePow2 Width and height must be a power of two.
returns The adjusted texture size.