Skip to content

Quad Texture Support#1393

Merged
manthey merged 13 commits intomasterfrom
quad-texture-support
Sep 16, 2025
Merged

Quad Texture Support#1393
manthey merged 13 commits intomasterfrom
quad-texture-support

Conversation

@BryonLewis
Copy link
Copy Markdown
Contributor

@BryonLewis BryonLewis commented Aug 1, 2025

Added a new .data({texture}) option to webGL quads:

texture: {
    data: uint8Array,
    width: number,
    height: number,
    type?: 'RGBA' | Luminance | 'LuminanceAlpha' = 'RGBA, // defautls to RGBA if not provided

}

Changes:

  • The new texture format in the data will take in a uint8Array as well as a width/height and a type being RGBA, Luminance or LuminanceAlpha, it will default to RGBA if no type is provided.
  • When loading this will behave similarly to the existing image feature, except it will use the raw texture provided instead of calculating the texture from an image by loading it.
  • It defaults to an RGBA pixel format but will also support Luminance and LuminanceAlpha. The data should align with the type chosen.
  • ./src/webgl/quadFeature.js
    • a quad internally has a new property called imageTexture if it has this it will skip the quad.image conditional in the _updateTextures and use this instead.
    • The _cleanup is updated to conditionally check for existence of items before removing and iteration because of the changes to properties available
    • I've modified the _updateTextures function to handle either an image or direct texture being loaded. The previous version used two conditionals with a lot of duplicated code. I've refactored it to take the texture based on the existence of either a imageTexture or a image with priority given to the imageTexture if it exists. If you want to see the simplified version it should be in the PR history before fix: refactor _updateTextures to remove code duplication
  • ./src/vgl/texture.js
    • m_texture is a new property that represents a texture that doesn't have an associated image
    • There is a new conditional block in setup function that uses textImage2D based on the texture type and size
    • There is also a new setTexture function to manunally set the new m_texture as
  • ./tests/cases/quadFeature.js
    • Added simplified tests for the different texture formats.

@BryonLewis BryonLewis force-pushed the quad-texture-support branch from bf2e3bb to df207d0 Compare August 19, 2025 12:35
@BryonLewis BryonLewis marked this pull request as ready for review September 11, 2025 12:22
@BryonLewis BryonLewis requested a review from manthey September 11, 2025 12:22
Comment thread src/quadFeature.js
video: 'quad.video'
video: 'quad.video',
/* support for raw texture data */
texture: 'quad.texture'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add capabilities[quadFeature.capabilities.texture] = true; near the end of src/webgl/quadFeature.js to indicate that this is supported (so programs that query by support get the webgl renderer).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that there were false values in there (specifically for the canvas and video) so I added capabilities[quadFeature.capabilities.texture] = false to the src/canvas/quadFeature.js as well.

Comment thread src/vgl/texture.js Outdated
* Set Raw Texture data using Uint8Array
*
* @param {object} texture texture object to load.
* type: 'RGB' | 'RGBA' | 'Luminance' | 'LuminanceAlpha'.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass RGB, doesn't this still expect data in RGBA? Should we remove the RGB option if it isn't directly supported?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And, I think the jsdoc of these sub properties should be

   * @param {object} texture texture object to load.
   * @param {string?} texture.type One of 'RGB' | 'RGBA' | 'Luminance' | 'LuminanceAlpha'.
   * @param {Uint8Array} texture.data Array representing the format based on the type
   * @param {number} texture.width width of the texture
   * @param {number} texture.height height of the texture

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll remove RGB, it was part of my early testing. Having RGBA should cover most of the use cases.

@manthey manthey merged commit 1206604 into master Sep 16, 2025
12 checks passed
@manthey manthey deleted the quad-texture-support branch September 16, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants