Envmap reflections too dark on some surfaces after linear pipeline conversion #45

Closed
opened 2026-03-19 18:09:32 +00:00 by kit · 1 comment
Owner

Problem

After converting to the full linear color pipeline (#44, commit 36368a2), envmap reflections on some surfaces appear too dark compared to ground truth.

Ground truth

Compare against window_reflection_02.jpg — window/glass surfaces with visible envmap reflections are noticeably dimmer than they should be.

Likely causes

  • ENV_MAP_SCALE removed: the old pipeline used * 2.0 on linearized cubemap samples as an overbright factor. The linear conversion dropped this to 1.0. Some surfaces may need a higher scale to compensate.
  • envmapTint interaction: while envmapTint is correctly kept as a linear multiplier (not double-linearized), the overall envmap contribution is lower without the 2.0 scale, so tinted surfaces are hit harder.
  • Contrast/saturation in linear space: the envmap contrast (mix(envColor, envColor * envColor, envmapContrast)) and saturation operations now run on linear values which have a different distribution than gamma values — this shifts the response curve darker.

Investigation

  1. Sample specific pixel RGB values from the dark reflections and compare against ground truth using compare.js
  2. Try restoring ENV_MAP_SCALE to 2.0 and compare
  3. Check whether the issue is uniform across all envmapped surfaces or specific to certain tint/contrast/saturation combinations
  • #44 — Linear color pipeline conversion (root cause)
  • #8 — VMT shader types (envmap parameters)
## Problem After converting to the full linear color pipeline (#44, commit 36368a2), envmap reflections on some surfaces appear too dark compared to ground truth. ## Ground truth Compare against `window_reflection_02.jpg` — window/glass surfaces with visible envmap reflections are noticeably dimmer than they should be. ## Likely causes - **ENV_MAP_SCALE removed**: the old pipeline used `* 2.0` on linearized cubemap samples as an overbright factor. The linear conversion dropped this to 1.0. Some surfaces may need a higher scale to compensate. - **envmapTint interaction**: while envmapTint is correctly kept as a linear multiplier (not double-linearized), the overall envmap contribution is lower without the 2.0 scale, so tinted surfaces are hit harder. - **Contrast/saturation in linear space**: the envmap contrast (`mix(envColor, envColor * envColor, envmapContrast)`) and saturation operations now run on linear values which have a different distribution than gamma values — this shifts the response curve darker. ## Investigation 1. Sample specific pixel RGB values from the dark reflections and compare against ground truth using `compare.js` 2. Try restoring ENV_MAP_SCALE to 2.0 and compare 3. Check whether the issue is uniform across all envmapped surfaces or specific to certain tint/contrast/saturation combinations ## Related - #44 — Linear color pipeline conversion (root cause) - #8 — VMT shader types (envmap parameters)
Author
Owner

Fixed in 5cb64b1. Added envMapScale uniform (default 2.0) applied post-linearization to cubemap samples. The reflections were too dim because the lightmap gamma compression shifted the diffuse working space, making the linear envmap contribution proportionally weaker. The 2.0 scale brings reflections in line with Source ground truth — verified against window_reflection.jpg and indoor_shadow_reflections.jpg.

Fixed in `5cb64b1`. Added `envMapScale` uniform (default 2.0) applied post-linearization to cubemap samples. The reflections were too dim because the lightmap gamma compression shifted the diffuse working space, making the linear envmap contribution proportionally weaker. The 2.0 scale brings reflections in line with Source ground truth — verified against `window_reflection.jpg` and `indoor_shadow_reflections.jpg`.
kit closed this issue 2026-03-20 05:38:33 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kit/gmod-web-stream#45
No description provided.