From 375ef99a97af4456237418eb5c9f426260dd3f3c Mon Sep 17 00:00:00 2001 From: yvain Date: Sun, 18 Aug 2024 11:44:52 +0200 Subject: [PATCH 1/2] check for visible and visibleShadows for rendering. --- Sources/iron/Scene.hx | 2 +- Sources/iron/data/SceneFormat.hx | 1 + Sources/iron/object/LightObject.hx | 3 ++- Sources/iron/object/MeshObject.hx | 5 +++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/iron/Scene.hx b/Sources/iron/Scene.hx index bd779f7f..2f4a95a2 100644 --- a/Sources/iron/Scene.hx +++ b/Sources/iron/Scene.hx @@ -828,8 +828,8 @@ class Scene { object.raw = o; object.name = o.name; if (o.visible != null) object.visible = o.visible; - if (o.visible_mesh != null) object.visibleMesh = o.visible_mesh; if (o.visible_shadow != null) object.visibleShadow = o.visible_shadow; + createConstraints(o.constraints, object); generateTransform(o, object.transform); object.setupAnimation(oactions); diff --git a/Sources/iron/data/SceneFormat.hx b/Sources/iron/data/SceneFormat.hx index 11313647..f804647c 100644 --- a/Sources/iron/data/SceneFormat.hx +++ b/Sources/iron/data/SceneFormat.hx @@ -451,6 +451,7 @@ typedef TObj = { @:optional public var visible: Null; @:optional public var visible_mesh: Null; @:optional public var visible_shadow: Null; + @:optional public var only_shadows: Null; @:optional public var mobile: Null; @:optional public var spawn: Null; // Auto add object when creating scene @:optional public var local_only: Null; // Apply parent matrix diff --git a/Sources/iron/object/LightObject.hx b/Sources/iron/object/LightObject.hx index 10866bc1..ec73309c 100644 --- a/Sources/iron/object/LightObject.hx +++ b/Sources/iron/object/LightObject.hx @@ -16,9 +16,10 @@ class LightObject extends Object { #if arm_shadowmap_atlas public var tileNotifyOnRemove: Void -> Void; public var lightInAtlas = false; + public var lightInAtlasTransparent = false; public var culledLight = false; public static var pointLightsData: kha.arrays.Float32Array = null; - public var shadowMapScale = 1.0; // When in forward if this defaults to 0.0, the atlas are not drawn before being bound. + public var shadowMapScale = 0.0; // When in forward if this defaults to 0.0, the atlas are not drawn before being bound. // Data used in uniforms public var tileOffsetX: Array = [0.0]; public var tileOffsetY: Array = [0.0]; diff --git a/Sources/iron/object/MeshObject.hx b/Sources/iron/object/MeshObject.hx index 15f1ed26..80c78fc0 100644 --- a/Sources/iron/object/MeshObject.hx +++ b/Sources/iron/object/MeshObject.hx @@ -161,7 +161,7 @@ class MeshObject extends Object { if (!isLodMaterial() && !validContext(mats, context)) return true; var isShadow = context == "shadowmap"; - if (!visibleMesh && !isShadow) return setCulled(isShadow, true); + if (!visible && !isShadow) return setCulled(isShadow, true); if (!visibleShadow && isShadow) return setCulled(isShadow, true); if (skip_context == context) return setCulled(isShadow, true); @@ -230,7 +230,8 @@ class MeshObject extends Object { public function render(g: Graphics, context: String, bindParams: Array) { if (data == null || !data.geom.ready) return; // Data not yet streamed - if (!visible) return; // Skip render if object is hidden + if (!visible && !visibleShadow) return; // Skip render if object is hidden + if ((visibleShadow && !visible) && context != "voxel" && context != "shadowmap") return; if (cullMesh(context, Scene.active.camera, RenderPath.active.light)) return; var meshContext = raw != null ? context == "mesh" : false; From a6c023c8a88aa33216bf2b4d8e9eeea18f16b393 Mon Sep 17 00:00:00 2001 From: e2002e Date: Tue, 20 Aug 2024 13:36:06 +0200 Subject: [PATCH 2/2] Update LightObject.hx --- Sources/iron/object/LightObject.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/iron/object/LightObject.hx b/Sources/iron/object/LightObject.hx index ec73309c..8570d6ea 100644 --- a/Sources/iron/object/LightObject.hx +++ b/Sources/iron/object/LightObject.hx @@ -19,7 +19,7 @@ class LightObject extends Object { public var lightInAtlasTransparent = false; public var culledLight = false; public static var pointLightsData: kha.arrays.Float32Array = null; - public var shadowMapScale = 0.0; // When in forward if this defaults to 0.0, the atlas are not drawn before being bound. + public var shadowMapScale = 1.0; // When in forward if this defaults to 0.0, the atlas are not drawn before being bound. // Data used in uniforms public var tileOffsetX: Array = [0.0]; public var tileOffsetY: Array = [0.0];