38 if (!owner || !owner->engine()) {
39 spdlog::error(
"ShadowCatcher::initialize — no owner entity or engine");
44 _planeEntity =
new Entity();
45 _planeEntity->setEngine(owner->engine());
51 _material->setName(
"shadow-catcher");
52 _material->setDiffuse(
Color(0.0f, 0.0f, 0.0f, 1.0f));
53 _material->setSpecular(
Color(0.0f, 0.0f, 0.0f, 1.0f));
54 _material->setEmissive(
Color(0.0f, 0.0f, 0.0f, 1.0f));
55 _material->setUseSkybox(
false);
56 _material->setUseFog(
false);
57 _material->setShadowCatcher(
true);
61 _material->setBlendState(blendState);
62 _material->setTransparent(
true);
67 _material->setDepthState(depthState);
72 renderComp->setMaterial(_material);
73 renderComp->setType(
"plane");
76 for (
auto* mi : renderComp->meshInstances()) {
77 mi->setCastShadow(
false);
79 spdlog::info(
"ShadowCatcher: RenderComponent created, {} mesh instances",
80 renderComp->meshInstances().size());
82 spdlog::error(
"ShadowCatcher: failed to add RenderComponent to plane entity");
86 _planeEntity->setLocalPosition(0.0f, _yOffset, 0.0f);
87 _planeEntity->setLocalScale(
Vector3(_planeScale, 1.0f, _planeScale));
90 owner->addChild(_planeEntity);
92 spdlog::info(
"ShadowCatcher: created {}x{} shadow plane at y={:.1f}, transparent={}, shadowCatcher={}",
93 _planeScale, _planeScale, _yOffset, _material->transparent(), _material->shadowCatcher());