Skip to content

Lighting-related cleanup; make r_dynamicLight non-latch#1341

Merged
slipher merged 9 commits intoDaemonEngine:masterfrom
slipher:lightstuff
Oct 10, 2024
Merged

Lighting-related cleanup; make r_dynamicLight non-latch#1341
slipher merged 9 commits intoDaemonEngine:masterfrom
slipher:lightstuff

Conversation

@slipher
Copy link
Copy Markdown
Member

@slipher slipher commented Oct 5, 2024

  • Remove unused and unneeded lighting code
  • Gate some tiled renderer-specific code behind the tiled cvar
  • Make r_dynamicLight non-latch, to quickly toggle dynamic lights

Copy link
Copy Markdown
Contributor

@VReaperV VReaperV left a comment

Choose a reason for hiding this comment

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

In commit "Remove redundant realtime light enabled tests" I assume that "If a type of realtime light is enabled, just don't add it to the scene." is a typo?

@VReaperV
Copy link
Copy Markdown
Contributor

VReaperV commented Oct 5, 2024

(moved from review since this would require targeting for-0.55) This:

void RB_RunVisTests( )
apparently uses the same functionality and can be nuked as well later. It's only used for lightflares and seems to be pretty broken, so I assume it was just some proof of concept. Having to do extra IPC calls makes it even worse.

@slipher slipher force-pushed the lightstuff branch 2 times, most recently from 0fee59e to 7d1d420 Compare October 6, 2024 15:11
@slipher
Copy link
Copy Markdown
Member Author

slipher commented Oct 6, 2024

I'm not planning to nuke vis tests. What's being deleted here is

  1. An extension cvar r_ext_occlusion_query which has no effect. Although we do use GL_ARB_occlusion query functionality, this usage is not actually gated by the cvar. I updated the commit message to clarify that it's the cvar that is unused, not the extension.
  2. The vis bounds expansion code which was apparently needed for a different occlusion test code path that was removed in 2014. The vis tests that we still have are used for a similar purpose (seeing if a "light" would shine on certain areas), the vis bounds change code wouldn't do anything useful for it because light flares are just textures, not dynamic lights.

@VReaperV
Copy link
Copy Markdown
Contributor

VReaperV commented Oct 6, 2024

I see, thanks for the explanation.

visBounds is used only to choose zFar. A comment says that
expanding the vis bounds was needed for occlusion queries (which
were NUKED in 2014). I looked at the nuking commit
ffd1714 and it seems that the occlusion
code involved GL draw calls to "draw" the boundaries of the light and
check whether anything would show up. So it's plausible that the
expanded zFar would be needed for that stuff. But it shouldn't be needed
now.
@slipher
Copy link
Copy Markdown
Member Author

slipher commented Oct 7, 2024

Regrettably, I have added more stuff to the PR:

  • NUKE static lights
  • Rename r_dynamicLight to r_drawDynamicLights and remove latch flag

@@ -1622,34 +1568,6 @@ void R_ComputeFinalAttenuation( shaderStage_t *pStage, trRefLight_t *light )
=================
R_CullLightTriangle
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It wasn't me. The banner comment for R_CullLightWorldBounds already says "R_CullLightTriangle"

@slipher
Copy link
Copy Markdown
Member Author

slipher commented Oct 7, 2024

The default diff algorithm generates garbage for the static light nuking commit in tr_bsp.cpp. Reviewers may wish to view commits locally with a better algorithm, for example:

git fetch origin pull/1341/head
git -c diff.algorithm=patience show -9 FETCH_HEAD

A "static light" was a type of realtime light. It was instantiated by
a BSP entity with classname "light", which must have
the "noradiosity" keyword set in order to be rendered. Judging by
https://users.unvanquished.net/~slipher/map-entity-directory.txt there
are no Tremulous or Unvanquished maps using this.

90% of the code for this feature was optimizations specific to the
deprecated forward renderer. (Optimizations in the sense that the code
is intended to be faster than the dynamic light code path.) If we ever
wanted to test real-time lights from map entities later, it could be
done by just adding a dynamic light based on the BSP entity. The entity
parser would be the only part that's needed.

Closes DaemonEngine#1051.
We do use GL_ARB_occlusion_query functionality, but the cvar is not
actually consulted before doing it.
If a dynamic light is disabled, just don't add it to the scene.
No need to check again later if it is disabled
Giving the cvar for whether to add dynamic lights at runtime a different
name from r_realtimeLighting's old name will help it to avoid getting
mistakenly set by old autogen.cfg values. The name name follows the
convention that r_drawXXX cvars that can be used to disable something
that is usually rendered. (showXXX cvars on the other hand are cheat
cvars for drawing a representation of something that is usually unseen.)

Remove Cvar::Latch so it can be toggled instantly.
r_realtimeLightingRenderer.Get() != Util::ordinal( realtimeLightingRenderer_t::TILED ) )
{
return;
}
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.

Totally nitpicking but I prefer that syntax:

	if ( !glConfig2.realtimeLighting )
	{
		return;
	}
	
	if ( r_realtimeLightingRenderer.Get() != Util::ordinal( realtimeLightingRenderer_t::TILED ) )
	{
		return;
	}

This is the pattern we usually implement (and I usually write new code or modify code this way), for example:

if ( !tr.registered )
{
return;
}
if ( r_numLights >= MAX_REF_LIGHTS )
{
return;
}
if ( l->radius <= 0 && !VectorLength( l->projTarget ) )
{
return;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I see it as one condition. "Is the tiled renderer active"

Copy link
Copy Markdown
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

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

LGTM.

@slipher slipher merged commit afd87da into DaemonEngine:master Oct 10, 2024
@slipher slipher deleted the lightstuff branch October 10, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants