-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
PMREM and EquiangularToCubeGenerator: added dispose() methods #13815
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
Conversation
|
Unrelated to this PR... I am thinking that this pattern is a bit too much: var pmremGenerator = new THREE.PMREMGenerator( hdrCubeMap );
pmremGenerator.update( renderer );
var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods );
pmremCubeUVPacker.update( renderer );
hdrCubeRenderTarget = pmremCubeUVPacker.CubeUVRenderTarget;
hdrCubeMap.dispose();
pmremGenerator.dispose();
pmremCubeUVPacker.dispose();Pehaps we can hide all of that, and free up memory when we are done, via a simpler API: var pmrem = new THREE.PMREM(); // Extends WebGLRenderTarget
pmrem.setFromCubeMap( cubeTexture, renderer );
pmrem.setFromEquirectangularMap( texture, renderer ); // alternate
material.envMap = pmrem.texture;/ping @bhouston |
|
I like the below: I can view it as a few separate operations:
I would actually suggest killing the idea of the PMREM class and replacing it with CubeTextureFactory/CubeTextureUtility class that has these functions on it. I am sure there are others we could add (CubeMap To EquirectangularMap, AngularMap to/from CubeMap, CubeMap to MapCap, CubeMap to/from SphericalHarmonic, etc.) I think that having them each as separable atomic operations would make it clearer and easier to use, and also lead to more reuse. |
|
How about: Basically I view the above as more precise and atomic. |
|
Or another alternative design would be to follow the Math class examples, where we avoid utility/factory classes and just have a class for each different interpretation of data: I have to say the above seems the most Three.JS like API - very obvious/simple and usable. Takes the mystery out of the admittedly intimidating "PMREM" name. |
|
@bhouston Thank you for the suggestions. For now, this PR allows us to continue to use the existing utilities, and in the HDR example, optionally dispose of ~ 500 temporary geometries and textures. Is this OK to merge for now? |
|
Thanks! |
...as proposed in #13752 (comment), plus some clean up.
Calling the dispose() methods significantly frees up gpu memory.