Skip to content

five-on-it / apps/client/src/renderer/materials

apps/client/src/renderer/materials ​

Materials made without a look through the scene. Babylon marks a material's sub-meshes dirty when one of its settings changes, and finds them by asking every sub-mesh of every mesh of the scene for its material: nothing in a mini level, about 10 ms in a city of 9,000 pieces, for a material no mesh uses yet. Setting how many lights a material takes costs one such look, and so does every material pushed onto a multi-material; a wreck's dozen burnt materials, made the first time it is drawn charred, were a frame of 150 ms, and a car in a paint not seen before a frame dropped.

So a material that takes several lights is a copy of one made once (a copy carries the setting over without setting it), and a multi-material is given its materials in one go.

Functions ​