Prevent decorative elements from casting shadows.

PiperOrigin-RevId: 837112208
Change-Id: I4ecc110eec1a2166df7a07d8bb9ec37df36b7c89
This commit is contained in:
Haroon Qureshi
2025-11-26 07:26:51 -08:00
committed by Copybara-Service
parent 0425355efc
commit c7e0c01e80
3 changed files with 17 additions and 1 deletions
@@ -72,6 +72,10 @@ static constexpr int kArrow2BottomConeDisk = 4;
Drawable::Drawable(ObjectManager* object_mgr, const mjvGeom& geom)
: material_(object_mgr),
renderables_(object_mgr->GetEngine()) {
if (geom.category == mjCAT_DECOR) {
renderables_.DisableShadows();
}
switch ((mjtGeom)geom.type) {
case mjGEOM_MESH:
AddMesh(geom.dataid);
@@ -103,7 +103,7 @@ utils::Entity Renderables::CreateEntity(const FilamentBuffers& buffers) {
}
builder.boundingBox(buffers.bounds)
.culling(false)
.castShadows(true)
.castShadows(cast_shadows_)
.receiveShadows(true)
.layerMask(1, visible_ ? 1 : 0)
.screenSpaceContactShadows(true);
@@ -197,4 +197,12 @@ void Renderables::Show() {
}
}
void Renderables::DisableShadows() {
filament::RenderableManager& rm = engine_->getRenderableManager();
for (utils::Entity& entity : entities_) {
rm.setCastShadows(rm.getInstance(entity), false);
}
cast_shadows_ = false;
}
} // namespace mujoco
@@ -61,6 +61,9 @@ class Renderables {
// Returns true if the entities are visible.
bool IsVisible() const { return visible_; }
// Disables the renderables from casting shadows.
void DisableShadows();
// Adds all managed entities to the given filament Scene.
void AddToScene(filament::Scene* scene);
@@ -84,6 +87,7 @@ class Renderables {
std::vector<utils::Entity> entities_;
std::vector<std::optional<FilamentBuffers>> owned_buffers_;
bool visible_ = true;
bool cast_shadows_ = true;
};
} // namespace mujoco