Skip to content

Fullneb Revamp#7352

Merged
BMagnu merged 14 commits into
scp-fs2open:masterfrom
BMagnu:fog_foo
May 28, 2026
Merged

Fullneb Revamp#7352
BMagnu merged 14 commits into
scp-fs2open:masterfrom
BMagnu:fog_foo

Conversation

@BMagnu

@BMagnu BMagnu commented Apr 6, 2026

Copy link
Copy Markdown
Member

This revamps the fullneb configuration from near and far multipliers with fixed nebula transparencies to a much more intuitive near-distance + configurable transparency at 1000m depth. It furthermore adds clip distances after which the nebula does not gain opacity with more depth, split between skyboxes and everything else. This is needed, and accordingly default-configured for old missions, because prior to #7245, skybox depth was incorrectly clipped to 0 in the shader due to float overflow, resulting in non-fogged skyboxes. #7245 fixed that, and in turn made skyboxes get fogged with full opacity, essentially completely hiding them when fog is enabled.
This PR makes the respective values fully configurable, allowing for full fogging, no fogging, and anything inbetween for skyboxes and/or ships respectively.

@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) labels Apr 6, 2026
@BMagnu BMagnu added this to the Release 26.0 milestone Apr 6, 2026
@MjnMixael

Copy link
Copy Markdown
Contributor

There are multiple mods, BtA included, that have not been able to upgrade to modern builds because this fix is still not in. Is this going to make 26.0.0?

@BMagnu

BMagnu commented May 22, 2026

Copy link
Copy Markdown
Member Author

It will.
This is a blocker as it is a critical bugfix.

Goober5000 and others added 6 commits May 25, 2026 18:47
Replace the legacy `+Fog Near Mult` / `+Fog Far Mult` model — which
depended on fixed engine constants — with four parameters that map
directly to renderer behavior:

  +Fog 1000m Visibility    fraction of light surviving 1000m of fog
  +Fog Near Distance       meters from camera where fog begins
  +Fog Skybox Clip Distance  max render distance for the skybox in fog
  +Fog Clip Distance       max render distance for the scene in fog

The deferred-lighting fog shader, material system, model renderer,
object sort, and the Lua mission API all consume the new parameters
directly. The legacy `Neb2_fog_near_mult` / `Neb2_fog_far_mult`
globals are removed.

Mission parsing accepts either the legacy keys or the modern keys.
Legacy values are converted to the modern set at parse time, and a
per-mission flag (`Neb2_fog_use_legacy_values`) records which keys to
write back on save. The flag is cleared only when something actually
changes, so opening and OK'ing an unmodified legacy mission preserves
its on-disk format. Saving uses `optional_string_fred` to preserve
user comments through edit cycles.

FRED2 and QtFRED background editors both expose the four parameters
in place of the old multipliers, with friendly labels and tooltips.
Both editors validate input (visibility clamped to [0, 1]; near
distance must be > 0; skybox and scene clip distances may be 0 to
disable fog at that range) and use a snapshot-and-compare at close
time so that a no-op open-then-OK never spuriously rewrites a legacy
mission in the modern format.

FRED2's background dialog is also reorganized so that "Display bg
bitmaps in nebula", "Override nebula fog palette", the RGB row, and
the four fog parameters all sit inside the Nebula group box; the
"Old Nebula" group box is restored below it with its Pattern, Color,
Pitch, Bank, and Heading controls back inside the frame. The dialog
now overrides PreTranslateMessage so that the new fog tooltips —
and the previously broken "Save sun/bitmap angles in correct format"
tooltip — actually fire.

QtFRED's BackgroundEditor.ui adds four QDoubleSpinBox controls in
the existing nebula form layout, with per-field decimals chosen to
avoid scientific notation, and per-field min/max declaring the
validation rules. The QtFRED help page is updated to describe the
new fields.
Rewrite nebula fog with four explicit parameters
Comment thread code/nebula/neb.h
// fog near and far values for rendering the background nebula
extern float Neb_backg_fog_near;
extern float Neb_backg_fog_far;

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.

Should these two values Neb_backg_fog_near and Neb_backg_fog_far just be removed to avoid any future confusion since they are removed everywhere else?

Comment thread code/scripting/api/libs/mission.cpp
@BMagnu BMagnu requested a review from wookieejedi May 26, 2026 23:04

@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.

Looks good now, thanks!

@BMagnu BMagnu marked this pull request as draft May 27, 2026 03:08
@BMagnu

BMagnu commented May 27, 2026

Copy link
Copy Markdown
Member Author

Small issues still popped up, so in draft for a day or so pending these

Goober5000 and others added 2 commits May 28, 2026 00:14
- Rename Neb2_fog_use_legacy_values to Neb2_fog_save_legacy_values
  to reflect that the flag governs save format, not runtime
  behavior.
- Decide both the save flag and the legacy-to-modern conversion
  purely from whether the file contains modern fog keys, dropping
  the prior heuristic based on required_fso_version. A mission
  without modern keys (legacy- or retail-format) converts on load
  and saves back in legacy format; missions with modern keys are
  saved as modern.
- Snapshot the four fog values as floats at editor open and use
  fl_equal for the no-change comparison in both FRED2 and QtFRED,
  replacing the FRED2 CString comparison and the QtFRED strict
  inequality.
- Document the on-disk invariant in missionsave: when not saving
  legacy keys, the four modern keys must always be written (never
  gated on "only if non-default"), since the parser uses their
  presence to decide whether to run the conversion on next load.
@BMagnu BMagnu marked this pull request as ready for review May 28, 2026 05:02
@BMagnu BMagnu merged commit 20c8417 into scp-fs2open:master May 28, 2026
20 checks passed
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants