more tooling
This commit is contained in:
@@ -10,6 +10,7 @@ SAMPLER3D(s_ditherSampler, 1);
|
||||
SAMPLER2D(s_rampSampler, 2);
|
||||
uniform vec4 u_time;
|
||||
uniform vec4 u_testColor;
|
||||
uniform vec4 u_texInfo;
|
||||
|
||||
float calcBrightness(vec3 lightPos, vec3 vertPos, vec3 normal)
|
||||
{
|
||||
@@ -28,27 +29,14 @@ vec3 desaturate(vec3 color)
|
||||
return vec3_splat(dot(color, vec3(0.33, 0.34, 0.33)));
|
||||
}
|
||||
|
||||
void main()
|
||||
float dither(float brightness, vec2 inputUv)
|
||||
{
|
||||
// setup
|
||||
float globalScale = 6.0;
|
||||
float testRadius = 30.0;
|
||||
float testSpeed = 1.0;
|
||||
vec3 testOffset = vec3(0.0, 0.0, 50.0);
|
||||
float3 lightPos = vec3(sin(u_time.x * testSpeed) * testRadius, 5.0, cos(u_time.x * testSpeed) * testRadius);
|
||||
vec2 inputUv = v_uv0;
|
||||
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||
|
||||
// lighting
|
||||
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
||||
float brightness = lerp(0.5, 0.9, calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal));
|
||||
// float brightness = 0.5;
|
||||
// brightness = lerp(0.2, 1.0, sin(u_time.x) * 0.5 + 0.5);
|
||||
float globalScale = 8.0;
|
||||
|
||||
// constants
|
||||
float dotsPerSide = 2;
|
||||
float xRes = u_texInfo.z;
|
||||
float dotsPerSide = xRes / 16;
|
||||
float dotsTotal = dotsPerSide * dotsPerSide;
|
||||
float xRes = 32;
|
||||
float invXRes = 1 / xRes;
|
||||
float zRes = dotsTotal;
|
||||
float invZRes = 1 / zRes;
|
||||
@@ -70,6 +58,7 @@ void main()
|
||||
// Figuring out how many dots we want
|
||||
float scaleExp = exp2(globalScale);
|
||||
float spacing = freq.y * scaleExp;
|
||||
spacing *= dotsPerSide * 0.125;
|
||||
|
||||
float brightnessSpacingMultiplier = pow(brightnessCurve * 2 + 0.001, -(1 - 0.5));
|
||||
// float brightnessSpacingMultiplier = 1;
|
||||
@@ -87,14 +76,34 @@ void main()
|
||||
|
||||
float pattern = texture3D(s_ditherSampler, vec3(uv, subLayer)).r;
|
||||
|
||||
float contrast = 12 * scaleExp * brightnessSpacingMultiplier * 0.1;
|
||||
float contrast = 8 * scaleExp * brightnessSpacingMultiplier * 0.1;
|
||||
contrast *= pow(freq.y / freq.x, 1.0);
|
||||
float baseVal = lerp(0.5, brightness, saturate(1.05 / (1 + contrast)));
|
||||
float threshold = 1 - brightnessCurve + 0.6;
|
||||
|
||||
vec3 thresholds = threshold.xxx / texColor;
|
||||
// vec3 finalColor = saturate((pattern - thresholds) * contrast + baseVal);
|
||||
vec3 finalColor = saturate((pattern - thresholds) * contrast + baseVal);
|
||||
return saturate((pattern - threshold) * contrast + baseVal);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// setup
|
||||
float testRadius = 30.0;
|
||||
float testSpeed = 1.0;
|
||||
vec3 testOffset = vec3(0.0, 0.0, 50.0);
|
||||
float3 lightPos = vec3(sin(u_time.x * testSpeed) * testRadius, 5.0, cos(u_time.x * testSpeed) * testRadius);
|
||||
vec3 texColor = u_testColor.x > 0.1 ? u_testColor.xyz : texture2D(s_texColor, v_uv0).xyz;
|
||||
|
||||
// lighting
|
||||
// float brightness = calcBrightness(lightPos, v_wpos, v_normal);
|
||||
float brightness = lerp(0.5, 0.9, calcBrightnessDirectional(vec3(0.5, 0.3, 1.0), v_normal));
|
||||
// float brightness = 0.5;
|
||||
// brightness = lerp(0.2, 1.0, sin(u_time.x) * 0.5 + 0.5);
|
||||
|
||||
float r = dither(brightness * texColor.r, v_uv0);
|
||||
float g = dither(brightness * texColor.g, v_uv0);
|
||||
float b = dither(brightness * texColor.b, v_uv0);
|
||||
// float3 finalColor = vec3(r, g, b);
|
||||
float3 finalColor = dither(brightness, v_uv0);
|
||||
gl_FragColor = vec4(finalColor, 1.0);
|
||||
// gl_FragColor = vec4(finalColor * 0.8 + subLayer * 0.2, 1.0);
|
||||
// gl_FragColor = vec4(finalColor * 0.8 + vec3(uv % 1, 0.0) * 0.2, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user