This is my first topic so first of all want to say thanks everyone for supporting Babylon.js comunity! Hope it keeps growing and becoming more popular.
I used FluidRenderer to build a foam effect (particles poured from a bottle) for a commercial project, and ran into two small limitations that I worked around locally. I’d like to upstream them properly if there’s interest.
Playground demo: Babylon.js Playground – shows both patches applied at runtime via ShaderStore/prototype patching.
Per-particle size – right now every particle in a fluid render pass uses the same global size, even when the particle system already has its own per-particle size (e.g. shrinking over lifetime). Would be nice to support that.
Opaque shading mode – fluid rendering always does glassy refraction. An option for a simple opaque, lit look would open it up for foam, milk, paint, lava, etc., not just water.
Would love your thoughts on whether these fit, before I put together a PR. Will be happy to make some contribution
Regarding per-particle size, please go ahead and create a PR. The feature should be opt-in for the fluid rendering system as a whole. Please add a static boolean—disabled by default—to enable the use of the particles’ size vertex attribute. We can finalize the property name while reviewing your PR. Reading an additional vertex attribute is not free, and custom particle buffers will need to provide a size attribute when the option is enabled. The current behavior must remain the default.
Regarding opaque shading, I don’t think we should add a dedicated opaque mode to core. The final fluid shader can already be customized through PostProcess.RegisterShaderCodeProcessing, which also supports adding and binding custom uniforms and samplers. This is more generic and can support opaque, emissive, stylized, or any other custom shading without adding specialized modes to FluidRenderingTargetRenderer.
I made an updated version of your Playground demonstrating this approach:
It retains your per-particle-size prototype patch, but implements the opaque appearance through RegisterShaderCodeProcessing("FluidRendering", ...), without requiring any core changes for the shading part.
Per-particle size landed in #18863 (v9.25): BABYLON.FluidRenderingObject.UsePerParticleSizeAttribute = true, works with ParticleSystem and custom particles (a size buffer with width/height per particle).
However, while adding GPUParticleSystem support I ran into a bug that is not related to the flag: the GPU sprite quad uses centered offsets (-0.5..0.5) while the fluid shaders expect 0..1, so GPU particles come out shifted by half a particle and only a quarter of each sphere survives the discard. You can see it on the current release here: https://playground.babylonjs.com/#M9FSIH#2. Both the GPU support and the offset fix are in #18888 (in review).
One more thing I noticed but did not touch: with addParticleSystem(gpuPs, false) (no diffuse texture) GPU particles never emit, because the emission bookkeeping lives in GPUParticleSystem.render(), which the fluid object replaces with a no-op. Happy to look at it if that is wanted.