#iChannel0 "file://./Textures/pixelart.png" //#iChannel0::MinFilter "LinearMipMapLinear" #iChannel0::WrapMode "Mirror" // this work is licenced under a CC0 1.0 Universal License // https://creativecommons.org/publicdomain/zero/1.0/ // https://www.shadertoy.com/view/MllBWf #define PI 3.14159265359 #define rot(a) mat2(cos(a+PI*vec4(0,1.5,0.5,0))) vec4 myTexture(vec2 uv) { vec2 res = iChannelResolution[0].xy; uv = uv*res + 0.5; // tweak fractionnal value of the texture coordinate vec2 fl = floor(uv); vec2 fr = fract(uv); vec2 aa = fwidth(uv)*0.75; fr = smoothstep( vec2(0.5)-aa, vec2(0.5)+aa, fr); uv = (fl+fr-0.5) / res; return texture(iChannel0, uv); } vec4 nearest(vec2 uv) { uv *= iChannelResolution[0].xy; uv = floor(uv)+0.5; uv /= iChannelResolution[0].xy; return textureLod(iChannel0, uv, 0.0); } vec4 mipmap(vec2 uv) { return texture(iChannel0, uv); } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = (fragCoord.xy - iResolution.xy*0.5) / iResolution.x; vec2 prevUV = uv; uv *= rot(iTime*0.2); uv.x *= iChannelResolution[0].y / iChannelResolution[0].x; uv *= exp2(iMouse.x*0.01); fragColor = myTexture(uv).rgba; if (prevUV.x < -0.25) fragColor = nearest(uv); if (prevUV.x > 0.25) fragColor = mipmap(uv); if (abs(prevUV.x+0.25) < 0.005) fragColor.rgb = vec3(0); if (abs(prevUV.x-0.25) < 0.005) fragColor.rgb = vec3(0); }