engine_components icon indicating copy to clipboard operation
engine_components copied to clipboard

Colour palette texture atlas for merged geometries

Open harrycollin opened this issue 2 years ago • 1 comments

Description 📝

Generate a simple colour palette texture to replace multiple materials in merged geometries. With some simple UV mapping you map entire sections of a merged geometry to single pixels on a texture. This results in a single draw call for that geometry instead of n draw calls for n colours.

This could also be applied to instanced items to keep the number of unique materials to one. Although the benefits become less noticeable.

Suggested solution 💡

Based on the colours found in a merged geometry generate a small texture with a resolution of 1 x (unique colours) and UV map items to pixels in this texture. Additional pixel padding might be needed.

Alternative ⛕

No response

Additional context ☝️

This approach can be found in many 2D games where a larger texture atlas is used for many sprites. Resulting in fewer draw calls.

Example texture atlas: image

Validations ✅

  • [X] Read the docs.
  • [X] Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

harrycollin avatar Aug 10 '23 10:08 harrycollin

This is a brilliant idea. I'm adding it to the next milestone!

agviegas avatar Nov 02 '23 11:11 agviegas

This is a great idea, but would also make the library more complex. Streaming should already give us decent performance, even with bigger models. We'll leave this for now and keep this in mind as a resort to come back to if draw calls become an issue in the future

agviegas avatar Jun 20 '24 09:06 agviegas