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

Visible shadows #215

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Sources/iron/Scene.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Sources/iron/data/SceneFormat.hx
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ typedef TObj = {
@:optional public var visible: Null<Bool>;
@:optional public var visible_mesh: Null<Bool>;
@:optional public var visible_shadow: Null<Bool>;
@:optional public var only_shadows: Null<Bool>;
@:optional public var mobile: Null<Bool>;
@:optional public var spawn: Null<Bool>; // Auto add object when creating scene
@:optional public var local_only: Null<Bool>; // Apply parent matrix
Expand Down
1 change: 1 addition & 0 deletions Sources/iron/object/LightObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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.
Expand Down
5 changes: 3 additions & 2 deletions Sources/iron/object/MeshObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -230,7 +230,8 @@ class MeshObject extends Object {

public function render(g: Graphics, context: String, bindParams: Array<String>) {
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;

Expand Down