26-10-2024, 05:57 PM (This post was last modified: 27-10-2024, 03:27 AM by spikebor.)
Hello there! First, pls look at this video
It shows 3 problems with foam particle rendering.
I'm On Unity 2022.3.45 URP deferred rendering.
In this example, I use Obi Fluid only for splash and trail effects, the infinitive ocean is KWS water system.
Problems with the Foam shown in the video:
1-Culling is so sensitive.
The foam particles are so easy to be culled, it can break immersion.
2-In script, I animate the ObiEmitter.speed to do the motorboat foam trail effect, and the dive into water splash effect.
for motorboat: when I contact the water and move on it, I set the ObiEmitter.speed to high value, when exit water, I set it to 0.
for dive splash effect: when I dive into water, I set ObiEmitter.speed to high value, then gradually animate the value to 0, it is Stream, but when I animate the speed, it looks like burst effect.
The problem is, after the ObiEmitter.speed is set to 0 in script, the emitter stops emitting, but the foam needs to be continued updated to it can gradually die out, but in the video, foam just hang in place. Is there somewhere in the system, when system detect ObiEmitter has 0 emission speed, it stop the ObiFoamGenerator from updating?
Suggest: ObiFoamGenerator only stop updating when the foam particles all die out.
3-Suggestion regarding foam rendering.
The foam currently not work well with KWS water system underwater rendering. I think if it is just opaque, it can receive those lighting.
Currently, it is just white while everything is tinted, looks so out of place. But a quick edit in the shader code to turn it to Opaque shows no noticeable changes.
Can you provide a shader graph version of the Foam shader? I'll try with Cutout Opaque to see.
Thank you!
31-10-2024, 10:43 AM (This post was last modified: 31-10-2024, 10:53 AM by josemendez.)
(26-10-2024, 05:57 PM)spikebor Wrote: 1-Culling is so sensitive.
The foam particles are so easy to be culled, it can break immersion.
Hi,
Foam is not independently culled (it gets culled with the solver, if the solver's "simulate when invisible" is disabled).
(26-10-2024, 05:57 PM)spikebor Wrote: 2-In script, I animate the ObiEmitter.speed to do the motorboat foam trail effect, and the dive into water splash effect.
for motorboat: when I contact the water and move on it, I set the ObiEmitter.speed to high value, when exit water, I set it to 0.
for dive splash effect: when I dive into water, I set ObiEmitter.speed to high value, then gradually animate the value to 0, it is Stream, but when I animate the speed, it looks like burst effect.
The problem is, after the ObiEmitter.speed is set to 0 in script, the emitter stops emitting, but the foam needs to be continued updated to it can gradually die out, but in the video, foam just hang in place. Is there somewhere in the system, when system detect ObiEmitter has 0 emission speed, it stop the ObiFoamGenerator from updating?
Suggest: ObiFoamGenerator only stop updating when the foam particles all die out.
Setting emitter.speed only sets the emission speed, existing fluid particles continue to live on until they reach their maximum lifetime. Foam continues being updated as long as foam particles still exist, it does not care about fluid particle lifetime or emitter's emission speed at all. The foam simulation and the fluid simulation are completely independent from each other, so setting emitter.speed = 0 will not affect foam behavior at all.
My guess is that your foam's "atmospheric drag" value is set to 1?. This will cause fluid particles to immediately lose all energy when no nearby fluid is around, making foam unnaturally stay frozen midair. Typically you're have a small drag value to simulate atmospheric density, allowing foam to slowly fall due to gravity when no fluid is close to it. It can also age faster, using the "air aging" parameter so that foam vanishes faster mid-air, when no fluid is around. This should result in natural-looking airborne foam.
(26-10-2024, 05:57 PM)spikebor Wrote: 3-Suggestion regarding foam rendering.
The foam currently not work well with KWS water system underwater rendering. I think if it is just opaque, it can receive those lighting.
Currently, it is just white while everything is tinted, looks so out of place. But a quick edit in the shader code to turn it to Opaque shows no noticeable changes.
Can you provide a shader graph version of the Foam shader? I'll try with Cutout Opaque to see.
Thank you!
Setting the shader's render queue and/or render type to Opaque does not make the shader opaque, it just changes the point during the frame at which the object is rendered. It does not change what the actual shader does at all. You need to change the blending mode too, write to the depth buffer, and add proper lighting which may not be trivial at all if you want it to integrate with KWS's custom lighting.
Unfortunately, the foam shader cannot currently be made using ShaderGraph. You'll have to edit the shader as plain text.
Foam is not independently culled (it gets culled with the solver, if the solver's "simulate when invisible" is disabled).
Setting emitter.speed only sets the emission speed, existing fluid particles continue to live on until they reach their maximum lifetime. Foam continues being updated as long as foam particles still exist, it does not care about fluid particle lifetime or emitter's emission speed at all. The foam simulation and the fluid simulation are completely independent from each other, so setting emitter.speed = 0 will not affect foam behavior at all.
My guess is that your foam's "atmospheric drag" value is set to 1?. This will cause fluid particles to immediately lose all energy when no nearby fluid is around, making foam unnaturally stay frozen midair. Typically you're have a small drag value to simulate atmospheric density, allowing foam to slowly fall due to gravity when no fluid is close to it. It can also age faster, using the "air aging" parameter so that foam vanishes faster mid-air, when no fluid is around. This should result in natural-looking airborne foam.
Setting the shader's render queue and/or render type to Opaque does not make the shader opaque, it just changes the point during the frame at which the object is rendered. It does not change what the actual shader does at all. You need to change the blending mode too, write to the depth buffer, and add proper lighting which may not be trivial at all if you want it to integrate with KWS's custom lighting.
Unfortunately, the foam shader cannot currently be made using ShaderGraph. You'll have to edit the shader as plain text.
kind regards,
Hi, thanks for the reply. But as I just test, no need to use script, you can test by change the speed to 50, wait a few secs, then 0, by changing value in the inspector. the foam particles will stay frozen in place after all the fluid particles die out. I've test this with various foam's atmospheric drag value from 0, 0.1, 0.5, 1 all same result. So, it's hard to say it is not independent on the emitter.speed, or I may say fluid particle count. As the frozen effect only happens when all fluid particles had died. Pls check it when you have time, thanks again!
04-11-2024, 09:05 AM (This post was last modified: 04-11-2024, 09:05 AM by josemendez.)
(01-11-2024, 07:01 AM)spikebor Wrote: Hi, thanks for the reply. But as I just test, no need to use script, you can test by change the speed to 50, wait a few secs, then 0, by changing value in the inspector. the foam particles will stay frozen in place after all the fluid particles die out. I've test this with various foam's atmospheric drag value from 0, 0.1, 0.5, 1 all same result. So, it's hard to say it is not independent on the emitter.speed, or I may say fluid particle count. As the frozen effect only happens when all fluid particles had died. Pls check it when you have time, thanks again!
Hi Spikebor,
I could reproduce this issue when using the Compute backend and having foam lifetime longer than fluid lifetime. The Burst backend is not affected. This is a bug, since the system isn't designed to work that way.
Replace Obi/Scripts/Common/Backends/Compute/Solver/ComputeSolverImpl.cs with the one attached to this post, that should fix the problem.
(04-11-2024, 09:05 AM)josemendez Wrote: Hi Spikebor,
I could reproduce this issue when using the Compute backend and having foam lifetime longer than fluid lifetime. The Burst backend is not affected. This is a bug, since the system isn't designed to work that way.
Replace Obi/Scripts/Common/Backends/Compute/Solver/ComputeSolverImpl.cs with the one attached to this post, that should fix the problem.
Let me know if I can help in any way,
kind regards
Hi, can confirm this fixed the problem, thank you!