Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RSF_FORCE_LIGHTMAP #1523

Merged
merged 3 commits into from
Mar 11, 2025
Merged

Conversation

VReaperV
Copy link
Contributor

@VReaperV VReaperV commented Jan 26, 2025

Cgame-side pr: Unvanquished/Unvanquished#3306

Replaces RSF_NOLIGHTSCALE.

If this flag is used when registering a shader, all ST_COLORMAP stages will be changed to ST_DIFFUSEMAP. This is intended for use with particles and trails, to make them use the lightGrid in the GLSL code.

Improves performance with particle systems and trails, e. g. with firebombs, and a massive performance improvement on map https://users.unvanquished.net/~sweet/pkg/map-jota_3.0.dpk in the outside area.

There's for the most part no difference in how the particles/trails look, the only differences are due to the GLSL lightGrid being more precise.

@slipher
Copy link
Member

slipher commented Jan 26, 2025

FWIW the realLight on Jota doesn't even do anything currently. The shader must have an rgbgen vertex or entity for the entity color to have any effect. There are only 4 maps where realLight is actually used with a compatible shader:

  • gantry (blood drops from fan)
  • sectorb17 (smokestack)
  • nova (purports to be smoke; haven't tested)
  • map-edge1_v3_ye_m.pk3 (purports to be smoke; haven't tested)

Haven't read the code yet but the approach sounds fine.

@VReaperV VReaperV force-pushed the reaper/lightgrid-particles/sync branch 2 times, most recently from 2adfd06 to 552cc35 Compare January 31, 2025 17:17
@VReaperV VReaperV force-pushed the reaper/lightgrid-particles/sync branch from 552cc35 to 8f395da Compare February 12, 2025 20:51

// TODO: Add lightmap as the first stage if there's a heatHaze stage here?
if ( pStage->type == stageType_t::ST_COLORMAP ) {
pStage->type = stageType_t::ST_DIFFUSEMAP;
Copy link
Member

Choose a reason for hiding this comment

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

I recall a shader in StarATCS that used realLight (uselessly, without rgbgen vertex/entity) and also had a lightmap stage. A shader like that would end up with two lightmaps. To avoid this we could restrict the forceLightMap effect to shaders with only a single stage, or perhaps do it after CollapseStages (so that it wouldn't have the ST_COLORMAP type anymore).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That shader ends up with 2 stages anyway.

Copy link
Member

Choose a reason for hiding this comment

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

True. So what about limiting the effect to shaders with a single stage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems reasonable. I checked all the shaders for particles with realLight in the particle directory, and only the staratcs one has 2 stages. Without the single stage check it ends up with a lightgrid and a regular lightmap stage, with the check it ends up as generic + lightgrid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the check for the amount of stages.

@VReaperV VReaperV force-pushed the reaper/lightgrid-particles/sync branch from 8f395da to eac1ff9 Compare March 10, 2025 19:52
Replaces RSF_NOLIGHTSCALE.

If this flag is used when registering a shader, all `ST_COLORMAP` stages will be changed to `ST_DIFFUSEMAP`. This is intended for use with particles and trails, to make them use the lightGrid in the GLSL code.
@VReaperV VReaperV force-pushed the reaper/lightgrid-particles/sync branch from eac1ff9 to 52395c8 Compare March 10, 2025 20:30
Stops particle shaders with 2 stages from switching a pattern of `generic + lightgrid` to `lightgrid + lightmap` (relevant for `staratcs`).

Also fixes an OOB.
Copy link
Member

@slipher slipher left a comment

Choose a reason for hiding this comment

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

LGTM modulo comment

@VReaperV VReaperV merged commit 1a4f393 into for-0.56.0/sync Mar 11, 2025
9 checks passed
@VReaperV VReaperV deleted the reaper/lightgrid-particles/sync branch March 11, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants