three.js icon indicating copy to clipboard operation
three.js copied to clipboard

[WIP] Add CubeTexture blur

Open elalish opened this issue 1 year ago • 9 comments

The idea here is to make the PMREM cubemap blur function available as a generic public blur method for a CubeTexture. So far I only have a sketch, but this being my first attempt at using TSL, I've run into some early problems that I'd like to ask @sunag about.

elalish avatar Dec 19 '24 00:12 elalish

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.44
79.06
339.44
79.06
+0 B
+0 B
WebGPU 488.86
135.68
489.66
135.89
+798 B
+212 B
WebGPU Nodes 488.33
135.55
489.1
135.77
+775 B
+220 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.3
112.11
465.3
112.11
+0 B
+0 B
WebGPU 558.8
151.3
559.79
151.53
+996 B
+232 B
WebGPU Nodes 514.87
141.07
515.87
141.29
+996 B
+224 B

github-actions[bot] avatar Dec 19 '24 00:12 github-actions[bot]

I'd like to ask @sunag about.

I can help with whatever you need :)

sunag avatar Dec 19 '24 00:12 sunag

Thanks @sunag - that got me unstuck for a bit. However, in my last commit I'm trying to pull in some of the #29900 changes but I hit a weird error, this.value is null in the function below:

getTransformedUV( uvNode ) {

		if ( this._matrixUniform === null ) this._matrixUniform = uniform( this.value.matrix );

I would guess this has something to do with my outputDirection node, but I don't think I've changed anything about it? In any case, fodder for a clearer error message. Any thoughts?

elalish avatar Dec 19 '24 18:12 elalish

that got me unstuck for a bit. However, in my last commit I'm trying to pull in some of the https://github.com/mrdoob/three.js/pull/29900 changes but I hit a weird error, this.value is null in the function below:

I pushed a commit to fix set uniform value, this happened because texture( null ) is uniform, you can change the value by changing the .value property. But I think we can improve this error message.

sunag avatar Dec 19 '24 20:12 sunag

Ah, thank you again! I don't know how you manage to develop all this without TS. I have the actual blur function written now - I just need to test it.

elalish avatar Dec 19 '24 22:12 elalish

Okay, I might have this close to working, and I updated the new API with feedback from @mrdoob. However, upon trying to test it, I realized that CubeRenderTarget is not exported to the public API - it inherits from WebGLCubeRenderTarget which is, but that doesn't have any of the new TSL stuff. Where should this function be exposed?

elalish avatar Dec 23 '24 20:12 elalish

Since this is my last day at Google (and as a maintainer of MV, see https://github.com/google/model-viewer/discussions/4975) I don't think I'll get a chance to finish this PR. Hopefully it looks useful enough for someone else to pick up and push over the finish line. Thanks for all the help, @sunag! The TSL you've built is quite impressive, though hopefully by the time I play with it again it'll have a few more docs 😄.

elalish avatar Dec 30 '24 22:12 elalish

@elalish This news took me by surprise. You have done an incredible job over the years with MV and with all the improvements in physical-based materials, tone mapping, etc. I have always found your high level work and rich in detail, your work will certainly be missed by the community. I hope we can meet again on life's journey and I wish you all the best in your achievements.

sunag avatar Dec 30 '24 23:12 sunag

Thanks a lot @sunag! If you ever find yourself in New Zealand, come visit.

elalish avatar Jan 05 '25 06:01 elalish