Less naive palette shader.

This commit is contained in:
Marisa the Magician 2023-02-26 16:31:20 +01:00
commit a0521259a7
14 changed files with 57 additions and 7 deletions

View file

@ -26,9 +26,16 @@ 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)%8,int(coord.y*sfact.y)%8);
res.rgb += paldither*texelFetch(DitherTexture,dcoord,0).x-.5*paldither;
vec3 lc = clamp(floor(res.rgb*64),0,63);
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);
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;