question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subimaging for THREE.Texture

See original GitHub issue

Just 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:closed
  • Created 10 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
FreakTheMightycommented, Jan 11, 2016

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. textImage2d blocks 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.

0reactions
mrdoobcommented, Mar 9, 2018
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found