Class PaletteFaceColorResolver
An IFaceColorResolver that maps shape faces onto the entries of a ColorPalette according to a FaceColoringMode. Shape builders call Resolve(int, int, Vector3) once per face when emitting their vertex color channel, so a single mesh can carry a distinct flat color per face.
Implements
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
public sealed class PaletteFaceColorResolver : IFaceColorResolver
Remarks
The resolver is immutable and allocation-free per call, so a single instance can be reused across rebuilds. Construct it directly from a ColorPalette (for tests or code that already holds a palette) or let ScyllaShapeBase3D build it from a registry palette name.
GradientByY samples the palette by the face center's
Y position normalized into the [minY, maxY] range supplied at construction.
The other modes ignore the face center.
Constructors
PaletteFaceColorResolver(ColorPalette, FaceColoringMode, int, int, float, float)
Initializes a resolver over palette using the supplied
mode.
Declaration
public PaletteFaceColorResolver(ColorPalette palette, FaceColoringMode mode, int seed = 0, int uniformIndex = 0, float minY = -0.5, float maxY = 0.5)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorPalette | palette | The palette whose entries are assigned to faces. Must be non-null and non-empty. |
| FaceColoringMode | mode | How faces map onto palette entries. None behaves like Uniform at index 0. |
| int | seed | Seed for Hash. Ignored by other modes. |
| int | uniformIndex | Palette index used by Uniform. Clamped to the palette range. Ignored by other modes. |
| float | minY | Lower Y bound for GradientByY normalization. Ignored by other modes. |
| float | maxY | Upper Y bound for GradientByY normalization. Ignored by other modes. |
Methods
Resolve(int, int, Vector3)
Returns the color to assign to all vertices of the face identified by
faceIndex.
Declaration
public Color32 Resolve(int faceIndex, int faceCount, Vector3 faceCenter)
Parameters
| Type | Name | Description |
|---|---|---|
| int | faceIndex | Zero-based face index within the shape's face inventory. The valid range is
|
| int | faceCount | Total number of faces the shape will emit, useful for resolvers that need to know the upper bound (e.g. gradient sampling by index ratio). |
| Vector3 | faceCenter | Local-space center of the face, useful for resolvers that derive color from spatial position (e.g. gradient sampled by Y, or 3D noise lookup). |
Returns
| Type | Description |
|---|---|
| Color32 | The color to assign to the face's vertices. |