Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Obi Fluid flicker after setting particles life to 0
#1
Hi, when I set a particles life to 0 fluid flickers is there any way to prevent this? 
Here is the video recording.

Also how can i make sure fluid is renderer in only 1 camera? Because currently I have 2 cameras in the scene 1 for 3d the other for ui fluid gets rendered in both.
I sort of fixed this by rotating the ui camera 90 degrees but I would like to know if there is another way. 

Thanks in advance.


Attached Files Thumbnail(s)
   
Reply
#2
(20-07-2022, 12:52 PM)CumaliSAH1N Wrote: Hi, when I set a particles life to 0 fluid flickers is there any way to prevent this? 
Here is the video recording.

Setting a particle's life to 0 will kill it, and re-emit it immediately. It might be emitted at a different place though, and this will cause flickering. May I ask what your use case is?

(20-07-2022, 12:52 PM)CumaliSAH1N Wrote: Also how can i make sure fluid is renderer in only 1 camera? Because currently I have 2 cameras in the scene 1 for 3d the other for ui fluid gets rendered in both.
I sort of fixed this by rotating the ui camera 90 degrees but I would like to know if there is another way. 

If you're using the built-in pipeline, fluid will only be rendered from cameras that have a ObiFluidRenderer component. If you're using URP, use different renderers for each camera.
[/quote]
Reply
#3
(20-07-2022, 02:27 PM)josemendez Wrote: Setting a particle's life to 0 will kill it, and re-emit it immediately. It might be emitted at a different place though, and this will cause flickering. May I ask what your use case is?


If you're using the built-in pipeline, fluid will only be rendered from cameras that have a ObiFluidRenderer component. If you're using URP, use different renderers for each camera.

I have a character which is filled with fluid, when an arrow hits it the particles in close proximity of that arrow will be killed, and level will be finished when there are no active particles in the scene.
Also I think particles I kill don't re-emit.
Reply
#4
(20-07-2022, 02:51 PM)CumaliSAH1N Wrote: I have a character which is filled with fluid, when an arrow hits it the particles in close proximity of that arrow will be killed, and level will be finished when there are no active particles in the scene.

How are you killing those particles? could you share the code you're using?

(20-07-2022, 02:51 PM)CumaliSAH1N Wrote: Also I think particles I kill don't re-emit.

Yes they do, like in any particle system. The only way to stop dead particles from re-emitting is to set the emitter's "min pool size" to 1, that way particles will begin respawning only once all have been killed. Maybe this is what you already have?
Reply
#5
(20-07-2022, 03:00 PM)josemendez Wrote: How are you killing those particles? could you share the code you're using?


Yes they do, like in any particle system. The only way to stop dead particles from re-emitting is to set the emitter's "min pool size" to 1, that way particles will begin respawning only once all have been killed. Maybe this is what you already have?

This is the code I'm using to kill the particles (some of the code is omitted for clarity).

All of my emitter's minpoolsize is set to 1

Code:
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);

Vector3 position = hitPointTransform.position;
QueryShape query = new QueryShape(QueryShape.QueryType.Sphere, Vector3.zero, Vector3.zero, 0,
    fluidCastRadius, filter);
AffineTransform affineTransform = new AffineTransform(position, Quaternion.identity, Vector4.one);

QueryResult[] results = obiSolver.SpatialQuery(query, affineTransform);
int length = results.Length;

for (int i = 0; i < length; i++)
{
    int particleIndex = obiSolver.simplices[results[i].simplexIndex];
    ObiSolver.ParticleInActor actor = obiSolver.particleToActor[particleIndex];
    ObiEmitter emitter = actor.actor as ObiEmitter;

    emitter.life[actor.indexInActor] = 0.0f;
}
Reply
#6
(20-07-2022, 03:06 PM)CumaliSAH1N Wrote: This is the code I'm using to kill the particles (some of the code is omitted for clarity).

All of my emitter's minpoolsize is set to 1

Code:
int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);

Vector3 position = hitPointTransform.position;
QueryShape query = new QueryShape(QueryShape.QueryType.Sphere, Vector3.zero, Vector3.zero, 0,
    fluidCastRadius, filter);
AffineTransform affineTransform = new AffineTransform(position, Quaternion.identity, Vector4.one);

QueryResult[] results = obiSolver.SpatialQuery(query, affineTransform);
int length = results.Length;

for (int i = 0; i < length; i++)
{
    int particleIndex = obiSolver.simplices[results[i].simplexIndex];
    ObiSolver.ParticleInActor actor = obiSolver.particleToActor[particleIndex];
    ObiEmitter emitter = actor.actor as ObiEmitter;

    emitter.life[actor.indexInActor] = 0.0f;
}

Hi,

Your code looks fine to me. Will try to reproduce this issue and get back to you.
Reply
#7
Hi again,

Tried your code on one of the sample scenes (whenever I press "Space" in the keyboard, the spatial query is performed), but I'm unable to reproduce any flickering. Killed particles are gone for good, until re-emitted. Here's a video of the test:



Would it be possible for you to share either your project or a simplified repro scene to support(at)virtualmethodstudio.com so that I can take a closer look? thanks!
Reply
#8
Hi, thanks for your time. Unfortunately I'm not permitted to share the project with you but I'll try to send you a simplified version of it tomorrow.
Reply