Skip to content

Commit 4c2854b

Browse files
committed
refactor(shaders): simplify comments in sdf_vector_simple_frag.glsl and update documentation
- Revised comments in `sdf_vector_simple_frag.glsl` to enhance clarity by removing references to the paper's HLSL code. - Updated the description in `SDF_VECTOR_TEXTURES.md` to reflect a more accurate representation of the shader's features, emphasizing its simplified nature.
1 parent c8be8b0 commit 4c2854b

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/shaders/SDF_VECTOR_TEXTURES.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Full-featured implementation with:
1616
- Optional base color texture
1717

1818
### `sdf_vector_simple_frag.glsl`
19-
Simplified version closely matching the paper's HLSL code:
19+
Simplified version with minimal features:
2020
- Basic alpha testing
2121
- Soft edges
2222
- Outlining
@@ -135,8 +135,3 @@ fragColor = mix(shadow, main, step(0.5, dist));
135135
- **Memory**: A 64x64 SDF texture can represent vector art that would require 4096x4096 in traditional formats (64x memory savings)
136136
- **Performance**: Minimal overhead - typically 2-5 additional shader instructions
137137
- **Compatibility**: Works on all modern GPUs, including those without programmable shaders (using alpha testing)
138-
139-
## References
140-
141-
- Green, C. (2007). "Improved Alpha-Tested Magnification for Vector Textures and Special Effects". GPU Gems 3, Chapter 25.
142-
- Valve Corporation. Source Engine.

src/shaders/sdf_vector_simple_frag.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ layout(binding = 0) uniform sampler2D baseTextureSampler;
1212
// Optional base color texture
1313
layout(binding = 1) uniform sampler2D baseColorTexture;
1414

15-
// Uniforms matching the paper's implementation
15+
// Uniforms
1616
layout(binding = 2) uniform SDFUniforms {
1717
// Soft edges
1818
bool SOFT_EDGES;
@@ -47,7 +47,7 @@ void main() {
4747

4848
float distAlphaMask = texture(baseTextureSampler, v_texCoord).a;
4949

50-
// Apply outlining (matches paper's HLSL code)
50+
// Apply outlining
5151
if (sdf.OUTLINE &&
5252
distAlphaMask >= sdf.OUTLINE_MIN_VALUE0 &&
5353
distAlphaMask <= sdf.OUTLINE_MAX_VALUE1) {
@@ -71,7 +71,7 @@ void main() {
7171
baseColor = mix(baseColor, sdf.OUTLINE_COLOR, oFactor);
7272
}
7373

74-
// Apply soft edges or alpha test (matches paper's HLSL code)
74+
// Apply soft edges or alpha test
7575
if (sdf.SOFT_EDGES) {
7676
baseColor.a *= smoothstep(
7777
sdf.SOFT_EDGE_MIN,
@@ -83,7 +83,7 @@ void main() {
8383
baseColor.a = (distAlphaMask >= 0.5) ? 1.0 : 0.0;
8484
}
8585

86-
// Apply outer glow / drop shadow (matches paper's HLSL code)
86+
// Apply outer glow / drop shadow
8787
if (sdf.OUTER_GLOW) {
8888
vec4 glowTexel = texture(
8989
baseTextureSampler,

0 commit comments

Comments
 (0)