Softer shadows in raytracing and RTAO - #7653
Open
The-E wants to merge 4 commits into
Open
Conversation
Raytraced shadow penumbras needed a hand-authored $SunAngularSize: in stars.tbl, which no shipped content sets -- so in practice nothing ever got a penumbra. Measure the size from the sun bitmap instead: g3_render_rect_screen_aligned_2d() sizes the sun quad so its rad is the tangent of the half-angle it subtends, making tan(angular radius) equal to 0.05 * the mission's +Scale: * the emitting disc's fraction of the bitmap. That fraction is the area of the pixels at or above 90% of the brightest one, converted to an equivalent radius. Across 90 sun bitmaps from retail, the MediaVPs, Blue Planet and BtA it lands at a median of 0.261 (retail's chunkier art at 0.487), and the threshold acts as a constant factor rather than a per-bitmap judgement call -- Spearman rho 0.96 between a 90% and a 50% cutoff. Taken literally that yields suns 3.9-8.5x Sol's apparent diameter once +Scale: is folded in (median 1.55, up to 5.0 in retail's own missions), so the measurement is scaled by 0.25 and clamped to 1.5 degrees, putting typical content near Sol. Derivation is the default: $SunAngularSize: 0 asks for hard shadows, an explicit value still wins, and "derived" states the default outright. Bitmaps that can't be read -- and the deliberately blank sun bitmaps mods ship to get a light source with no visible disc -- fall back to hard shadows rather than to the widest possible penumbra. Also adds lab controls for RT shadow quality (Low/High) and the local light cap. Both are safe to change live: they only gate which lights are picked as shadow casters while filling the per-frame light uniforms. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Introduce +AngularSize: for suns in mission files, overriding stars.tbl or bitmap-derived sizes. Updates FRED and QtFRED UI to support this feature, including validation and default fallback logic.
The-E
force-pushed
the
feat/softer-shadows
branch
from
July 25, 2026 18:18
46ed13c to
c975b84
Compare
Contributor
|
please dont forget there is another shadowCascadeParams in shadow_map-g |
Member
Author
done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds methods for softening RT shadows. This mechanism works by setting an apparent light size either in the mission file, a lab override, or by deriving it from the sun bitmap. The current implementation limits the apparent size to 1.5°; this is an artificial constraint based around the limits of raytraced shadows - the wider the sun is, the sparser the rays to check whether something is in shadow become, and the more grainy the shadows appear.
There are table settings and FRED/qtFRED controls to set this in missions.
And because the methods required to do soft shadows are mostly identical to what you need to do in order to do raytraced Ambient Occlusion, I threw in that effect as well - but I seriously cannot recommend anyone use it. The visual impact is only noticeable when you really look for it, and the performance cost is pretty large.