Keep old naive dither as an option.

This commit is contained in:
Marisa the Magician 2023-03-04 18:19:38 +01:00
commit e8b7b1c29f
10 changed files with 145 additions and 36 deletions

View file

@ -1,6 +1,6 @@
/*
RetroFX palette reduction from MariENB
(C)2012-2022 Marisa the Magician
(C)2012-2023 Marisa the Magician
*/
vec3 rgb2hsv( vec3 c )
{
@ -26,12 +26,12 @@ void main()
hsv.y = clamp(hsv.y*palsat,0.,1.);
hsv.z = pow(max(hsv.z,0.),palpow);
res.rgb = hsv2rgb(hsv);
ivec2 dcoord = ivec2(int(coord.x*sfact.x)%dsize,int(coord.y*sfact.y)%dsize+doffset);
float cstep = float(paldepth);
float cdiv = 1./cstep;
vec3 cl = floor(res.rgb*cstep)*cdiv;
vec3 ch = ceil(res.rgb*cstep)*cdiv;
vec3 cf = fract(res.rgb*cstep);
ivec2 dcoord = ivec2(int(coord.x*sfact.x)%dsize,int(coord.y*sfact.y)%dsize+doffset);
float dth = texelFetch(DitherTexture,dcoord,0).x*.9375+.03125;
vec3 thr = vec3(step(dth,cf.r),step(dth,cf.g),step(dth,cf.b));
res.rgb = mix(cl,ch,thr);