Context: in a fragment shader, I need the fragment UV coordinate within the particular frame of a spritesheet, in a material that will be reused across multiple spritesheets.
From what I understand, currently I have to do it the hard way by passing uniforms to the shader to know how many rows and columns the spritesheet has, and what is the coordinate of the current frame, in oder to compute the frame’s UV from the spritesheet texture UV. If the spritesheet happens to have separations and borders, it becomes even more complex.
It would be so convenient to just have a “FUV” (Frame UV) built-in instead.
Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Laptop GPU (NVIDIA; 32.0.15.5597) - Intel(R) Core(TM) i9-14900HX (32 Threads)
You should probably post feature requests on the Godot GitHub page .
1 Like
Thanks for the suggestion, I just did it:
opened 11:47AM - 16 Feb 25 UTC
### Describe the project you are working on
A basic 2D game.
### Describe the … problem or limitation you are having in your project
Context: in a fragment shader, I need the fragment UV coordinate within the particular frame of a spritesheet, in a material that will be reused across multiple spritesheets.
From what I understand, currently I have to do it the hard way by passing uniforms to the shader to know how many rows and columns the spritesheet has, and what is the coordinate of the current frame, in oder to compute the frame’s UV from the spritesheet texture UV. If the spritesheet happens to have separations and borders, it becomes even more complex.
### Describe the feature / enhancement and how it helps to overcome the problem or limitation
It would be so convenient to just have a “FUV” (Frame UV) built-in instead.
<img width="1166" alt="Image" src="https://github.com/user-attachments/assets/b48d4583-bb3c-4d1b-9f10-8cc51696a558" />
### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
exemple fragment shader code:
`COLOR = vec4( FUV, 1.0, 1.0 )`
### If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes it does by coding a spritesheet sampler, which can be annoying depending on the complexity of the spritesheet (borders, margins..)
### Is there a reason why this should be core and not an add-on in the asset library?
It is a benefit for any game using spritesheets and custom shaders, which is quite common.