pub struct InstanceDesc {
pub mesh: usize,
pub material: usize,
pub transform: Mat4,
}Expand description
One object in the scene: which resident mesh it draws, which row it shades through, and where it is.
Handed to ForwardRenderer::add_instance and
ForwardRenderer::set_instance, at any point in a renderer’s life — this
is the half of the scene that is calls rather than data, for the reason the
module docs open with.
§Both fields are description indices, not table ids
mesh is an index into SceneDesc::meshes and
material one into SceneDesc::materials — the
positions a caller wrote its own description in, which is the only numbering
it has. Neither is the id the GPU reads: a DAG occupies one mesh table entry
per level, so a description’s fourth mesh is very often not table entry
four, and an instance always names level 0’s entry whatever level it ends up
drawn at. The renderer holds that mapping and is what resolves it.
Fields§
§mesh: usizeWhich SceneDesc::meshes entry this object draws.
material: usizeWhich SceneDesc::materials row it shades through.
Row 0 is the one mesh::GpuInstance::default names, so it is what an
object shades through by omission — see SceneDesc::materials.
transform: Mat4Where it is: a model matrix, on mesh::GpuInstance::transform’s
terms — any affine one, non-uniform scale included, because the mesh
shaders build the normal transform out of it rather than assuming its
3×3 is orthonormal.