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

Texture reuse memory issue #17653

Closed
3 of 11 tasks
adevart opened this issue Oct 3, 2019 · 1 comment
Closed
3 of 11 tasks

Texture reuse memory issue #17653

adevart opened this issue Oct 3, 2019 · 1 comment

Comments

@adevart
Copy link

adevart commented Oct 3, 2019

texture-test.zip

Description of the problem

In the attached project, there are a set of sprites created using the same texture.

The first texture is created and it has an image object inside it. More textures are created from this image.

If I don't set needsUpdate = true in the loop, none of the textures display.
If I do set needsUpdate = true, it uploads each copy of the same texture separately to the GPU and with enough copies runs out of memory.

Why doesn't it display copied textures without setting needsUpdate = true and why does it keep uploading copies when needsUpdate is true?

I would expect the first texture displaying would mean subsequent copies would display ok without needsUpdate.
Once a base image is uploaded to the GPU, it doesn't need to be uploaded again. Can there be an internal method for tracking which webgl textures have already been created, perhaps based on the source URL so that it checks if it's already on the GPU and if it is, reuse that instead of uploading another copy.

In this example, the texture creation can be taken outside of the loop but the reason I want it to work inside is that I need to be able to change the parameters for each copy.

Three.js version
  • r106
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 3, 2019

Once a base image is uploaded to the GPU, it doesn't need to be uploaded again.

It's not possible so far that textures share the internal WebGLTexture object, see #5821. One way to solve this issue is the introduction of THREE.Image like mentioned here: #5876 (comment)

I'm going to mark your issue as a duplicate of #5821, okay? Please proceed the discussion there.

@Mugen87 Mugen87 closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants