mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Softening the MSDF, ready to move on
This commit is contained in:
2
TODO.txt
2
TODO.txt
@@ -1,7 +1,5 @@
|
|||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
Replace fwidth with a uniform or something
|
|
||||||
|
|
||||||
Bloom comparison: WebGPU vs REGL
|
Bloom comparison: WebGPU vs REGL
|
||||||
Why are they different?
|
Why are they different?
|
||||||
Create a project that tests them side-by-side
|
Create a project that tests them side-by-side
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ vec2 getSymbol(vec2 uv, float index) {
|
|||||||
// MSDF: calculate brightness of fragment based on distance to shape
|
// MSDF: calculate brightness of fragment based on distance to shape
|
||||||
vec2 symbol;
|
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);
|
vec2 screenTexSize = vec2(1.0) / fwidth(uv);
|
||||||
float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ vec2 getSymbol(vec2 uv, float index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isolateGlint) {
|
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);
|
vec2 screenTexSize = vec2(1.0) / fwidth(uv);
|
||||||
float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||||
|
|
||||||
@@ -167,24 +167,6 @@ void main() {
|
|||||||
) * symbol.r,
|
) * symbol.r,
|
||||||
1.
|
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 {
|
} else {
|
||||||
gl_FragColor = vec4(brightness.rg * symbol.r, brightness.b * symbol.g, 0.);
|
gl_FragColor = vec4(brightness.rg * symbol.r, brightness.b * symbol.g, 0.);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ fn getSymbol(cellUV : vec2<f32>, index : i32) -> vec2<f32> {
|
|||||||
// var sigDist = median3(dist) - 0.5;
|
// var sigDist = median3(dist) - 0.5;
|
||||||
// symbol.r = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
// symbol.r = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
||||||
|
|
||||||
var unitRange = vec2<f32>(config.msdfPxRange) / vec2<f32>(textureDimensions(glyphMSDFTexture));
|
var unitRange = vec2<f32>(config.msdfPxRange) / (vec2<f32>(textureDimensions(glyphMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary
|
||||||
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
||||||
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||||
|
|
||||||
@@ -521,7 +521,7 @@ fn getSymbol(cellUV : vec2<f32>, index : i32) -> vec2<f32> {
|
|||||||
// var sigDist = median3(dist) - 0.5;
|
// var sigDist = median3(dist) - 0.5;
|
||||||
// symbol.g = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
// symbol.g = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
||||||
|
|
||||||
var unitRange = vec2<f32>(config.msdfPxRange) / vec2<f32>(textureDimensions(glintMSDFTexture));
|
var unitRange = vec2<f32>(config.msdfPxRange) / (vec2<f32>(textureDimensions(glintMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary
|
||||||
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
||||||
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user