Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying the name of light associated with lens flares #2172

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading