Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colour palette texture atlas for merged geometries #104

Closed
2 tasks done
harrycollin opened this issue Aug 10, 2023 · 2 comments
Closed
2 tasks done

Colour palette texture atlas for merged geometries #104

harrycollin opened this issue Aug 10, 2023 · 2 comments
Labels
feature Something new that we could do

Comments

@harrycollin
Copy link
Contributor

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 ✅

  • Read the docs.
  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
@harrycollin harrycollin added the feature Something new that we could do label Aug 10, 2023
@harrycollin harrycollin changed the title Color palette texture atlas for merged geometries Colour palette texture atlas for merged geometries Aug 10, 2023
@agviegas
Copy link
Contributor

agviegas commented Nov 2, 2023

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

@agviegas agviegas added this to the 1.3.0 milestone Nov 2, 2023
@agviegas agviegas removed this from the 1.3.0 milestone Jan 27, 2024
@agviegas
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something new that we could do
Projects
None yet
Development

No branches or pull requests

2 participants