Fluid Simulation & Rendering

You can use the existing .sdf files in FluidRendering/src/assets/sdf at main · Popov72/FluidRendering · GitHub as an example.

The value of the 3rd line is the <dx> parameter to be passed to sdfgen.

For example, for sphere.sdf, it’s 0.1 :

image

Depending on the value, the .sdf file will be more or less precise (and the file more or less voluminous).

For the <padding> parameter, I used 4 for all models.

My parameter settings are as follows
image

But the fluid passed directly through the container
image

You probably need to decrease the grid size (currently 0.1) because this results in a sdf with dimensions 8x8x8 (see first line), which is too small. Try 0.03 instead and see if that helps.

Stupid question: your model has a bottom, doesn’t it?

It seems to be working, it looks like it’s due to a missing. mtl file.

Thank you, @Evgeni_Popov

1 Like

I have a dam model, but I don’t have an SDF file. How can I combine the dam with the fluid? What tool can I use to obtain the SDF file of the dam model

thanks

If you can convert your model to a .obj file, you can use sdfgen to generate the sdf file.

1 Like

thanks i see

hi~
I am using fluids to apply to my dam model and have encountered some issues during this process. The fluid directly penetrates the model. This is my code example. Can you help me find the problem

  1. My code example has been modified using the official example

  2. I use the sdfgen tool to output obj to sdf

    Conversion command [SDFGen dam3. obj 0.1 4]

  3. This is my file

dam3.zip (578.0 KB)

I can see your .obj file has 11 different meshes: try to merge them into a single one, I don’t know if sdfgen works correctly when there are multiple meshes in the file…

2 Likes

hey, Evgeni_Popov. how to make the fluid achieve self-luminescence. @Evgeni_Popov

You would have to write your own shader and replace the one used by the fluid renderer if you want to change how it looks (the current shader can be found/replaced in BABYLON.ShaderStore.ShadersStore["fluidRenderingRenderPixelShader"]). The glow/highlight layer won’t work because the fluid renderer is using a post-process and not regular meshes for rendering.

1 Like

I’m not very good at it. Is there any guideline that I can refer to?

I think there are a lot of ressources about writing shaders on the web. I don’t know any particular ones, but after a quick research, I found these:

2 Likes

I get a number of errors in the console when I hit the demo link:

It looks like uniformity warnings and some variables that should be declared as const instead of let.

I have updated my first post, the fluid renderer is now integrated into Babylon and you should access the demos through the doc page:

3 Likes