VFX - setting Tex Index does not work

Hello there, I have this simple graph with 1x2 atlas and trying to set a atlas index in Initialization context but it always renders first frame only.

Setting Tex Index to zero shows red color (first frame):

Setting Tex Index to 1 (or whatever other number) also shows only first frame (red) instead of second one (green):

Hi @sergiusz308 ,
Did you try in update? I think it should work OK. Don’t use initialize context which I presume is above your empty update.

5136578--508316--textureindex.png

Just a thought - If you are going to do flip book plane with alpha in front of a gun, maybe VFX Graph is not the ideal tool for this as it can do so much more :slight_smile:

1 Like

@Olmi you mean add “set tex index” in the update? I want it to be randomized - as @JulienF_Unity suggested in other post to put it in the init context - I did it and it seems not being taken into account whatsoever.

If I’d have a single value maybe putting it in the update would do the trick but I want it to be initialized to random value and then play using that value. There’s even a block called “Set Tex Index Random” and it does not work either :frowning:

About using VFX being for much more - I am looking at it from code/assets mgmt point of view: it’s easier to deal with a single particle system than multiple ones. Here it’s a simple muzzle flash for a gun, but for other weapons we can have much more elaborated effects.

Well can’t you set the random value from outside, C#? You could use some exposed parameter and set a random value there. Or just set random int value inside VFX Graph.

I’m not sure if I understand correctly. You want to set a single frame or a start frame. What do you mean with play? Play the flipbook sequence from that point forward? You would need to limit the range somehow if you want to play a region of your flipbook, like from frame 4-10, for example, so that it would wrap around.

I got two frames playbook and at each burst I just want to show a single frame, selected randomly. So in the example above it’s a simple red and green rectangle - at each burst I want it to be red or green, picked randomly and displayed throughout the particle life.

Well, I think you can then just set the index through exposed parameter, if random doesn’t function inside VFX Graph for some reason.

1 Like

@Olmi - I will try that, but it looks like a bug.

Maybe that’s the same issue as with ShaderGraph with uneven flipbook grids.

Hey @sergiusz308 , I just tried it and cannot reproduce your issue.
In your example, did you per chance spawn the particle once and after that tried to change the value in Initialize?

If so, Initialize, much like Start() in C#, gets called once at the birth of the particle, so after the particle is born, changing any value in Initialize will not update anything.

If you recompile the graph or spawn new particles, you should see the updated change.
If you’d like to assign a new tex index after the particle has already been born, you can do so as @Olmi suggested in Update or even in Output.

And if you wanted to set a random value that does not change, you can use a Random Number with the constant checkbox selected. Here’s an example for both:

Hope this helps!
Please let me know if I am misunderstanding the issue.

5154848--510695--2019-11-08_17-03-43.gif

2 Likes

@VladVNeykov Thanks for looking into this.

Anyway, I end up with this setup:

5175749--513692--upload_2019-11-14_18-52-57.png

Upon clicking “play” it gives random value for the tex index.

5175749--513680--upload_2019-11-14_18-47-1.png
5175749--513683--upload_2019-11-14_18-47-15.png
5175749--513686--upload_2019-11-14_18-47-40.png

1 Like