Add debug utilities to help debug dynamic lights and small fixes#1908
Add debug utilities to help debug dynamic lights and small fixes#1908DolceTriade wants to merge 3 commits intoDaemonEngine:masterfrom
Conversation
src/engine/renderer/tr_backend.cpp
Outdated
| { | ||
| static const vec3_t kOmniDirs[ 6 ] = { | ||
| { 1.0f, 0.0f, 0.0f }, | ||
| { -1.0f, 0.0f, 0.0f }, |
There was a problem hiding this comment.
I think it's consistent now.
| }; | ||
| for ( int dirIndex = 0; dirIndex < 6; ++dirIndex ) | ||
| { | ||
| addArrow( kOmniDirs[ dirIndex ], color ); |
There was a problem hiding this comment.
The 12 tetrahedrons seems too busy to me. Maybe we could just draw a wireframe cube?
There was a problem hiding this comment.
I kept tetrahedrons so I could show the direction of the light for projected lights and show that omni lights go in all directions. I also cargo culted the lightgrid code here.
I've found it helpful to debug dynamic light in my testing as is.
| glState.modelViewProjectionMatrix[ glState.stackIndex ] ); | ||
|
|
||
| Tess_Begin( Tess_StageIteratorDebug, nullptr, true, -1, 0 ); | ||
| GL_CheckErrors(); |
There was a problem hiding this comment.
This is admittedly cargo culted:
Daemon/src/engine/renderer/tr_backend.cpp
Lines 2245 to 2246 in 29446db
As a convention should I check for errors elsewhere?
src/engine/renderer/tr_scene.cpp
Outdated
| light->color[ 0 ] = r_debugProjLightR.Get(); | ||
| light->color[ 1 ] = r_debugProjLightG.Get(); | ||
| light->color[ 2 ] = r_debugProjLightB.Get(); | ||
| light->scale = r_debugProjLightIntensity.Get(); |
There was a problem hiding this comment.
This doesn't compile since scale was removed on the for-0.56 branch. Now it's just unbounded r/g/b values.
There was a problem hiding this comment.
ah, removed the cvar. People can just double the color if they want.
src/engine/renderer/tr_scene.cpp
Outdated
| } | ||
|
|
||
| // Debug spot light (projected) injection | ||
| static Cvar::Cvar<bool> r_debugProjLight( "r_debugProjLight", "inject a directional sun light each frame", Cvar::NONE, false ); |
src/engine/renderer/tr_scene.cpp
Outdated
|
|
||
| static void AddDebugProjectedLight() | ||
| { | ||
| if ( r_numLights + 1 >= MAX_REF_LIGHTS ) |
There was a problem hiding this comment.
Ah right. If r_numLights == MAX_REF_LIGHTS we're maxed out. If it is less, then the increment will happen after assigning the light, so we're still good.
| 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 ) { |
There was a problem hiding this comment.
Instead of this how about setting a large radius in the code that adds the light?
There was a problem hiding this comment.
This works. Nice suggestion
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.
Directional lights should affect all light tiles, so set a really high radius to ensure they are included in all light tiles. Also add some cvars to allow adding a debug sun.
glsl_restart