Different bc1 565L tune (better quality), Make 888S work with bc1 correclty

This commit is contained in:
mittorn 2024-11-12 01:32:18 +03:00
parent 5bcc122051
commit 55e791419e

View file

@ -1,6 +1,6 @@
#include "glsl_shared.h"
#define CONV_MODE CONV_565L
#define CONV_MODE CONV_888S
#define LCONVERT(cmul, x) (log(cmul*x+1.0)/log(cmul+1.0))
#define LCONVERT2(cmul,mul,off,x) (LCONVERT(cmul,abs(x))*sign(x)*(mul) + off)
@ -53,23 +53,23 @@ vec3 conv_load(vec3 color)
#elif CONV_MODE == CONV_565L
float uconv(float x)
{
return LCONVERT(1.5,(clamp(abs(x),0.2,1)-0.2)/0.8)*sign(x)*31.75/63.0 + 31.0/63.0;
return LCONVERT(0.125,(clamp(abs(x),0.1,0.9)-0.1)/0.8)*sign(x)*31.75/63.0 + 31.0/63.0;
}
float uconv2(float x)
{
return LCONVERT(3,(clamp(abs(x),0.1,1)-0.1)/0.9)*sign(x)*15.75/31.0 + 15.0/31.0;
return LCONVERT(0.25,(clamp(abs(x),0.1,0.7)-0.1)/0.6)*sign(x)*15.75/31.0 + 15.0/31.0;
}
float invuconv(float x)
{
if(abs(x - 31.0/63.0) < 0.01 )
return 0;
return (LICONVERT(1.5,abs(x-31.0/63.0)/(31.75/63.0))*0.8+0.2)*sign(x-31.0/63.0);
return (LICONVERT(0.125,abs(x-31.0/63.0)/(31.75/63.0))*0.8+0.1)*sign(x-31.0/63.0);
}
float invuconv2(float x)
{
if(abs(x - 15.0/31.0) < 0.01 )
return 0;
return (LICONVERT(3,abs(x-15.0/31.0)/(15.75/31.0))*0.9+0.1)*sign(x-15.0/31.0);
return (LICONVERT(0.25,abs(x-15.0/31.0)/(15.75/31.0))*0.6+0.1)*sign(x-15.0/31.0);
}
vec4 conv_store(vec3 vals)
@ -84,14 +84,14 @@ vec3 conv_load(vec3 color)
#elif CONV_MODE == CONV_888S
float uconv(float x)
{
float cv = LCONVERT(8,abs(x))*sign(x);
return (((cv / 2.1 + float(cv < 0.0)) - 0.5) * 1.1)+ 0.5;
float cv = LCONVERT(32,(clamp(abs(x),0.1,0.9)-0.1)/0.9)*sign(x);
return (cv / 2 + float(cv < 0.0));
}
float invuconv(float x)
{
float s1 = (x - 0.5) / 1.1 + 0.5;
float icv = (float(s1 > 0.5)*(s1-1) + float(s1 <= 0.5) * s1)*1.9;
return LICONVERT(8,abs(icv))*sign(icv);
float s1 = x;//x;//(x - 0.5) / 1.1 + 0.5;
float icv = (float(s1 > 0.5)*(s1 - 1) + float(s1 <= 0.5) * s1)*2;
return (LICONVERT(32,abs(icv))*0.8+0.1)*sign(icv);
}
vec4 conv_store(vec3 vals)
{