Page MenuHome

SPH Fluid Density texture
Closed, ArchivedPublicPATCH


This patch adds a new texture type for rendering SPH fluids. It is based on the Point Density texture, but on each sample, the actual SPH field variables are used to colour the surface. Like Point Density, this can also be used with a volumetric material to visualise the shape of the particle system.

This patch overlaps a little with 29661 and 29663 (bug fixes and refactoring). However the patch provided (fluidDensity_r42811_1_svn.patch) applies against trunk (r42811) and does not need other patches applied first.

By making a contribution to this project, I certify that the contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file.

Signed-off-by: Alex Fraser <> on behalf of VPAC Ltd.

Event Timeline

As discussed with Janne on IRC, the patch in its current form may not be ideal. It might be better to either:
- Combine this feature with the Point Density texture, or
- Combine it with the force field visualisation work by Lukas.

Attached is a new version of the patch that applies against r46643 (fluidDensity_r46643_4_svn.patch). This version no longer introduces a new texture type: instead, the new functionality is added directly to Point Density. A new test file is attached, and new rendered image.

Point Density now has three modes: [Particle System, Object Vertices, Fluid Particles]. In Fluid particles mode, all the falloff options are disabled, because this information is taken from the SPH settings. Also the colour source is hidden, because extracting the velocity and age is not implemented yet (it would be possible, in future, to extract these using the SPH kernel).

The attached image (fluidVsPoint_wave2.png) shows the difference between the old Particle System mode and the new Fluid Particles mode. Blue is old, red is new. As shown in the image, it is possible to come close with the old method, but it is not an accurate representation of the SPH density field.

Attached a new version (fluidDensity_r46643_5_svn.patch) which fixes a crasher: now, if Fluid Particle mode is chosen but the particle system has no fluid settings, the texture will return a value of zero for all samples. Note that the old Particle System mode is unaffected by this.

With a volumetric material, this can also be used to render a surface of a particle fluid (fluidDens_volume.jpg). Although, you can get similar results with the original Point Density texture - but this is more accurate! :)

Attaching a new version of the patch (fluidDensity_r53102_6_svn.patch) that applies against HEAD. This version works with the new classical SPH solver too.

Also attaching a comparison of the SPH density field vs regular point density texture for a dam break simulation (fluidVsPoint_dam_break.png).

I am trying your patch.
I am frustated to not having access to radius and fall-off settings.
Although shape's accuracy is better; it is difficult to obtain a rendered volume close to what we see in 3D view.
It is obvious in your render ( fluidDens_volume.jpg ). Borders of rendered volume are far away from borders of particles mass in 3D view.
I hope that efforts to create low-poly surface for sph will happen.
Volumes are slow to render and a nightmare in compositing (no ability to obtain correct normals for reflection rendering, no only shadow option, no raytransparency limited to point density).

a blend to show problem with a volume.

a pratical case where i did not succeed to obtain a thin fluid with fluid particles choïce.

I made an animation with this patch.

Hi Ronan,

Sorry it has taken me so long to respond. The animation is good! Are you happy with that result, or do you still want more control over the look?

How useful do you think this texture is in general? If there was a way to generate a surface mesh from the particles, would you use the texture at all?


Dalai Felinto (dfelinto) closed this task as Archived.Dec 23 2019, 6:50 PM
Dalai Felinto (dfelinto) claimed this task.

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.