Skip to content

Conversation

mats31
Copy link

@mats31 mats31 commented Sep 17, 2025

Description

A few years ago, I've ported the Fluid Distortion example from OGL to three.js. Now that I'm digging into TSL, I decided to do it again in WebGPU. The logic stays the same using GPGPU rendering but with several StorageTextures. I thought that maybe it could be an helpful example 😊.

@RenaudRohlinger
Copy link
Collaborator

Nice! I also put together a TSL implementation with a basic RenderTarget. I’m curious to see how Storage Textures performances compares with classic RTT. That’s a neat idea, and I’m looking forward to benchmarking both approaches.

Also in a few weeks, Chrome Canary should release the optional texture-formats-tier2 feature (gpuweb/gpuweb#5226
). This would let us drop the ping-pong strategy and instead use a single storage texture with both read and write access at the same time.

That said, it probably makes sense to keep the ping-pong approach for now, since texture-formats-tier2 won’t be available on all GPUs. Realistically, we’ll likely need to wait another year before support is widespread enough to rely on it.

@mats31
Copy link
Author

mats31 commented Sep 19, 2025

Thanks @RenaudRohlinger!

That would be a very interesting comparison indeed. I didn't know about this upcoming update for Chrome though, I'll make sure to have a look, thank you 👍.

@sunag
Copy link
Collaborator

sunag commented Sep 21, 2025

Could you follow the mrdoob code style to fix the eslint issues?

I think it would help a lot with the example's adherence if it were transformed into a TSL function
to simplify use like:

import { fluid } from 'three/addons/effects/fluid.js';

material.colorNode = fluid( { ...params } );

@Makio64
Copy link
Contributor

Makio64 commented Sep 22, 2025

So cool @mats31 !

I read it in diagonal but I think you create too many time the same nodes :

				const posX = instanceIndex.mod( width )
				const posY = instanceIndex.div( width )
				const indexUV = uvec2(posX, posY)

				// center-of-texel for this cell
				const uvC = getUVs({ width, height })

I think make a function Fn for part of the code repeated many times will make sense and make the code cleaner, also it might reduce the cpu pressure but im not sure about it @sunag ?

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.

4 participants