Skip to content

Proper Ambient Light#6849

Merged
BMagnu merged 11 commits into
scp-fs2open:masterfrom
BMagnu:proper_ambient_light
Jul 21, 2025
Merged

Proper Ambient Light#6849
BMagnu merged 11 commits into
scp-fs2open:masterfrom
BMagnu:proper_ambient_light

Conversation

@BMagnu

@BMagnu BMagnu commented Jul 20, 2025

Copy link
Copy Markdown
Member

This PR moves ambient light (including from envmaps) from the main shader to the deferred lighting pass. This means, that things modifying the G-Buffer would not be correctly lit by environment light. Notably, anything changing the diffuse texture in a place not directly lit by a non-ambient light (i.e. lots of decals) would just be invisible, as well as things rendering to the emissive buffer (i.e. insignias) would have an already ambient-lit model base which they could not darken, leading to a faded appearance.
This alone fixes #6838.
While this also fixes the underlying root cause of faded insignias, there's an additional problem with insignias in that the CPU-side light estimation used for insignia rendering was often inaccurate or outright wrong. To make insignias look proper, this PR also piggybacks insignias off of decals. This is a slightly lossy conversion, as insignias could previously have arbitrary polygons, wheras now they're reduced to a decal in a specific spot, but due to the restrictions on insignia UV-mapping and the need to be using the square insignia textures, I believe that this is effectively not noticeable for the insignias actually in use.
This fixes #1309 and it fixes #5674.
This PR also addresses the Insignia side of #5161.

@BMagnu BMagnu added fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d) opengl Features and Issues related to OpenGL labels Jul 20, 2025
@BMagnu BMagnu requested review from asarium and z64555 as code owners July 20, 2025 12:27
@BMagnu BMagnu added this to the Release 25.0 milestone Jul 20, 2025

@wookieejedi wookieejedi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really fantastic to have decals properly fixed and insignias actually working again! Overall works well in my tests, too.

@BMagnu BMagnu merged commit 9b82dae into scp-fs2open:master Jul 21, 2025
20 checks passed
@MoerasGrizzly

Copy link
Copy Markdown

This has been bugging me relentlessly for a very long time and I'm super happy to see it fixed. Thank you!

wookieejedi added a commit to wookieejedi/fs2open.github.com that referenced this pull request Jul 24, 2025
Small one-line fix that follows up scp-fs2open#6849. That PR removed the `!(Viewer_mode & VM_EXTERNAL))` check within a section of `ship_render_player_ship` to optimize insignia rendering, but turns out that check is needed to ensure `show-ship` properly works. This PR restores that check to fix this bug, and ideally the thoughts about slightly optimizing insignias can be considered later.

Tested and works as expected.
BMagnu pushed a commit that referenced this pull request Jul 24, 2025
Small one-line fix that follows up #6849. That PR removed the `!(Viewer_mode & VM_EXTERNAL))` check within a section of `ship_render_player_ship` to optimize insignia rendering, but turns out that check is needed to ensure `show-ship` properly works. This PR restores that check to fix this bug, and ideally the thoughts about slightly optimizing insignias can be considered later.

Tested and works as expected.
Kestrellius pushed a commit to Kestrellius/fs2open.github.com that referenced this pull request Jul 26, 2025
* Remove ambient handling from amin / decal pass

* Add ambient light to deferred pass

* Make decals work and fix double insignia rendering

* Fix decal vertex shader

* render insignias as decals

* Cleanup of old insignia stuff

* Move insignia post-processing to model load

* perform envmap lighting in deferred shader

* Remove Envmapping from main shader

* Fix MSVC warning

* exclude def_files from clang tidy
Kestrellius pushed a commit to Kestrellius/fs2open.github.com that referenced this pull request Jul 26, 2025
Small one-line fix that follows up scp-fs2open#6849. That PR removed the `!(Viewer_mode & VM_EXTERNAL))` check within a section of `ship_render_player_ship` to optimize insignia rendering, but turns out that check is needed to ensure `show-ship` properly works. This PR restores that check to fix this bug, and ideally the thoughts about slightly optimizing insignias can be considered later.

Tested and works as expected.
@BMagnu BMagnu mentioned this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. graphics A feature or issue related to graphics (2d and 3d) opengl Features and Issues related to OpenGL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Dark Decals By Adding a Proper "Ambient Light" Squad logos look faded Squadron images are invisible under certain lighting conditions

3 participants