Custom Time Index Niagara on value change?

Hello!

I have created a rough function here in a Niagara Script Module. The system spawns 10 particles total, but here, this function uses an int32 input, and any of the particle ID count that is higher than the int32 input is hidden using this parameter, whether it be an erode or just an opacity.

Essentially its just a mask for particles with an ID count higher than the input number.

The problem I am having is that I’m not really sure how to approach creating a time index from when each particle is “Unmasked” or when the input number is increased from 1 to 2 to 3 etc, and instead of the value going from 0 - 1 opacity instantly, it uses a time index where i can use it to control a curve, so the particles have a smooth transition.

Here is a screenshot of what my basic little module consists of. I would really appreciate any insight on how I could approach this. Thanks!

EDIT: To clarify, the int32 input will go linearly, from 1-10, and I would like each particle that is slowly added by 1, to be interpolated from 0 opacity to full opacity, instead of it being just an instant POP-IN.

You don’t need ID which would require Persistent IDs depending on your use case. Instead you can just use Exec Index as long as it’s under 65 particles or uses CPU simulation. If you have over 64 particles and use GPU simulation, change Exec Index to UniqueID (tiny bit more expensive) instead:

image

Edit: I forgot about this before capturing the video. If you are using this to control the color alpha (opacity), preferably clamp the value within [0, 1]:

image

1 Like

This looks really good! This is really close I think.

The only problem I have is that the value I’m using currently is an Erode and the value for opacity is -1 to 1, and im not totally sure how to normalize this.

Also, i would like to have it be on input, rather than a time based increase. So when the number manually changes from 1 to 2 for example, how could i go about creating a smooth lerp between that?

You can use the “Remap” dynamic input to modify the output of the whole math operations from [0,1] to [-1,1].

1 Like

Yes this worked, thank you.

But still, using return exec index essentially is giving me the same results as I had before. I can see that increasing the value in decimals upward can cause the smooth increase, but my input value is coming from a blueprint, and the value is always whole numbers 1-10, so I need a way to smooth between 1-2, 2-3, 3-4, 4-5, 5-6, 6-7, 7-8, 8-9, 9-10 automatically each time the value is increased.

Technically this can be achieved in Niagara with a trick which lerps between the previous frame value and the target value with a very small lerp alpha value during the Update stage, but I think this is not really justifiable, given that it would be much more straightforward to have the value transitioned smoothly in BP in the first place.

1 Like

Unfortunately, I am unable to have it changed in blueprint for it to be a smooth increase. And it also seems that doing this process in BP would be just as difficult as it would be in Niagara, no?

I’ve been trying to figure this out for a few months now, and It just has been a struggle for me.

I appreciate you helping. It seems this is way too difficult for me to create in Niagara.

I actually just figured it out. I’m surprised I ended up coming across this. I have another script that’s used for fading out on deactivation, but I ended up just switching everything over to accompany the Particle ID and the int32 input. Here are some screenshots of the Niagara Scratchpad.


And here is the interior of the Node when placed inside the Niagara system. It allows for a custom time duration for how long you want the fade in/out to be.


And finally, I plugged the output parameter, which is the time frame, into the curve index for the “Erode Dynamic Parameter”

And well, it works. I feel like its just black magic. The solution was just sitting under my nose, in another custom parameter I had already made.

ezgif-1-beddd334e6

The system spawns with a total of 10 particles, but only shows ones specified by the int32 input, which is exactly as I wanted it to do. And they also smoothly fade in and out.

EDIT : The final example is cut short because the GIF file size requirement is pretty small. You get the idea, I increase the parameter first by one, then by two and then two again.

3 Likes