Skip to content
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

WebGPURenderer: error with empty compressed textures #29785

Closed
vlucendo opened this issue Nov 1, 2024 · 1 comment · Fixed by #29788
Closed

WebGPURenderer: error with empty compressed textures #29785

vlucendo opened this issue Nov 1, 2024 · 1 comment · Fixed by #29788
Milestone

Comments

@vlucendo
Copy link
Contributor

vlucendo commented Nov 1, 2024

Description

It is very common to assign an empty texture to a uniform while the asset loads, and then copy the loaded data to it once it's available. On WebGPU renderer this throws an error due to the lack of mipmaps.

Reproduction steps

  1. Assign an empty compressed texture to a uniform
  2. Render something with a shader using that uniform

Code

const testLoader = new KTX2Loader();
testLoader.detectSupport(webgpurenderer);
testLoader.setTranscoderPath(`libs/basis/`);

const cTexture = new CompressedTexture();
const textureNode = texture(cTexture);

testLoader.loadAsync('url_of_new_texture.ktx2').then((newTexture) => {
    cTexture.copy(newTexture);
    cTexture.needsUpdate = true;
});

 const fs = wgslFn(/* wgsl */ `
  fn test(
      vUv: vec2f,
      tex: texture_2d<f32>,
      tex_sampler: sampler
  ) -> vec4<f32> {
      var lala = textureSample(tex, tex_sampler, vUv);
      return vec4f(lala.rgb, 1.0);
  }
`);

this.material.fragmentNode = fs({
    vUv: varyingvUv,
    tex: textureNode,
    tex_sampler: textureNode,
});

// ... etc

Live example

Screenshots

No response

Version

r170

Device

No response

Browser

No response

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented Nov 1, 2024

I think this has been overlooked since we have only tested compressed textures with KTX2Loader so far. We then use loadAsync() which makes sure the compressed texture is ready on the first usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants