Skip to content

renderer: catch shader source processing exceptions and print raw source#1614

Open
illwieckz wants to merge 133 commits intomasterfrom
illwieckz/shader-dump
Open

renderer: catch shader source processing exceptions and print raw source#1614
illwieckz wants to merge 133 commits intomasterfrom
illwieckz/shader-dump

Conversation

@illwieckz
Copy link
Member

Catch shader source processing exceptions and print raw source if something bad happened while processing the source.

See #1612:

This doesn't fix the underlying cause of the processing error, but at least the engine doesn't crash, the source get printed, the error message get printed, and it is possible to debug the GLSL shader code in some kind of degraded mode.

slipher and others added 30 commits October 22, 2024 21:49
This was a cheat cvar used for dynamic lights that have no intensity set, and set to 2.0 for absolutely no reason whatsoever.
…ET() to RE_AddDynamicLightToScene()

These were largely doing the same thing, use just one function instead.
This has largely the same functionality as trap_R_AddLightToScene().
This was only used to scale the light's colour, just multiply the colour with it earlier on instead.
illwieckz and others added 29 commits December 4, 2025 02:38
This was already removed from the ABI so it was just unused.
Redesign the scheme for storing light grid direction and
directedness vs. ambientness information in the pixels of
a 3D image. Note for context: the light grid does not store
the separate directed and ambient colors; it just averages them.

Before: Light dir is always stored as a normal vector. There is an
"ambient part" byte which is supposed to indicate what fraction of
the light is ambient and what fraction directed.
After: Light dir is scaled according to how much ambient light
there is. Amount of light which is ambient is determined by how
long the direction vector is.

Some issues with the old code which are fixed:
- Wrong averaging of the directed and ambient colors. Previously
  directed and ambient colors were equally weighted, but ambient
  should have more weight since there is no dot product term
  which can decrease it.
- Bad interpolation behavior. Example 1: if neighboring grid cells
  had nearly opposing directions, the resulting direction vector
  would be garbage. With the new code, this results in a small
  vector which causes most light to be automatically moved into
  directed instead of ambient. Example 2: if one cell has a large
  directed component and its neighbor has none, the directions
  are equally weighted despite the second one being meaningless.
  With the new code, directions are weighted according to how much
  directed light there is.
- Excessive brightness when deluxe mapping is disabled, because it
  behaved in that case as if the normal vector were always perfectly
  aligned with the light direction.
The previous commit fixed excessive brightness with grid lighting
when deluxe mapping is disabled by using the average expected
brightness (over all directions) instead of the maximum, but
it went too far and made things dim. Boost the light a bit
since light directions are positively correlated with normals
in practice.
Using git bisect, e497a08 introduces a
window where globalUBOProxy can be null after glsl_restart. Therefore,
also return early, if glboalUBOProxy is null. It will be instantiated
later.

Further, only initialize world shaders *AFTER* all shader storage has
been initialized.
@illwieckz illwieckz force-pushed the illwieckz/shader-dump branch from 09775ad to 2bf3f00 Compare March 9, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants