Created
June 3, 2026 01:36
-
-
Save c64cosmin/b531ba220d3c7d13a5c5c513d5d8ec41 to your computer and use it in GitHub Desktop.
gdshader for rotated pixelart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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