A MaterialKey defines the parameters that define the mapping from color values to material weights.
struct
|
MaterialKey
|
implements
|
IComparable<MaterialKey>
|
||
IEquatable<MaterialKey>
|
For each material ID, a MaterialKey is defined in the containing MaterialKeys object. For a given color, material weights are computed for each key and the weighted materials are then combined into a material token.
The
weight
w
for
a
material
key
is
computed
as
follows:
dst
is
computed
between
the
material
key
color
(see
Color)
and
the
input
color.
The
Distance_RGB_RGB
method
is
used
as
metric.
dst
is
divided
by
the
configured
distance
range
(see
Distance),
which
reduces
the
range
of
the
material
key.
dst
is
clamped
using
the
configured
clamp
amount
(see
Clamp):
dst
=
max(0,
Clamp
-
dst)
/
Clamp
.
This
cuts
off
small
material
weights
while
retaining
the
full
weight
range.
dst
is
scaled
by
the
configured
weight
(see
Weight,
yielding
the
final
material
weight.
This
affects
how
strong
the
material
will
be
realized
in
relation
to
the
other
material
keys.
The configurator object for this type.
public
static
property
|
Config
{
get
}
|
||
type
|
IConfigurator<MaterialKey>
|
||
value
|
|
The configurator object. |
The invalid (i.e. non-existent) material key.
public
static
readonly
field
|
Invalid
|
||
type
|
MaterialKey
|
See also:
IsInvalidThe relative clamp amount of this material.
public
readonly
field
|
Clamp
|
||
type
|
float64
|
Remarks:
A clamp amount less than one will cut off small material weights. A clamp amount greater than one will add small material weights.
The color key of the material.
public
readonly
field
|
Color
|
||
type
|
int64
|
The color distance range of this material.
public
readonly
field
|
Distance
|
||
type
|
float64
|
Remarks:
The material has full weight where the color distance is zero. The weight drops to zero when this distance value is reached.
The overall influence of this material key.
public
property
|
Influence
{
get
}
|
||
type
|
float64
|
||
value
|
|
The relative influence. |
Is this material key invalid?
public
property
|
IsInvalid
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
material
key
is
invalid,
false
if
it
is
valid. |
See also:
InvalidThe
material
ID
in
the
range
[0..255]
or
-1
if
this
material
key
is
invalid
(see
IsInvalid).
public
readonly
field
|
Material
|
||
type
|
int32
|
The relative weight of this material.
public
readonly
field
|
Weight
|
||
type
|
float64
|
Creates a new instance of MaterialKey.
public
constructor
|
MaterialKey
(int32 material,
int64 color,
float64 distance = 1,
float64 weight = 1,
float64 clamp = 1)
|
||
params
|
material
|
[-1..255]
|
The
material
ID
or
-1
for
an
invalid
material
key.
|
color
|
The color key of the material. | ||
distance
|
[>=0]
|
The
color
distance
range
of
this
material.
Defaults
to
1 .
|
|
weight
|
[>=0]
|
The
relative
weight
of
this
material.
Defaults
to
1 .
|
|
clamp
|
[>=0]
|
The
relative
clamp
amount
of
this
material.
Defaults
to
1 .
|
public
method
|
CompareTo
(MaterialKey other)
|
||
type
|
int32
|
||
params
|
other
|
Computes the material weight for the given color.
public
method
|
ComputeWeight
(int64 color)
|
||
type
|
int32
|
||
params
|
color
|
The color value. | |
returns
|
|
The
material
weight,
as
a
14.15
fixed
point
number. |
public
method
|
Equals
(MaterialKey other)
|
||
type
|
bool
|
||
params
|
other
|