Skip to content

Commit

Permalink
Only set shadow texture size if configured by the user in the SDForma…
Browse files Browse the repository at this point in the history
…t file (#642)

Signed-off-by: Addisu Z. Taddese <[email protected]>
  • Loading branch information
azeey authored Sep 16, 2024
1 parent ce5315c commit 7e1d64f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/plugins/minimal_scene/MinimalScene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,12 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi)
scene->SetSkyEnabled(true);
}

if (!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
this->directionalLightTextureSize))
if (this->directionalLightTextureSize.has_value() &&
!scene->SetShadowTextureSize(rendering::LightType::DIRECTIONAL,
*this->directionalLightTextureSize))
{
gzerr << "Unable to set directional light shadow <texture_size> to '"
<< this->directionalLightTextureSize
<< *this->directionalLightTextureSize
<< "'. Using default texture size of "
<< scene->ShadowTextureSize(rendering::LightType::DIRECTIONAL)
<< std::endl;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/minimal_scene/MinimalScene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <string>
#include <memory>
#include <optional>

#include <gz/common/KeyEvent.hh>
#include <gz/common/MouseEvent.hh>
Expand Down Expand Up @@ -240,7 +241,7 @@ namespace gz::gui::plugins
public: bool skyEnable = false;

/// \brief Shadow texture size for directional light
public: unsigned int directionalLightTextureSize = 2048u;
public: std::optional<unsigned int> directionalLightTextureSize;

/// \brief Horizontal FOV of the camera;
public: math::Angle cameraHFOV = math::Angle(M_PI * 0.5);
Expand Down

0 comments on commit 7e1d64f

Please sign in to comment.