This repository was archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 498
LensFlare: parameterize number of occlusion steps #3234
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
45bac85
LensFlare: param for number of occlusion steps
scpeters bf5c238
fix build
scpeters eccb4e6
fix plugin
scpeters 4f90525
LensFlarePlugin: call SetCamera last
scpeters cef139e
Document plugin XML parameter
scpeters edcf104
Merge remote-tracking branch 'origin/gazebo11' into scpeters/lensflar…
scpeters 38fdb50
Initialize double constants with 10.0
scpeters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -55,6 +55,10 @@ namespace gazebo | |||||
/// \brief Color of lens flare. | ||||||
public: ignition::math::Vector3d color | ||||||
= ignition::math::Vector3d(1.0, 1.0, 1.0); | ||||||
|
||||||
/// \brief Number of steps to take in each direction when checking for | ||||||
/// occlusion. | ||||||
public: double occlusionSteps = 10; | ||||||
}; | ||||||
|
||||||
////////////////////////////////////////////////// | ||||||
|
@@ -95,6 +99,13 @@ namespace gazebo | |||||
this->dataPtr->color = _color; | ||||||
} | ||||||
|
||||||
////////////////////////////////////////////////// | ||||||
void LensFlareCompositorListener::SetOcclusionSteps( | ||||||
double _occlusionSteps) | ||||||
{ | ||||||
this->dataPtr->occlusionSteps = _occlusionSteps; | ||||||
} | ||||||
|
||||||
////////////////////////////////////////////////// | ||||||
void LensFlareCompositorListener::notifyMaterialRender(unsigned int _passId, | ||||||
Ogre::MaterialPtr &_mat) | ||||||
|
@@ -313,7 +324,7 @@ namespace gazebo | |||||
// work in normalized device coordinates | ||||||
// lens flare's halfSize is just an approximated value | ||||||
double halfSize = 0.05 * this->dataPtr->scale; | ||||||
double steps = 10; | ||||||
double steps = this->dataPtr->occlusionSteps; | ||||||
double stepSize = halfSize * 2 / steps; | ||||||
double cx = _imgPos.X(); | ||||||
double cy = _imgPos.Y(); | ||||||
|
@@ -356,6 +367,9 @@ namespace gazebo | |||||
public: ignition::math::Vector3d lensFlareColor | ||||||
= ignition::math::Vector3d(1.0, 1.0, 1.0); | ||||||
|
||||||
/// \brief Color of lens flare. | ||||||
public: double lensFlareOcclusionSteps = 10; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
||||||
/// \brief Compositor name to be used for lens flare | ||||||
public: std::string compositorName = "CameraLensFlare/Default"; | ||||||
|
||||||
|
@@ -423,6 +437,8 @@ void LensFlare::SetCamera(CameraPtr _camera) | |||||
this->dataPtr->lensFlareScale); | ||||||
this->dataPtr->lensFlareCompositorListener->SetColor( | ||||||
this->dataPtr->lensFlareColor); | ||||||
this->dataPtr->lensFlareCompositorListener->SetOcclusionSteps( | ||||||
this->dataPtr->lensFlareOcclusionSteps); | ||||||
|
||||||
this->dataPtr->lensFlareInstance = | ||||||
Ogre::CompositorManager::getSingleton().addCompositor( | ||||||
|
@@ -463,6 +479,12 @@ void LensFlare::SetColor(const ignition::math::Vector3d &_color) | |||||
} | ||||||
} | ||||||
|
||||||
////////////////////////////////////////////////// | ||||||
void LensFlare::SetOcclusionSteps(double _occlusionSteps) | ||||||
{ | ||||||
this->dataPtr->lensFlareOcclusionSteps = _occlusionSteps; | ||||||
} | ||||||
|
||||||
////////////////////////////////////////////////// | ||||||
void LensFlare::SetCompositorName(const std::string &_name) | ||||||
{ | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,6 +40,9 @@ namespace gazebo | |||||
public: ignition::math::Vector3d color | ||||||
= ignition::math::Vector3d(1.4, 1.2, 1.0); | ||||||
|
||||||
/// \brief Lens flare occlusion steps | ||||||
public: double occlusionSteps = 10; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
||||||
/// \brief Lens flare compositor name | ||||||
public: std::string compositorName; | ||||||
}; | ||||||
|
@@ -87,6 +90,11 @@ void LensFlareSensorPlugin::Load(sensors::SensorPtr _sensor, | |||||
this->dataPtr->color = _sdf->Get<ignition::math::Vector3d>("color"); | ||||||
} | ||||||
|
||||||
if (_sdf->HasElement("occlusion_steps")) | ||||||
{ | ||||||
this->dataPtr->occlusionSteps = _sdf->Get<double>("occlusion_steps"); | ||||||
} | ||||||
|
||||||
const std::string compositorName = "compositor"; | ||||||
if (_sdf->HasElement(compositorName)) | ||||||
{ | ||||||
|
@@ -141,6 +149,17 @@ void LensFlareSensorPlugin::SetColor(const ignition::math::Vector3d &_color) | |||||
} | ||||||
} | ||||||
|
||||||
///////////////////////////////////////////////// | ||||||
void LensFlareSensorPlugin::SetOcclusionSteps(double _occlusionSteps) | ||||||
{ | ||||||
this->dataPtr->occlusionSteps = _occlusionSteps; | ||||||
|
||||||
for (auto flare : this->dataPtr->lensFlares) | ||||||
{ | ||||||
flare->SetOcclusionSteps(_occlusionSteps); | ||||||
} | ||||||
} | ||||||
|
||||||
///////////////////////////////////////////////// | ||||||
void LensFlareSensorPlugin::AddLensFlare(rendering::CameraPtr _camera) | ||||||
{ | ||||||
|
@@ -153,8 +172,10 @@ void LensFlareSensorPlugin::AddLensFlare(rendering::CameraPtr _camera) | |||||
{ | ||||||
lensFlare->SetCompositorName(this->dataPtr->compositorName); | ||||||
} | ||||||
lensFlare->SetCamera(_camera); | ||||||
lensFlare->SetScale(this->dataPtr->scale); | ||||||
lensFlare->SetColor(this->dataPtr->color); | ||||||
lensFlare->SetOcclusionSteps(this->dataPtr->occlusionSteps); | ||||||
// SetCamera must be called last | ||||||
lensFlare->SetCamera(_camera); | ||||||
this->dataPtr->lensFlares.push_back(lensFlare); | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
38fdb50