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>
This commit is contained in:
gs5579andDevin AI committed 2026-12-01 06:21:59 +00:00
1 parent 2c625254f3
commit bb6f154d60
1 file changed
+6 -3
+6 -3
View File
@@ -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;
}