Conversation
…roper blending - LineGS.h: Add edgeDist/lineAlpha varyings, enforce minimum 1px quad half-width with proportional alpha reduction for sub-pixel lines - LineFS.h: Use smoothstep edge falloff and lineAlpha for smooth anti-aliased edges - RenderStep.cpp: Change blend from GL_ONE/GL_ZERO to GL_SRC_ALPHA/GL_ONE Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
|
@copilot the lines seems now thinner (too thin) and are thus rendered to dark. |
Instead of fading within the original line width (which made lines thinner and darker), add a 1px AA margin outside the core. The core region stays at full brightness while only the margin fades smoothly. Pass coreEdge ratio to fragment shader for adaptive smoothstep threshold. Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Fixed in 1a5287a. The previous approach faded the outer 50% of the line quad width, which made lines appear thinner and darker. The new approach keeps the core line at its original width ( |
|
@copilot it is much better. but there is still a flickering. maybe one needs a z buffer as in the _TriangleRenderStep. |
Additive blending (GL_SRC_ALPHA, GL_ONE) caused flickering because overlapping line quads accumulated colors, varying with draw order. With opaque rendering (GL_ONE, GL_ZERO) + depth test, each pixel has a clean depth-buffer winner. AA edge fade still works via fragColor*alpha. Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Fixed in 50a30cf. Changed the blend mode from additive ( |
|
@copilot at low zoom levels the lines are much too dark. |
| // Enable blending (opaque with depth test, matching _TriangleRenderStep) | ||
| glEnable(GL_BLEND); | ||
| glBlendFunc(/*GL_SRC_ALPHA*/ GL_ONE, /*GL_ONE*/ GL_ZERO); | ||
| glBlendFunc(GL_ONE, GL_ZERO); |
There was a problem hiding this comment.
@copilot The problem here is that before the LineRenderStep, the TriangleRenderStep is executed. Then the lines overwrite the triangles at the edges. But the boundaries of the lines are darker rendered at low zoom level. Maybe other blending function is needed or the color calculation for the lines is not optimal.
There was a problem hiding this comment.
Fixed in 5c4a7b8. The fragment shader now uses gl_FragDepth = 1.0 for AA edge pixels so they don't occupy the depth buffer at normal depth. This allows the subsequent TriangleRenderStep to overwrite dim line edges via GL_LESS. Core line pixels keep gl_FragDepth = gl_FragCoord.z to maintain proper occlusion. The blending stays opaque (GL_ONE, GL_ZERO).
…FragDepth for AA edges Co-authored-by: chrxh <73127001+chrxh@users.noreply.github.com>
Fixed in 5c4a7b8. Two root causes:
|
Thin lines in
_LineRenderSteppartially disappear because the fragment shader always outputsalpha = 1.0with no edge falloff, and sub-pixel quads vanish whenzoom * 0.15drops below one pixel.Changes
max(zoom * 0.15 * 0.5, 0.5)) clamped to a minimum of 0.5px for sub-pixel visibility, then add a 1px AA margin outside the core for smooth edge fadeout. PasscoreEdge(ratio of core to total width) andedgeDist∈ [-1, 1] to the fragment shader. No alpha reduction for sub-pixel lines — they render at full brightness with clamped minimum width.smoothstep(coreEdge, 1.0, abs(edgeDist))so the core region stays at full brightness and only the AA margin fades. Usesgl_FragDepth = 1.0for edge pixels so they don't occupy the depth buffer at normal depth, allowing the subsequent_TriangleRenderStepto overwrite dim line edges viaGL_LESS. Core pixels keepgl_FragDepth = gl_FragCoord.zfor proper occlusion.GL_ONE, GL_ZERO) with depth testing (GL_LESS), matching_TriangleRenderStep. This prevents flickering caused by additive blending where overlapping line quads accumulate colors inconsistently as draw order changes between frames.Key geometry shader logic
Key fragment shader logic
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.