@@ -36,8 +36,7 @@ namespace gazebo
36
36
namespace rendering
37
37
{
38
38
// / \brief We'll create an instance of this class for each camera, to be
39
- // / used to inject lens flare uniforms and time (for animating flare)
40
- // / in each render call.
39
+ // / used to inject lens flare uniforms in each render call.
41
40
class LensFlareCompositorListener
42
41
: public Ogre::CompositorInstance::Listener
43
42
{
@@ -72,6 +71,13 @@ namespace gazebo
72
71
this ->scale = _scale;
73
72
}
74
73
74
+ // / \brief Set the color of lens flare.
75
+ // / \param[in] _color Color of lens flare
76
+ public: void SetColor (const ignition::math::Vector3d &_color)
77
+ {
78
+ this ->color = _color;
79
+ }
80
+
75
81
// / \brief Callback that OGRE will invoke for us on each render call
76
82
// / \param[in] _passID OGRE material pass ID.
77
83
// / \param[in] _mat Pointer to OGRE material.
@@ -97,9 +103,6 @@ namespace gazebo
97
103
pass->getFragmentProgramParameters ();
98
104
GZ_ASSERT (!params.isNull (), " Null OGRE material GPU parameters" );
99
105
100
- // used for animating flare
101
- params->setNamedConstant (" time" , static_cast <Ogre::Real>(
102
- common::Time::GetWallTime ().Double ()));
103
106
// for adjusting aspect ratio of flare
104
107
params->setNamedConstant (" viewport" ,
105
108
Ogre::Vector3 (static_cast <double >(this ->camera ->ViewportWidth ()),
@@ -133,6 +136,8 @@ namespace gazebo
133
136
params->setNamedConstant (" lightPos" , Conversions::Convert (pos));
134
137
params->setNamedConstant (" scale" ,
135
138
static_cast <Ogre::Real>(lensFlareScale));
139
+ params->setNamedConstant (" color" ,
140
+ Ogre::Vector3 (this ->color .X (), this ->color .Y (), this ->color .Z ()));
136
141
}
137
142
138
143
// / \brief Get the lens flare position and scale for a normal camera
@@ -338,6 +343,10 @@ namespace gazebo
338
343
339
344
// / \brief Scale of lens flare.
340
345
private: double scale = 1.0 ;
346
+
347
+ // / \brief Color of lens flare.
348
+ private: ignition::math::Vector3d color
349
+ = ignition::math::Vector3d(1.0 , 1.0 , 1.0 );
341
350
};
342
351
343
352
// / \brief Private data class for LensFlare
@@ -373,6 +382,10 @@ namespace gazebo
373
382
374
383
// / \brief Scale of lens flare.
375
384
public: double lensFlareScale = 1.0 ;
385
+
386
+ // / \brief Color of lens flare.
387
+ public: ignition::math::Vector3d lensFlareColor
388
+ = ignition::math::Vector3d(1.0 , 1.0 , 1.0 );
376
389
};
377
390
}
378
391
}
@@ -415,6 +428,8 @@ void LensFlare::SetCamera(CameraPtr _camera)
415
428
LensFlareCompositorListener (this ->dataPtr ->camera , nullptr ));
416
429
this ->dataPtr ->lensFlareCompositorListener ->SetScale (
417
430
this ->dataPtr ->lensFlareScale );
431
+ this ->dataPtr ->lensFlareCompositorListener ->SetColor (
432
+ this ->dataPtr ->lensFlareColor );
418
433
419
434
this ->dataPtr ->lensFlareInstance =
420
435
Ogre::CompositorManager::getSingleton ().addCompositor (
@@ -442,6 +457,19 @@ void LensFlare::SetScale(const double _scale)
442
457
}
443
458
}
444
459
460
+ // ////////////////////////////////////////////////
461
+ void LensFlare::SetColor (const ignition::math::Vector3d &_color)
462
+ {
463
+ // lensFlareColor is intentionally not clamped so the user can work in
464
+ // HDR color spaces or be artistic.
465
+ this ->dataPtr ->lensFlareColor = _color;
466
+ if (this ->dataPtr ->lensFlareCompositorListener )
467
+ {
468
+ this ->dataPtr ->lensFlareCompositorListener ->SetColor (
469
+ this ->dataPtr ->lensFlareColor );
470
+ }
471
+ }
472
+
445
473
// ////////////////////////////////////////////////
446
474
void LensFlare::Update ()
447
475
{
0 commit comments