Struct TextureTransform
Represents settings for converting between textures and tensors.
Create an instance of TextureTransform
using the constructor, then use the TextureTransform
object as a parameter in TextureConverter
methods.
For example: TextureTransform settings = new TextureTransform().SetDimensions(256, 256, 4).SetTensorLayout(TensorLayout.NHWC);
Inherited Members
Namespace: Unity.Sentis
Syntax
public struct TextureTransform
Methods
SetBroadcastChannels(Boolean)
Sets the default behaviour when the output texture has more channels than the input tensor.
When broadcastChannels
is true
, Sentis broadcasts the tensor values to additional channels in the render texture. For example, a tensor with a single channel R maps to (R, R, R, R) if the number of channels is 4.
When broadcastChannels
is false
, Sentis applies a (0, 0, 0, 1) color mask to additional channels in the render texture. For example, a tensor with a single channel R becomes (R, 0, 0, 1) if the number of channels is 4.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetBroadcastChannels(bool broadcastChannels)
Parameters
Type | Name | Description |
---|---|---|
Boolean | broadcastChannels |
Returns
Type | Description |
---|---|
TextureTransform |
SetChannelColorMask(Boolean, Boolean, Boolean, Boolean, Color)
Sets which channels in the output texture ignore input tensor values and write a specific color
instead.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetChannelColorMask(bool maskR, bool maskG, bool maskB, bool maskA, Color color)
Parameters
Type | Name | Description |
---|---|---|
Boolean | maskR | |
Boolean | maskG | |
Boolean | maskB | |
Boolean | maskA | |
Color | color |
Returns
Type | Description |
---|---|
TextureTransform |
SetChannelColorMask(Channel, Boolean, Single)
Sets a specific texture channel, for example Channel.R
, to a specific color
. The channel ignores input tensor values.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetChannelColorMask(Channel c, bool mask, float color)
Parameters
Type | Name | Description |
---|---|---|
Channel | c | |
Boolean | mask | When the value is |
Single | color |
Returns
Type | Description |
---|---|
TextureTransform |
SetChannelSwizzle(Int32, Int32, Int32, Int32)
Sets which channels in the tensor map to which RGBA channels in the texture, using four channel position values.
A color mask for tensor to texture conversions might override this setting.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetChannelSwizzle(int channelSwizzleR = 0, int channelSwizzleG = 1, int channelSwizzleB = 2, int channelSwizzleA = 3)
Parameters
Type | Name | Description |
---|---|---|
Int32 | channelSwizzleR | |
Int32 | channelSwizzleG | |
Int32 | channelSwizzleB | |
Int32 | channelSwizzleA |
Returns
Type | Description |
---|---|
TextureTransform |
SetChannelSwizzle(Channel, Int32)
Sets a specific texture channel, for example Channel.R
, to a specific position in the tensor.
A color mask for tensor to texture conversions might override this setting.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetChannelSwizzle(Channel c, int swizzle)
Parameters
Type | Name | Description |
---|---|---|
Channel | c | |
Int32 | swizzle |
Returns
Type | Description |
---|---|
TextureTransform |
SetChannelSwizzle(ChannelSwizzle)
Sets which channels in the tensor map to which RGBA channels in the texture, using a ChannelSwizzle
enum value.
A color mask for tensor to texture conversions might override this setting.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetChannelSwizzle(ChannelSwizzle channelSwizzle)
Parameters
Type | Name | Description |
---|---|---|
ChannelSwizzle | channelSwizzle |
Returns
Type | Description |
---|---|
TextureTransform |
SetCoordOrigin(CoordOrigin)
Sets the position of the origin (0, 0) in the tensor.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetCoordOrigin(CoordOrigin coordOrigin)
Parameters
Type | Name | Description |
---|---|---|
CoordOrigin | coordOrigin |
Returns
Type | Description |
---|---|
TextureTransform |
SetDimensions(Int32, Int32, Int32)
Sets the dimensions of the output texture or tensor. The default value is -1, which means Sentis infers the dimensions from the input texture or tensor.
If the width and height of the input don't match the width and height of the output, Sentis applies linear resampling.
If you use SetDimensions
in a blit to an existing texture, Sentis ignores width
, height
, and channels
.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetDimensions(int width = -1, int height = -1, int channels = -1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | |
Int32 | height | |
Int32 | channels |
Returns
Type | Description |
---|---|
TextureTransform |
SetTensorLayout(Int32, Int32, Int32, Int32)
Sets the layout of the input tensor with four int values.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetTensorLayout(int tensorLayoutAxisN, int tensorLayoutAxisC, int tensorLayoutAxisH, int tensorLayoutAxisW)
Parameters
Type | Name | Description |
---|---|---|
Int32 | tensorLayoutAxisN | |
Int32 | tensorLayoutAxisC | |
Int32 | tensorLayoutAxisH | |
Int32 | tensorLayoutAxisW |
Returns
Type | Description |
---|---|
TextureTransform |
SetTensorLayout(TensorLayout)
Sets the layout of the input tensor with a TensorLayout
object, for example TensorLayout.NHWC
. The default is TensorLayout.NCHW
.
The method returns a TextureTransform
that you can use to chain other methods.
Declaration
public TextureTransform SetTensorLayout(TensorLayout tensorLayout)
Parameters
Type | Name | Description |
---|---|---|
TensorLayout | tensorLayout |
Returns
Type | Description |
---|---|
TextureTransform |