Skip to content

Commit

Permalink
Support specifying the name of light associated with lens flares (#2172)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Oct 5, 2023
1 parent 78c27d9 commit 8c2fb9b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/systems/lens_flare/LensFlare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ void LensFlare::Configure(
this->dataPtr->occlusionSteps = _sdf->Get<uint32_t>("occlusion_steps");
}

if (_sdf->HasElement("light_name"))
{
this->dataPtr->lightName = _sdf->Get<std::string>("light_name");
}

// Get Camera Name
this->dataPtr->cameraName = scopedName(this->dataPtr->entity,
_ecm, "::", false);
Expand Down Expand Up @@ -187,7 +192,18 @@ void LensFlarePrivate::OnPostRender()
}

// get light
auto light = this->scene->LightByIndex(0);
rendering::LightPtr light;
if (!this->lightName.empty())
{
light = this->scene->LightByName(this->lightName);
}
else if (this->scene->LightCount() > 0)
{
light = this->scene->LightByIndex(0);
}
// Light not found. Keep trying in case it's not available in the world yet.
if (!light)
return;

rendering::RenderEngine *engine = this->camera->Scene()->Engine();
rendering::RenderPassSystemPtr rpSystem = engine->RenderPassSystem();
Expand Down
3 changes: 3 additions & 0 deletions src/systems/lens_flare/LensFlare.hh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ namespace systems
/// <occlusion_steps> Sets the number of steps to take in
/// each direction to check for occlusions.
/// The default value is set to 10. Use 0 to disable
/// <light_name> Sets the light associated with the lens flares.
/// If not specified. The first light in the scene will
/// be used.

class LensFlare:
public System,
Expand Down

0 comments on commit 8c2fb9b

Please sign in to comment.