From bb6f154d6046a2091fe6e0ff6165bf223a7bb407 Mon Sep 17 00:00:00 2001 From: gs5579 Date: Tue, 1 Dec 2026 06:21:59 +0000 Subject: [PATCH] Outlines: keep thin edges about a pixel wide; tone down cel highlight Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- src/render/Shaders.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/render/Shaders.cpp b/src/render/Shaders.cpp index 8ebdd93..6d51271 100644 --- a/src/render/Shaders.cpp +++ b/src/render/Shaders.cpp @@ -147,7 +147,7 @@ void main() { // Two-tone cel: a hard terminator with a cool, slightly saturated shade colour. float band = smoothstep(-0.02, 0.06, ndl) * lit; vec3 shade = base.rgb * vec3(0.66, 0.62, 0.78); - color = mix(shade, base.rgb * (0.95 + 0.25 * u_lightColor), band); + color = mix(shade, base.rgb * (0.85 + 0.25 * u_lightColor), band); } else { // Soft studio: wrapped diffuse, sky/ground ambient and Fresnel-weighted highlights. vec3 up = normalize(mat3(osg_ViewMatrix) * vec3(0.0, 0.0, 1.0)); @@ -191,7 +191,7 @@ void main() { const char* kEdgeVertex = R"( attribute float a_edgeScale; uniform float u_edgeSize; -uniform float u_edgeWidth; // global multiplier: pixels per edge-size unit at 1080p height +uniform float u_edgeWidth; // global multiplier: pixels per edge-size unit at 720p height void main() { vec4 pos; vec3 nrm; @@ -199,11 +199,14 @@ void main() { vec4 clip = gl_ProjectionMatrix * (gl_ModelViewMatrix * pos); vec2 dir = (gl_ProjectionMatrix * vec4(gl_NormalMatrix * nrm, 0.0)).xy; float len = length(dir); + // Thin edges are kept near a pixel wide; sub-pixel lines break up into dots. + float width = u_edgeSize * a_edgeScale; + width = width > 0.0 ? max(width * u_edgeWidth, 0.8) : 0.0; if (len > 1e-6) { dir /= len; float aspect = abs(gl_ProjectionMatrix[1][1] / gl_ProjectionMatrix[0][0]); dir.x /= aspect; - clip.xy += dir * (u_edgeSize * a_edgeScale * u_edgeWidth * (2.0 / 1080.0)) * clip.w; + clip.xy += dir * (width * (2.0 / 720.0)) * clip.w; } gl_Position = clip; }