IModelTexture

Description

[ShutdownSurvive]
interface Tinman.Engine.Models.IModelTexture

Base interface for classes that represent textures for 3D models.

IModelTexture objects act as resource handles and produce ITexture2D resource objects.

Public / Methods

Invert


public method Invert → (1)

channels in : int32

The channels to invert:

1 : red
2 : green
4 : blue
8 : alpha
returns → IModelTexture

The resulting model texture.

Inverts the given channels of this model texture.

Read​Elevation


public method ReadElevation → (1)

range in : PixelRange

The pixel range to use (see ISampleBuffer.ScanlineRange).

returns → ElevationBuffer

The elevation data.

Reads elevation data.

IOException

If an I/O error has occurred while reading the pixel data.

Read​Pixels


public method ReadPixels → ()

returns → ColorBuffer

The pixel data.

Reads pixel data.

IOException

If an I/O error has occurred while reading the pixel data.

Read​Texels


[OwnerReturn]
public method ReadTexels → ()

returns → TexelBuffer

The texture data.

Reads texture data.

IOException

If an I/O error has occurred while reading the texture data.

Swizzle


public method Swizzle → (4)

red in : int32

[-5..5]
Swizzle operand that outputs the red channel.

green in : int32

[-5..5]
Swizzle operand that outputs the green channel.

blue in : int32

[-5..5]
Swizzle operand that outputs the blue channel.

alpha in : int32

[-5..5]
Swizzle operand that outputs the alpha channel.

returns → IModelTexture

The resulting model texture.

Swizzles the color channels of this texture.

For each channel of the resulting texture, one of the following swizzle operands may be specified:

  • -5 : use constant minimum value

  • -4 : use inverse alpha channel of input

  • -3 : use inverse blue channel of input

  • -2 : use inverse green channel of input

  • -1 : use inverse red channel of input

  • 0 : use grayscale intensity of input

  • 1 : use red channel of input

  • 2 : use green channel of input

  • 3 : use blue channel of input

  • 4 : use alpha channel of input

  • 5 : use constant maximum value

Public / Attributes

Is​Srgb


[Constant]
public attribute IsSrgb → (get)

value : bool

The sRGB behaviour flag.

Returns the value of the ISrgb.Srgb property for the TexelBuffer data that is returned by the ReadTexels method

This sRGB behaviour flag only affects the encoding of texture data. The GPU will perform sRGB decompression automatically, so GPU shader code will always sample linear values. However, using the wrong sRGB behaviour may reduce visual quality, because encoding has a lower effective precision.

Preferred​Texture​Format


public attribute PreferredTextureFormat → (get)

value : TextureFormat

The preferred texture format or null.

The preferred format to use for this model texture.

Extensions

Normal​Map


public static method NormalMap → (1)

height opt : float64 = 0.01

The relative bump height (see remarks).

returns → IModelTexture

The resulting model texture.

Interprets this model texture as a bump map and computes a normal map from it.

Black pixels lie in the XY plane (see figure), white pixels are at the given height opt. The height is specified relative to the size of this texture (i.e. maximum of width and height), e.g. a value of 1 would turn the cuboid below into a cube.

     .............
    .:          .:
Z+ . :         . :
| .  +--------.--+-- X+
|.  /        .  /
.............  /
: /         : /
:/          :/
+-----------+
           /
          Y+