diff --git a/TODO.txt b/TODO.txt index b8c73b0..30718f4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,5 @@ TODO: -Replace fwidth with a uniform or something - Bloom comparison: WebGPU vs REGL Why are they different? Create a project that tests them side-by-side diff --git a/shaders/glsl/rainPass.frag.glsl b/shaders/glsl/rainPass.frag.glsl index 8141206..501c3cf 100644 --- a/shaders/glsl/rainPass.frag.glsl +++ b/shaders/glsl/rainPass.frag.glsl @@ -117,7 +117,7 @@ vec2 getSymbol(vec2 uv, float index) { // MSDF: calculate brightness of fragment based on distance to shape vec2 symbol; { - vec2 unitRange = vec2(msdfPxRange) / glyphMSDFSize; + vec2 unitRange = vec2(msdfPxRange) / (glyphMSDFSize * 1000.); // Not sure why this x1000 softening is necessary vec2 screenTexSize = vec2(1.0) / fwidth(uv); float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0); @@ -127,7 +127,7 @@ vec2 getSymbol(vec2 uv, float index) { } if (isolateGlint) { - vec2 unitRange = vec2(msdfPxRange) / glintMSDFSize; + vec2 unitRange = vec2(msdfPxRange) / (glintMSDFSize * 1000.); // Not sure why this x1000 softening is necessary vec2 screenTexSize = vec2(1.0) / fwidth(uv); float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0); @@ -167,24 +167,6 @@ void main() { ) * symbol.r, 1. ); - - uv = fract(uv * vec2(numColumns, numRows)); - uv -= 0.5; - uv *= clamp(1. - glyphEdgeCrop, 0., 1.); - if (length(uv) > 0.25) { - discard; - } - uv += 0.5; - - float goal = fwidth(uv - 0.5).x; - float computed = 1.0; - float magnifier = 50.0; - - if (uv.x <= 0.5) { - gl_FragColor = vec4(vec3(goal * magnifier), 1.0); - } else { - gl_FragColor = vec4(vec3(computed * magnifier), 1.0); - } } else { gl_FragColor = vec4(brightness.rg * symbol.r, brightness.b * symbol.g, 0.); } diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index 028dead..c28d1a9 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -507,7 +507,7 @@ fn getSymbol(cellUV : vec2, index : i32) -> vec2 { // var sigDist = median3(dist) - 0.5; // symbol.r = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0); - var unitRange = vec2(config.msdfPxRange) / vec2(textureDimensions(glyphMSDFTexture)); + var unitRange = vec2(config.msdfPxRange) / (vec2(textureDimensions(glyphMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary var screenTexSize = vec2(1.0) / fwidth(uv); var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0); @@ -521,7 +521,7 @@ fn getSymbol(cellUV : vec2, index : i32) -> vec2 { // var sigDist = median3(dist) - 0.5; // symbol.g = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0); - var unitRange = vec2(config.msdfPxRange) / vec2(textureDimensions(glintMSDFTexture)); + var unitRange = vec2(config.msdfPxRange) / (vec2(textureDimensions(glintMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary var screenTexSize = vec2(1.0) / fwidth(uv); var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);