/* RetroFX palette reduction from MariENB (C)2012-2021 Marisa Kirisame */ vec3 rgb2hsv( vec3 c ) { vec4 K = vec4(0.0,-1.0/3.0,2.0/3.0,-1.0); vec4 p = (c.g= 1.0 ) res.r += paldither; if ( res.g >= 1.0 ) res.g += paldither; if ( res.b >= 1.0 ) res.b += paldither; res.rgb += paldither*dither8[int(coord.x*sfact.x)%8+int(coord.y*sfact.y)%8*8]-0.5*paldither; vec3 lc = clamp(floor(res.rgb*64),0,63); ivec2 lcoord = ivec2(lc.r,lc.g+lc.b*64); lcoord.x += 64*palnum; res.rgb = texelFetch(PalLUTTexture,lcoord,0).rgb; FragColor = res; }