This commit is contained in:
Joshua Ashton 2023-04-08 01:09:03 +01:00
parent d2c0e88105
commit 9b86d84eaf
1 changed files with 73 additions and 12 deletions

View File

@ -47,11 +47,48 @@ float gold_noise(vec2 xy, float seed)
return fract(tan(distance(xy*PHI, xy)*seed)*xy.x);
}
float positive_mod(float flX, float flPeriod)
{
float flVal = mod( flX, flPeriod );
return ( flVal < 0 ) ? flVal + flPeriod : abs( flVal ); // fabs fixes -0
}
vec3 hsv_to_rgb(vec3 hsv)
{
if ( abs( hsv.y ) < 0.0000001 )
{
return vec3( hsv.z ) ;
}
float flHue = positive_mod( hsv.x, 1.f );
flHue *= 6.f;
int i = int(floor(flHue)); // integer part
float f = fract(flHue); // fractional part
float p = hsv.z * ( 1.f - hsv.y );
float q = hsv.z * ( 1.f - hsv.y * f );
float t = hsv.z * ( 1.f - hsv.y * ( 1.f - f ) );
switch(i)
{
case 0: return vec3( hsv.z, t, p ); break;
case 1: return vec3( q, hsv.z, p ); break;
case 2: return vec3( p, hsv.z, t ); break;
case 3: return vec3( p, q, hsv.z ); break;
case 4: return vec3( t, p, hsv.z ); break;
case 5: return vec3( hsv.z, p, q ); break;
}
return vec3( 0 );
}
void main()
{
outColor = vec4(0.0, 0.0, 0.0, 1.0);
int nextTest = 0;
if (test == 0)
if (test == nextTest++)
{
const vec3 start = vec3(0.0);
const vec3 end = vec3(targetNits);
@ -60,7 +97,7 @@ void main()
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == 1)
else if (test == nextTest++)
{
const vec3 start = vec3(0.0);
const vec3 end = vec3(targetNits);
@ -75,7 +112,31 @@ void main()
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == 2)
else if (test == nextTest++)
{
const vec3 start = vec3(0.0);
const vec3 end = vec3(hsv_to_rgb(vec3(coords.y, 1.0, 1.0)) * targetNits);
vec3 color = mix(start, end, coords.x);
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == nextTest++)
{
const vec3 start = vec3(0.0);
const vec3 end = vec3(targetNits);
vec3 color = mix(start, end, coords.x);
if (coords.y < 1.0 / 3.0)
color.gb = vec2(0.0);
else if (coords.y < 2.0 / 3.0)
color.rb = vec2(0.0);
else
color.rg = vec2(0.0);
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == nextTest++)
{
vec3 color = vec3(0.0);
if ((int(gl_FragCoord.x) & 1) == 0)
@ -83,7 +144,7 @@ void main()
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == 3)
else if (test == nextTest++)
{
vec3 color = vec3(0.0);
if ((int(gl_FragCoord.y) & 1) == 0)
@ -91,7 +152,7 @@ void main()
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == 4)
else if (test == nextTest++)
{
vec3 color = vec3(0.0);
if ((int(gl_FragCoord.x) & 1) == 0 && (int(gl_FragCoord.y) & 1) == 0)
@ -99,37 +160,37 @@ void main()
outColor = vec4(nitsToPq(color), 1.0);
}
else if (test == 5)
else if (test == nextTest++)
{
const vec3 barycentrics = vec3(1.0 - coords.x - coords.y, coords.x, coords.y) * targetNits;
outColor = vec4(nitsToPq(barycentrics), 1.0);
}
else if (test == 6)
else if (test == nextTest++)
{
float value = ((frame & 1) == 0) ? targetNits : 0.0;
outColor = vec4(nitsToPq(vec3(value)), 1.0);
}
else if (test == 7)
else if (test == nextTest++)
{
float value = ((frame & 1) == 0) ? targetNits : 0.0;
outColor = vec4(nitsToPq(vec3(value, 0, 0)), 1.0);
}
else if (test == 8)
else if (test == nextTest++)
{
float value = ((frame & 1) == 0) ? targetNits : 0.0;
outColor = vec4(nitsToPq(vec3(0, value, 0)), 1.0);
}
else if (test == 9)
else if (test == nextTest++)
{
float value = ((frame & 1) == 0) ? targetNits : 0.0;
outColor = vec4(nitsToPq(vec3(0, 0, value)), 1.0);
}
else if (test == 10)
else if (test == nextTest++)
{
const float seed = fract(time);
@ -137,7 +198,7 @@ void main()
outColor = vec4(nitsToPq(value), 1.0);
}
else if (test == 11)
else if (test == nextTest++)
{
const float seed = fract(time);