Fixed a math issue in the symbol UV function.

This commit is contained in:
Rezmason
2021-10-30 20:30:55 -07:00
parent 4ea6cadd2f
commit 375560d6a1
3 changed files with 3 additions and 4 deletions

View File

@@ -2,7 +2,6 @@ TODO:
WebGPU
First decent rainRender
What's wrong with the other font textures?
Port compute pass 100%
Compute entry point can live in the same wgsl file, I think
use textureLoad for texel access in render pipeline

View File

@@ -25,7 +25,7 @@ float median3(vec3 i) {
vec2 getSymbolUV(float glyphCycle) {
float symbol = floor(glyphSequenceLength * glyphCycle);
float symbolX = mod(symbol, glyphTextureColumns);
float symbolY = ((glyphTextureColumns - 1.0) - (symbol - symbolX) / glyphTextureColumns);
float symbolY = glyphTextureColumns - floor(symbol / glyphTextureColumns);
return vec2(symbolX, symbolY);
}

View File

@@ -129,7 +129,7 @@ fn wobble(x:f32) -> f32 {
var uv = (quadPosition + quadCorner) / quadGridSize;
// Retrieve the quad's glyph data
var vGlyph = vec4<f32>(1.0, 0.72, randomFloat(vec2<f32>(quadPosition.x, 1.0)), 0.0); // TODO: texture2D(state, quadPosition / quadGridSize);
var vGlyph = vec4<f32>(1.0, 0.0, randomFloat(vec2<f32>(quadPosition.x, 1.0)), 0.0); // TODO: texture2D(state, quadPosition / quadGridSize);
// Calculate the quad's depth
var quadDepth = 0.0;
@@ -181,7 +181,7 @@ fn median3(i:vec3<f32>) -> f32 {
fn getSymbolUV(glyphCycle:f32) -> vec2<f32> {
var symbol = i32(f32(msdf.glyphSequenceLength) * glyphCycle);
var symbolX = symbol % msdf.glyphTextureColumns;
var symbolY = ((msdf.glyphTextureColumns - 1) - (symbol - symbolX) / msdf.glyphTextureColumns);
var symbolY = symbol / msdf.glyphTextureColumns;
return vec2<f32>(f32(symbolX), f32(symbolY));
}