Skip to content

allow further texture uniforms #12558

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bkuster
Copy link
Contributor

@bkuster bkuster commented Apr 9, 2025

Description

The number of image data types available to Materials should be upgraded with some more data types:

  • OffscreenCanvas (can just be passed to WegGL, same as HTMLCanvasElement).
  • ImageBitmap (can be directly consumed by the GPU).

In my usecase, I already have an ImageBitmap created in a worker and would like to avoid having to draw it onto a canvas to then pass it to the Texture, when I could just pass it directly.

Testing plan

Added tests to MetarialSpec.js for both use cases.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

github-actions bot commented Apr 9, 2025

Thank you for the pull request, @bkuster!

✅ We can confirm we have a CLA on file for you.

@ggetz
Copy link
Contributor

ggetz commented Apr 11, 2025

Awesome, thanks @bkuster!

@jjhembd Would you mind taking a pass on this PR?

@ggetz
Copy link
Contributor

ggetz commented Apr 17, 2025

A friendly reminder to @jjhembd to take a pass on this.

Copy link
Contributor

@jjhembd jjhembd left a comment

Choose a reason for hiding this comment

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

Thanks @bkuster! The code change looks good to me. I think we only need to extend the docs update to a couple more places inside Texture. Then this should be good to go!

@@ -483,7 +483,7 @@ function loadFramebufferSource(texture, source) {
* Load texel data from an Image into a texture.
*
* @param {Texture} texture The texture to which texel values will be loaded.
* @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} source The source for texel values to be loaded into the texture.
* @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|OffscreenCanvas|ImageBitmap} source The source for texel values to be loaded into the texture.
Copy link
Contributor

Choose a reason for hiding this comment

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

This update to the type should also apply to the functions that call loadImageSource.

  • The doc for Texture.copyFrom should be a straightforward update.
  • The Texture constructor itself is messier, but I think Texture.ConstructorOptions.source could have the same doc as options.source from Texture.copyFrom.

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.

3 participants