(I would like to say right away that I personally am not a programmer and may not be so competent in what is said below.)

My friend and I are creating a small "game" engine. We have a task with the implementation of some VFX, which assume that the created 3d model with a certain Uv-map + sprite texture will be involved.

enter image description here enter image description here

(A couple of photos that will help you understand what we are talking about)

In order to make the scrolling animation of our sprite texture on a 3D model (VFX), we decided to move our UV map using attributes during initialization, and yes, it worked, but we had a problem supporting shaders. After trying to figure out the problem a little bit, we came to the conclusion that: Shaders are working with each pixel individually, the shader uses 2 numbers per 1 pixel, and an entire array is transmitted through attributes (as I understand it: work happens with each pixel in any effect, and each effect requires a UV-map and changes his as he needs it) After trying to continue to understand the problem even more, we thought that in general, the transmission of UV-maps does not occur in real time, and that in fact UV-maps in shaders are constants. As a result, it still does not allow us to use shaders correctly.

I know that such technologies have long been implemented in engines such as UE or Unity, but we could not find information on how we should do this in our engine, it is possible that we generally made a mistake in our approach to implementing this system. Could you tell us how to solve this problem?

  • 1
    \$\begingroup\$ It's not clear to me what problem you need help solving. It looks like you have what are called flipbook textures, where one image contains several frames to animate the texture over time. These are usually implemented by setting a uniform variable on the shader to a value indicating which frame to draw in this pass, so the shader code can use math to transform the input UVs into that part of the texture. When you have many instances drawn in one go, this can be done as one mesh, passing the frame ID as a vertex colour channel, or with instanced rendering, with a buffer of frame IDs. \$\endgroup\$
    – DMGregory
    Mar 10 at 11:51


You must log in to answer this question.

Browse other questions tagged .