Random Mesh Visibility with Material?

This might be a big ask, but I’m trying to use a custom foliage mesh to represent raindrop splashes (impacts) and I was hoping to randomize the visibility of the drops inside the material. I’ve gotten really close, the only problem is that every once in a while, all of the meshes seem to synchronize and become visible at the same exact time. Not sure why this is happening.

This is my material:

And this is a video showing the random synchronization:

I think you need to add to time.

306314-yelo.gif

Thank you so much! You’re awesome. I’ll Try this when I get home from work.

So this works a lot better than my previous setup, however, I’m having a hard time figuring out how I would control the time that the meshes stay invisible. Usually, I would multiply Time by a constant, but this only seems to increase the speed at which they flicker on and off rather than the duration they remain off. Any idea how to fix that?

What is the ‘off’ part? Is it a frame in the flip book or…?

Yes, make sense.

But I think stop trying to stop the flipbook. Let the flipbook run, and periodically make the material black ( multiply the base color by zero or make the opacity 0 ).

See what I mean, you could do that with a sine wave or something and then also use per instance on the so the sine wave aren’t synced.

Well, using your math without the flipbook got it working save for the fact that I have no control over the off duration or how long it remains black vs yellow. The flip book was simply my hacky way to force it to remain off for a longer duration by having one white frame followed by a whole bunch of black for the off state, but sadly, this causes the previously mentioned synchronization where when it hits that’s white frame, all instances show up at once. I don’t understand why it happens using the per instance random, but that’s the results I get. Your solution solves the random synchronization, but they’re all flickering constantly from on to off (or visible to invisible) and back again in a very short time period. Ideally what I need is for them to flick on for a fraction of a second and then remain off for about 1-3 seconds before coming back on again. So a way to control how long they remain black vs yellow in your example. Does that make sense?

I definitely wasn’t trying to stop the flip book. It’s just looping. But eventually when it gets back to the first frame the synch happens. No idea how to fix that. The problem I foresee with a sine wave is again that the off time and the on time would be equal so it’ll stay off for as long as it stays on. I need a way to make the off last longer. Though I’ll play with the idea when I get home. Previously I was using the same per instance to control everything but there’s a good point that I could use two with different timings. Thanks :wink:

Just use a multiple of per instance to control the frequency of the wave, then they’re all different :slight_smile:

Alright, so after you mentioning to use a Sine wave, I implemented that, but it left me with a little less control over the variation and still didn’t look quite right. Then I remembered a forum post I made a while back for how to do a gapped sine wave and that was the solution. It allows me to make the off period at least double that of the on period which was good enough. I do wish there was a bit more random variation in the flickering because it seems that each instance is given a random value, but it keeps that same value once it’s applied so there’s still repetition, but for my purposes, I’m calling it done. My game is stylized anyway so it works.

Here’s my final material:

And here’s the final result:

Thanks so much for your help ClockworkOcean!

Just fab! :slight_smile: