Skip to content

Texture from region of canvas #25669

@ikerr

Description

@ikerr

Description

It would be handy if THREE.Texture / THREE.CanvasTexture allowed you to create a texture from a subregion of a canvas (I'd imagine this would also be useful for images). I'm attempting to filter very large canvases using GLSL (with dimensions greater than MAX_TEXTURE_SIZE), so the canvases need to be tiled. I'd like to be able to create a set of THREE.CanvasTexture instances where each one references the same canvas, but a different subregion of that canvas.

Solution

This looks to be possible with WebGL 2 using pixelStorei with UNPACK_SKIP_ROWS and UNPACK_SKIP_PIXELS (see https://stackoverflow.com/questions/20930466/webgl-is-there-an-efficient-way-to-upload-only-part-of-an-image-canvas-as-a-tex).

Perhaps these could be additional properties on THREE.Texture: unpackSkipRows, unpackSkipPixels.

Alternatives

Currently I need to create a separate canvas for each "tile" texture.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions