Frame Syncing Problem

Hello!

im a rather new to game creation, but ive been trying to create a fire texture that utilizes an animated texture to do some cool effects. HOWEVER! with multiple instances of the object on screen, it become painfully obvious that all of the instances are on the same frame, making the effect look rather unconvincing. does anyone have any leads???

below are a video and photos.

the problem is better described in video!: Video Prompt

a photo of my shader, I do use an animated texture!

I really appreciate the consideration and help!

Pass a random uniform int to the shader and offset the frame by it.

My apologies, im not sure how to do that, is that a node in the shader editor…? Or should i hard code that myself?

In visual shaders, uniforms are created with parameter nodes. In your case that would be IntParameter node.

1 Like

I have no idea what I’m doing. So I figure you wanted me to use the sampler2D to set some sort of data? however, instead of taking a integer that can be randomized it allows me to add a texture parameter??? I have not one clue how to access the frame data in order to change the frame for each instance.

thank you for your consideration!

I don’t think the AnimatedTexture resource type will work to solve your problem, the resource is shared between all instances of this shader and isn’t affected per-instance. You may have to convert it into a sprite sheet where you can specify a frame number by dividing and adding to the UV coordinates.

As an example a 2x2 sprite sheet would use UV’s for these frames

  1. 0.0, 0.0 to 0.5, 0.5
  2. 0.5, 0.0 to 1.0, 0.5
  3. 0.0, 0.5 to 0.5, 1.0
  4. 0.5, 0.5 to 1.0, 1.0

Which can be achieved by dividing your UV by 2 and adding 0.5 for each x and y frame coordinate, then you can create an instance uniform to specify the random frame offset for each flame. Maybe there is a tutorial for sprite sheet animations in shader graphs out there.

@gertkeno is right. You can’t do it from within the shader if your using AnimatedTexture. So either use an atlas texture or if your torch is an instantiated scene, you can make the material and texture resources local to scene, and randomize texture’s current_frame on instantiation. If you instantiate at different times this will happen automatically.