mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29:30 -07:00
Fixed SDF math; texture dimensions were accessed before they loaded in the REGL-based renderer
This commit is contained in:
@@ -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 * 1000.); // Not sure why this x1000 softening is necessary
|
||||
vec2 unitRange = vec2(msdfPxRange) / glyphMSDFSize;
|
||||
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 * 1000.); // Not sure why this x1000 softening is necessary
|
||||
vec2 unitRange = vec2(msdfPxRange) / glintMSDFSize;
|
||||
vec2 screenTexSize = vec2(1.0) / fwidth(uv);
|
||||
float screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||
|
||||
|
||||
@@ -499,15 +499,14 @@ fn getSymbol(cellUV : vec2<f32>, index : i32) -> vec2<f32> {
|
||||
uv += 0.5;
|
||||
uv = (uv + getSymbolUV(index)) / vec2<f32>(config.glyphTextureGridSize);
|
||||
|
||||
var symbol = vec2<f32>();
|
||||
|
||||
// MSDF: calculate brightness of fragment based on distance to shape
|
||||
var symbol = vec2<f32>();
|
||||
{
|
||||
// var dist = textureSample(glyphMSDFTexture, linearSampler, uv).rgb;
|
||||
// var sigDist = median3(dist) - 0.5;
|
||||
// symbol.r = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
||||
|
||||
var unitRange = vec2<f32>(config.msdfPxRange) / (vec2<f32>(textureDimensions(glyphMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary
|
||||
var unitRange = vec2<f32>(config.msdfPxRange) / vec2<f32>(textureDimensions(glyphMSDFTexture));
|
||||
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
||||
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||
|
||||
@@ -521,7 +520,7 @@ fn getSymbol(cellUV : vec2<f32>, index : i32) -> vec2<f32> {
|
||||
// var sigDist = median3(dist) - 0.5;
|
||||
// symbol.g = clamp(sigDist / fwidth(sigDist) + 0.5, 0.0, 1.0);
|
||||
|
||||
var unitRange = vec2<f32>(config.msdfPxRange) / (vec2<f32>(textureDimensions(glintMSDFTexture)) * 1000.0); // Not sure why this x1000 softening is necessary
|
||||
var unitRange = vec2<f32>(config.msdfPxRange) / vec2<f32>(textureDimensions(glintMSDFTexture));
|
||||
var screenTexSize = vec2<f32>(1.0) / fwidth(uv);
|
||||
var screenPxRange = max(0.5 * dot(unitRange, screenTexSize), 1.0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user