Skip to content

Instantly share code, notes, and snippets.

@c64cosmin
Created June 3, 2026 01:36
Show Gist options
  • Select an option

  • Save c64cosmin/b531ba220d3c7d13a5c5c513d5d8ec41 to your computer and use it in GitHub Desktop.

Select an option

Save c64cosmin/b531ba220d3c7d13a5c5c513d5d8ec41 to your computer and use it in GitHub Desktop.
gdshader for rotated pixelart
shader_type canvas_item;
render_mode blend_mix;
uniform float global_rotation = 0.0;
mat2 getRotationMatrix(float angle){
float r = radians(angle);
float cs = cos(r);
float sn = sin(r);
return mat2(
vec2(cs ,-sn),
vec2(sn , cs)
);
}
vec2 getPixelatedUV(vec2 inUV, vec2 texel, float angle){
mat2 rotCW = getRotationMatrix(-angle);
mat2 rotCCW = getRotationMatrix(angle);
return rotCW*floor((rotCCW*inUV)/texel)*texel;
}
void fragment(){
vec2 newUV = getPixelatedUV(UV, TEXTURE_PIXEL_SIZE, global_rotation);
COLOR = texture(TEXTURE, newUV);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment