RenderingUtil

Description

static class Tinman.Terrain.Rendering.RenderingUtil

Provides some helpful methods for rendering.

Public / Methods

Memory​Consumption​Of​Texture


[Pure]
public static method MemoryConsumptionOfTexture → (6)

width in : int32

[>0]
The texture width, in texels.

height in : int32

[>0]
The texture height, in texels.

bitsPerTexel in : int32

[>0]
The bits per texel.

blockSize opt : int32 = 1

[>=1]
The texel block size.

mipmaps opt : int32 = 0

[>=0]
The mipmap levels. If 0, the mipmap level count will be inferred from width in and height in.

slices opt : int32 = 1

[>=1]
The number of texture array slices.

returns → int32

The texture memory consumption.

Computes the memory consumption of a texture.

Mipmap​For​Cone


[Pure]
public static method MipmapForCone → (2)

angle in : float64

[>=0]
The cone opening angle, in degrees.

size in : int32

[pow2]
The cubemap texture size.

returns → float64

The zero-based mipmap level index.

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

Mipmap​Levels​Check


public static method MipmapLevelsCheck → (3)

width in : int32

[>0]
Width of texture image.

height in : int32

[>0]
Height of texture image.

mipmaps in : int32

[>=0]
The number of mipmap levels (including the full-resolution level). If 0 the number of levels will be inferred from width in and height in (see MipmapLevelsRect).

returns → int32

The number of mipmap levels.

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

Mipmap​Levels​Rect


public static method MipmapLevelsRect → (2)

width in : int32

[>0]
Width of texture image.

height in : int32

[>0]
Height of texture image.

returns → int32

The number of mipmap levels.

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

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

Mipmap​Levels​Square


public static method MipmapLevelsSquare → (2)

textureSize in : int32

[>0]
The texture size.

smallestMipmapSize opt : int32 = 1

[pow2]
The smallest mipmap level size.

returns → int32

The number of mipmap levels.

Computes the number of mipmap levels.

Primitive​Count


[Pure]
public static method PrimitiveCount → (2)

primitive in : Primitive

The primitive type.

vertexCount in : int32

[>=0]
The vertex count.

returns → int32

The number of renderable primitives.

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

Resource​Binding


public static method ResourceBinding → (2)

previous in : IResource

The resource object that has been bound previously.

current in : IResource

The resource object that is now bound.

Helper method that calls IResource.Binding2 for the given resources.

Validate​Texture​Size


public static method ValidateTextureSize → (5)

width in : int32

The texture width.

height in : int32

The texture height.

maximum in : int32

Maximum texture size.

mustBeSquare in : bool

Width and height must be equal.

mustBePow2 in : bool

Width and height must be a power of two.

returns → Vec2I

The adjusted texture size.

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

Weight​To​Alpha

2 overloads


[Pure]
public static method WeightToAlpha1 → (3)

w1 in : float64

The weight of the second value, in the range [0..1].

w2 in : float64

The weight of the third value, in the range [0..1].

w3 in : float64

The weight of the fourth value, in the range [0..1].

returns → Vec3D

The alpha blending factors for the four consecutive passes that produce the weighted sum, where each pass is defined as:

target_1 = source_1
target_2 = target_1 * (1 - X) + source_2 * X
target_3 = target_2 * (1 - Y) + source_3 * Y
target_4 = target_3 * (1 - Z) + source_4 * Z

Computes alpha blending factors for computing a weighted sum of four values.

The weight of the first value w0 is defined as 1-w1-w2-w3.


[Pure]
public static method WeightToAlpha2 → (4)

w0 in : float64

The weight of the first value, in the range [0..1].

w1 in : float64

The weight of the second value, in the range [0..1].

w2 in : float64

The weight of the third value, in the range [0..1].

w3 in : float64

The weight of the fourth value, in the range [0..1].

returns → Vec4D

The alpha blending factors for the four consecutive passes that produce the weighted sum on top of the existing opaque content, where each pass is defined as:

target_0 = ...
target_1 = target_0 * (1 - X) + source_1 * X
target_2 = target_1 * (1 - Y) + source_2 * Y
target_3 = target_2 * (1 - Z) + source_3 * Z
target_4 = target_3 * (1 - W) + source_4 * W

Computes alpha blending factors for computing a weighted sum of four values.