public readonly record struct MeshInstanceOne entity's copy of a shape: where it is, and what it looks like.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A hundred and ninety-two bytes per entity per frame, and that number is the whole point. The path this replaces cost one MeshVertex per vertex per frame — forty bytes times a shape's vertex count, times every entity, with a cube's four hundred bytes and a sphere's twenty-odd kilobytes rebuilt whether or not anything moved. What crosses the bus now is linear in entities.
⚠ and are the material, and they are per instance because a material is per entity. Two entities sharing a shape and differing only in what they are made of stay one draw, which is what would have been lost by putting them anywhere else — a uniform block would be one material per draw, and a descriptor set would be one per material, which is the compositor's arrangement and needs a compositor. Thirty-two more bytes an entity buys a block-out that reads as brick and metal rather than as grey and grey.
⚠ The normal matrix is stored rather than derived, and it is per entity rather than per vertex. A cube scaled 2 1 1 transformed by its own matrix comes out with normals that are no longer perpendicular to their faces, and the shading then slides across the object as it is scaled — which reads as the light moving. The inverse is one matrix inverse per entity here; asking the vertex stage for it would be one per vertex, and the shader language has no inverse to ask with.
The fourth row of is never read — a direction has no translation — and is kept because a Matrix4x4 is what Transpose hands back. Sixteen bytes to avoid a hand-packed three-row layout that only the shader and this struct would agree about.
Fields and properties (6)
public Matrix4x4 TransformWhere the entity is, as WorldTransform holds it.
public Matrix4x4 NormalsThe matrix normals go through, which is 's inverse transpose. See Of, which is the only reason a caller would build one by hand.
public Color4 ColourWhat colour the surface is, linear and straight-alpha.
public Vector4 StyleFour independent decisions about how this instance is drawn, described by the shader that reads them: an outline width in pixels, an outline depth bias in pixels, whether to light it flat, and whether to take its colour from the world normal instead of from .
public Vector4 SurfaceHow the light behaves on it: metalness in x, perceptual roughness in y. The remaining two lanes are reserved — see DielectricF0 for what goes in them when something authors it.
public Color4 EmissiveWhat it emits on its own, linear, with the material's intensity already folded into the components. Alpha is unused. Black for a surface that emits nothing, which is nearly all of them.
Methods (4)
public MeshInstance(Matrix4x4 Transform, Matrix4x4 Normals, Color4 Colour, Vector4 Style, Vector4 Surface, Color4 Emissive)One entity's copy of a shape: where it is, and what it looks like.
public static MeshInstance Of(in Matrix4x4 transform, Color4 colour, Vector4 style = default(Vector4), MaterialSurface? surface = null, float checker = 0, float tint = 0)An instance of a shape at a transform, with its normal matrix worked out.
public static Vector4 Packed(MaterialSurface surface, float checker = 0, float tint = 0)The lanes the shader reads a surface's shading from.
public static Matrix4x4 NormalMatrix(in Matrix4x4 transform)The matrix a normal goes through under a transform.
Used by (8)
- MaterialSurfaceTestsVixen.Rendering.Tests
- MeshInstanceRendererVixen.Rendering
- MeshInstanceRendererTestsVixen.Rendering.Tests
- PrimitiveShapeTestsVixen.Editor.SceneView.Tests
- SceneMaterialTestsVixen.Editor.SceneView.Tests
- SceneMeshAssetTestsVixen.Editor.SceneView.Tests
- SceneMeshesVixen.Editor.SceneView
- ViewportStateTestsVixen.Editor.SceneView.Tests