Skip to content

Commit adb8770

Browse files
committed
Added culling of low intensity lights.
1 parent d3c67c1 commit adb8770

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

include/vsg/app/RecordTraversal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ namespace vsg
9090
Mask traversalMask = MASK_ALL;
9191
Mask overrideMask = MASK_OFF;
9292

93+
/// Light::intensity minimum value for a light to be passed to GPU.
94+
float intensityMinimum = 0.00001;
95+
9396
ref_ptr<Instrumentation> instrumentation;
9497

9598
/// Container for CommandBuffers that have been recorded in current frame

src/vsg/app/RecordTraversal.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,31 +366,31 @@ void RecordTraversal::apply(const AmbientLight& light)
366366
CPU_INSTRUMENTATION_L2_O(instrumentation, &light);
367367

368368
//debug("RecordTraversal::apply(AmbientLight) ", light.className());
369-
if (_viewDependentState) _viewDependentState->ambientLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
369+
if (light.intensity >= intensityMinimum && _viewDependentState) _viewDependentState->ambientLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
370370
}
371371

372372
void RecordTraversal::apply(const DirectionalLight& light)
373373
{
374374
CPU_INSTRUMENTATION_L2_O(instrumentation, &light);
375375

376376
//debug("RecordTraversal::apply(DirectionalLight) ", light.className());
377-
if (_viewDependentState) _viewDependentState->directionalLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
377+
if (light.intensity >= intensityMinimum && _viewDependentState) _viewDependentState->directionalLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
378378
}
379379

380380
void RecordTraversal::apply(const PointLight& light)
381381
{
382382
CPU_INSTRUMENTATION_L2_O(instrumentation, &light);
383383

384384
//debug("RecordTraversal::apply(PointLight) ", light.className());
385-
if (_viewDependentState) _viewDependentState->pointLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
385+
if (light.intensity >= intensityMinimum && _viewDependentState) _viewDependentState->pointLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
386386
}
387387

388388
void RecordTraversal::apply(const SpotLight& light)
389389
{
390390
CPU_INSTRUMENTATION_L2_O(instrumentation, &light);
391391

392392
//debug("RecordTraversal::apply(SpotLight) ", light.className());
393-
if (_viewDependentState) _viewDependentState->spotLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
393+
if (light.intensity >= intensityMinimum && _viewDependentState) _viewDependentState->spotLights.emplace_back(_state->modelviewMatrixStack.top(), &light);
394394
}
395395

396396
// transform nodes

0 commit comments

Comments
 (0)