Does the shader have a built-in function to get the texture size? I’m trying to draw a circle on a texture, the texture is in sprite.
I tried it in different ways, sometimes it turns out to be a stretched circle, sometimes it’s not visible at all, sometimes only part of the circle is visible.
Assuming you’re using the latest versions of GLSL, you can get texture size with the “textureSize()”
Example code here…
uniform sampler2D myTexture; // Uniform for the texture
void main() {
//Note: if you don’t specify a LOD, glsl will default to 0 automatically
ivec2 texSize = textureSize(myTexture, 0); // Get size of the texture at LOD 0
int width = texSize.x; // Width of the texture
int height = texSize.y; // Height of the texture
//variable declarations above to demonstrate use of `width` and `height` for your calculations