Skip to content

Add debug utilities to help debug dynamic lights and small fixes#1908

Open
DolceTriade wants to merge 4 commits intoDaemonEngine:masterfrom
DolceTriade:debuglight
Open

Add debug utilities to help debug dynamic lights and small fixes#1908
DolceTriade wants to merge 4 commits intoDaemonEngine:masterfrom
DolceTriade:debuglight

Conversation

@DolceTriade
Copy link
Copy Markdown
Contributor

  • Add cvars to create a debug spotlight and a debug sun light.
  • Ensure that sun lights affect all light tiles
  • Add a debug cvar to help visualize spot lights and point lights
  • Stop segfaulting when running glsl_restart

This adds a debug cvar to draw a tetrahedron (similar to what you get
when yuou enable r_showSkeleton) in the direction of a spot light or in
6 directions for an omnilight that is proportional to the radius of the
light.

This makes it easier to visualize dynamic lights and see what they
should be doing, what direction they are intended to point, etc.

Also, while here, normalize spotlight direction.
Makes it easier to test dynamic lights.
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 initiialized.
Directional lights should affect all light tiles, so automatically add
them to every tile since we don't populate the radius.

Also add some cvars to allow adding a debug sun.
{
static const vec3_t kOmniDirs[ 6 ] = {
{ 1.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f },
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.

messed up spacing

};
for ( int dirIndex = 0; dirIndex < 6; ++dirIndex )
{
addArrow( kOmniDirs[ dirIndex ], color );
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.

The 12 tetrahedrons seems too busy to me. Maybe we could just draw a wireframe cube?

glState.modelViewProjectionMatrix[ glState.stackIndex ] );

Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 );
GL_CheckErrors();
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.

Oddly placed GL_CheckErrors.

light->color[ 0 ] = r_debugProjLightR.Get();
light->color[ 1 ] = r_debugProjLightG.Get();
light->color[ 2 ] = r_debugProjLightB.Get();
light->scale = r_debugProjLightIntensity.Get();
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.

This doesn't compile since scale was removed on the for-0.56 branch. Now it's just unbounded r/g/b values.

}

// Debug spot light (projected) injection
static Cvar::Cvar<bool> r_debugProjLight( "r_debugProjLight", "inject a directional sun light each frame", Cvar::NONE, false );
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.

Cvar::CHEAT


static void AddDebugProjectedLight()
{
if ( r_numLights + 1 >= MAX_REF_LIGHTS )
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.

No need for + 1

for( uint i = uint( u_lightLayer ); i < uint( u_numLights ); i += uint( NUM_LIGHT_LAYERS ) ) {
Light l = GetLight( i );
// Directional lights (sun) have infinite extent, so always include them in tiles
if ( l.type == 2 ) {
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.

Instead of this how about setting a large radius in the code that adds the light?

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.

2 participants