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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only set shadow texture size if configured by the user in the SDFormat file #642

Merged
merged 1 commit into from
Sep 16, 2024
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
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
Loading