Clamped per-vertex sunlight is slightly brighter than it should be

Alexei Kotov
2026-04-03T04:13:38Z

Found by wareya.

The current clamping implementation requires handling diffuse sunlight contribution separately to shadow it. Because it's split from the rest of lighting contribution, interpolation of unclamped separate lighting contribution might cause sunlight to have slightly more contribution than it should in FFP, specifically when per-vertex lighting is used, even if there are no shadows.

We cannot/should not do per-vertex shadowing, and emulating its curve with per-pixel shadowing is not viable.

A solution wareya proposed is to make shadowing interpolate between capped lighting with no diffuse sunlight and capped full lighting. This should match per-vertex shadowing at end points (no shadow/full shadow) and at the very least ensure no-shadow case looks like FFP. This also allows not to clamp lighting in the fragment shader. For unclamped lighting this changes nothing. For clamped PPL this is probably unnecessary?

This currently requires more refactoring as there are too many roughly similar lighting implementations (PVL for objects, terrain and groundcover and PPL for objects, terrain, groundcover and BSLightingShader) which could become overcomplicated, although I'm thinking now the PPL path might be fine (more "physically accurate") without doing this.