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

StorageTexture: Mipmaps #27332

Merged
merged 3 commits into from
Dec 7, 2023
Merged

StorageTexture: Mipmaps #27332

merged 3 commits into from
Dec 7, 2023

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Dec 7, 2023

Related issue: Closes #27274

Description

Whenever StorageTexture is computed and storageTexture.generateMipmaps=true and storageTexture.minFilter=Mipmaps.. the Backend.generateMipmaps() will be called.

--

  • WebGPURenderer.getMaxAnisotropy()

@sunag sunag added this to the r160 milestone Dec 7, 2023
@sunag sunag marked this pull request as ready for review December 7, 2023 16:37
@sunag sunag merged commit 4c7912c into mrdoob:dev Dec 7, 2023
11 checks passed
@sunag sunag deleted the dev-storageTexture-mipmaps branch December 7, 2023 16:46
@Spiri0
Copy link
Contributor

Spiri0 commented Dec 22, 2023

Hi Sunag,

I immediately downloaded r160 and also looked at the two compute texture examples to see whether mipmaps were created. In compute textures I saw a commented out line.

I just did this after the computed storageTextures:

Update(){

   //Here the textures are computed


   this.displacement.generateMipmaps = true;
   this.derivative.generateMipmaps = true;
   this.jacobian.generateMipmaps = true;

   this.displacement.magFilter = THREE.LinearFilter;
   this.derivative.magFilter = THREE.LinearFilter;
   this.jacobian.magFilter = THREE.LinearFilter;

   this.displacement.minFilter = THREE.LinearMipMapLinearFilter;
   this.derivative.minFilter = THREE.LinearMipMapLinearFilter;
   this.jacobian.minFilter = THREE.LinearMipMapLinearFilter;

   this.displacement.anisotropy = this.params_.renderer.getMaxAnisotropy();
   this.derivative.anisotropy = this.params_.renderer.getMaxAnisotropy();
   this.jacobian.anisotropy = this.params_.renderer.getMaxAnisotropy();

  
   document.getElementById("testfield5").value = Object.keys(this.displacement);
   document.getElementById("testfield6").value = this.displacement.mipmaps.length;  //to check whether the mipmaps have been created
}

The length of the mipmaps is shown to me as 0. At 256 x 256 for the storageTextures my expected value is 8 mipmaps.
Is Mipmaps.. a new node element in your comment? In any case, I couldn't find it in nodes.js.
The code runs without error messages and that's a good thing. Only the mipmaps are not created.

If it's ever of interest, I've uploaded my repo to github.
Maybe this would be useful as a test environment for future expansions around webgpu. So far I'm probably the only one who uses webgpu and the node system to such a large extent. And I'll add more.

But that's just a thought.

@sunag
Copy link
Collaborator Author

sunag commented Dec 23, 2023

It was not intentional to store the automatically generated mipmaps in texture.mipmaps, this field is being used to load manually mipmaps generated.
It's possible to perform another test.

Open webgpu_compute_texture and make some changes:

const storageTexture = new StorageTexture( width, height );
storageTexture.minFilter = THREE.LinearMipMapLinearFilter;

...

const material = new MeshBasicNodeMaterial( { color: 0x00ff00 } );
material.colorNode = texture( storageTexture ).level( float( 5 ) );

minFilter will enable mipmaps and the node level will access the mipmap selected .level( float( 5 ) );

@Spiri0
Copy link
Contributor

Spiri0 commented Dec 23, 2023 via email

AdaRoseCannon pushed a commit to AdaRoseCannon/three.js that referenced this pull request Jan 15, 2024
* StorageTexture: Mipmaps

* revision

* use texture.generateMipmaps
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.

Useful extensions for the webgpuRenderer
2 participants