SdfMesh.onStoreChange (src/engine/SdfMesh.ts:180) decides whether to rebuild the material from two fields only:
if (sdf.glsl !== this.lastGlsl || sdf.paramCount !== this.lastParamCount) {
...
this.rebuild(sdf);
}
But rebuild() bakes two more inputs into the material:
hasWarn — passed to buildFrag(sdf.glsl, sdf.paramCount, sdf.hasWarn) (:105-107), so it selects the fragment source.
textures — each becomes a DataTexture uniform (:195-204).
So an evaluation that produces identical GLSL and the same param count, but a different hasWarn or different texture payload, never reaches the GPU. The thin-wall highlight shows the previous evaluation's state, and a texture-only change renders with stale texture data.
Fix
Include both in the cache key. hasWarn is a boolean, so it is free. Textures need a content key — hashing the payload on every evaluation may not be worth it, so a cheap structural key (count, plus each texture's name/width/height) would catch the common cases, with a comment noting that same-dimension content-only edits still need a full hash to detect.
Related
#53 (GPU resources leaked on every rebuild) touches the same function. Fixing the key here makes rebuilds more frequent for texture changes, which makes the leak worse — so #53 should land first or together.
SdfMesh.onStoreChange(src/engine/SdfMesh.ts:180) decides whether to rebuild the material from two fields only:But
rebuild()bakes two more inputs into the material:hasWarn— passed tobuildFrag(sdf.glsl, sdf.paramCount, sdf.hasWarn)(:105-107), so it selects the fragment source.textures— each becomes aDataTextureuniform (:195-204).So an evaluation that produces identical GLSL and the same param count, but a different
hasWarnor different texture payload, never reaches the GPU. The thin-wall highlight shows the previous evaluation's state, and a texture-only change renders with stale texture data.Fix
Include both in the cache key.
hasWarnis a boolean, so it is free. Textures need a content key — hashing the payload on every evaluation may not be worth it, so a cheap structural key (count, plus each texture's name/width/height) would catch the common cases, with a comment noting that same-dimension content-only edits still need a full hash to detect.Related
#53 (GPU resources leaked on every rebuild) touches the same function. Fixing the key here makes rebuilds more frequent for texture changes, which makes the leak worse — so #53 should land first or together.