From 9799a349ff9ff701b37e606d50ebd192bec80dfc Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 18 Feb 2026 13:25:00 -0800 Subject: [PATCH] Fix copper traces nearly invisible in 3D viewer The TransparencyControl function was squaring the gray color value to make dark solder masks more opaque, but this made the default green mask (gray ~0.13) nearly completely opaque, hiding copper traces underneath. The squaring was unnecessary since truly dark colors already produce near-zero transparency from the existing cubic formula. The specular floor, dynamic shininess, and reflection scaling from the same commit already properly handle dark solder mask appearance. Fixes https://gitlab.com/kicad/code/kicad/-/issues/23103 --- 3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp | 8 +++----- 3d-viewer/3d_rendering/raytracing/create_scene.cpp | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp index a526165aaa..7e6b649a65 100644 --- a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp +++ b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp @@ -48,8 +48,8 @@ /** * Attempt to control the transparency based on the gray value of the color. - * This function applies a non-linear transformation that makes darker colors more opaque, - * preventing copper show-through on dark solder masks like black. + * This function applies a non-linear transformation that reduces transparency + * for darker colors while preserving copper visibility through the solder mask. * * @param aGrayColorValue - diffuse gray value (0.0 to 1.0) * @param aTransparency - base transparency value (0.0 opaque to 1.0 transparent) @@ -63,9 +63,7 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency ) float ca = 1.0f - aTransparency; ca = 1.00f - 1.05f * ca * ca * ca; - // Squaring gray value makes darker colors more opaque, which improves appearance - // of dark solder masks like black where copper would otherwise show through - return glm::clamp( aGrayColorValue * aGrayColorValue * ca + aaa, 0.0f, 1.0f ); + return glm::clamp( aGrayColorValue * ca + aaa, 0.0f, 1.0f ); } /** diff --git a/3d-viewer/3d_rendering/raytracing/create_scene.cpp b/3d-viewer/3d_rendering/raytracing/create_scene.cpp index 1f3557f35e..6f1a751b62 100644 --- a/3d-viewer/3d_rendering/raytracing/create_scene.cpp +++ b/3d-viewer/3d_rendering/raytracing/create_scene.cpp @@ -64,9 +64,7 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency ) float ca = 1.0f - aTransparency; ca = 1.00f - 1.05f * ca * ca * ca; - // Squaring gray value makes darker colors more opaque, which improves appearance - // of dark solder masks like black where copper would otherwise show through - return glm::max( glm::min( aGrayColorValue * aGrayColorValue * ca + aaa, 1.0f ), 0.0f ); + return glm::max( glm::min( aGrayColorValue * ca + aaa, 1.0f ), 0.0f ); } /**