Subimaging for THREE.Texture
See original GitHub issueJust some inspiration for a subimaging approach, how I did it…
THREE.Texture = function... {
...
this._subImages = [];
...
}
addSubImage: function( offsetX, offsetY, image) {
this._subImages.push( {
_subOffsetX: offsetX,
_subOffsetY: offsetY,
image: image
} );
this.needsUpdate = true;
},
//from WebGLRenderer
this.setTexture = function ( texture, slot ) {
...
// the code for regular textures with auto generated mipmaps:
if ( texture._subImages.length == 0 ) {
_gl.texImage2D( _gl.TEXTURE_2D, 0, glFormat, glFormat, glType, texture.image );
} else {
for ( var i = 0, il = texture._subImages.length; i < il; i ++ ) {
_gl.texSubImage2D( _gl.TEXTURE_2D, 0, texture._subImages[ i ]._subOffsetX, texture._subImages[ i ]._subOffsetY, glFormat, glType, texture._subImages[ i ].image );
}
texture._subImages = [];
}
...
};
… if I find time I might code it out one day, but this would have to be done for all renderers and all cases I guess (CompressedTexture, DataTexture?, Cubestuff?, etc.)
Ah well the benefit… the benefit is performance and fancyness I guess. Replacing parts of a texture is cool 👍 And e.g. for spritesheets it’s way faster than instantiating a new texture every time.
Soooo searching for volunteer! 😄
Issue Analytics
- State:
- Created 10 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Texture SubImage Interface · Issue #17162 · mrdoob/three.js
The suggestion is to move the subimage interface to the texture. Each texture would have an array of SubImageData that can be appended...
Read more >Best way to texSubImage2D [SOLVED] - three.js forum
I do have another question though: Is there anyway to access a WebGLTexture object from the ThreeJS Texture object? Try this: var textureProperties...
Read more >Three.js: Strategies to progressively increase resolution of ...
Each material has a different texture, which in your case are the different resolution images. Now, debug into your Mesh . Under the...
Read more >Ubuntu Manpage: glCopyTexSubImage3D ... - manpages.ubuntu!
... glCopyTextureSubImage3D - copy a three-dimensional texture subimage ... target Specifies the target to which the texture object is bound for ...
Read more >glGetTextureSubImage - OpenGL 4 Reference Pages
glGetTextureSubImage returns a texture subimage into pixels. texture is the name of the source texture object and must not be a buffer or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This would be quite useful to our project. We’re working with spherical panoramas and I’ve found a bottle neck loading textures with size 4096x2048 on mobile devices.
textImage2dblocks the UI thread for a little over half a second. I may change to cubic maps, but functionality like this would be pretty useful.@arcanis I can work on testing your implementation.
#13512