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

getTextureUV call to atlas.uv is needlessly expensive #15

Open
nikitakit opened this issue Sep 23, 2016 · 0 comments
Open

getTextureUV call to atlas.uv is needlessly expensive #15

nikitakit opened this issue Sep 23, 2016 · 0 comments

Comments

@nikitakit
Copy link

getTextureUV calls atlas.uv(), which requires looping over the entire atlas (roughly linear time in the number of textures). It then uses just one entry, and throws the rest of the data away. The mesher plugin calls this method at the innermost loop of the block model pipeline (it's called for every texture element in a block model, for every block in the scene)

I think some caching here would be very useful.

I'm rendering some maps using a chunk distance of 2-4, 32x32x32 chunks, with a very large set of block models. A hacky caching fix for this issue makes the difference between intolerable slowdowns and mostly-OK levels of performance. I was surprised to find that mesh creation is the slowest part of the pipeline, while the 3D renderer can keep up with camera movements at a very reasonable framerate.

Note to anyone addressing this: uv.slice() is a shallow copy, i.e. getTextureUV actually mutates the data on-demand. Any caching needs to make sure these mutations only happen once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant