Skip to content

getTextureUV call to atlas.uv is needlessly expensive #15

@nikitakit

Description

@nikitakit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions