Skip to content

Commit

Permalink
Add occlusion via rooms & portals
Browse files Browse the repository at this point in the history
  • Loading branch information
lawnjelly committed Sep 28, 2023
1 parent 0abde43 commit c506454
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 33 deletions.
3 changes: 3 additions & 0 deletions enemies/red_robot/red_robot.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func _ready():
$AnimationTree.active = true
if test_shoot:
shoot_countdown = 0.0

# Make sure shows up when portals are on.
Portals.change_portal_mode_recursive(self, CullInstance.PORTAL_MODE_ROAMING)


func resume_approach():
Expand Down
4 changes: 2 additions & 2 deletions enemies/red_robot/red_robot.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ nodes/hit3/position = Vector2( 980, 240 )
nodes/output/position = Vector2( 1180, 200 )
nodes/state/node = SubResource( 51 )
nodes/state/position = Vector2( 60, 100 )
node_connections = [ "state", 0, "Animation", "state", 1, "Animation 3", "state", 2, "Animation 2", "state", 3, "Animation 4", "output", 0, "hit3", "hit2", 0, "hit1", "hit2", 1, "Animation 6", "aiming", 0, "state", "aiming", 1, "aim", "hit1", 0, "aiming", "hit1", 1, "Animation 5", "hit3", 0, "hit2", "hit3", 1, "Animation 7" ]
node_connections = [ "aiming", 0, "state", "aiming", 1, "aim", "hit1", 0, "aiming", "hit1", 1, "Animation 5", "hit2", 0, "hit1", "hit2", 1, "Animation 6", "hit3", 0, "hit2", "hit3", 1, "Animation 7", "output", 0, "hit3", "state", 0, "Animation", "state", 1, "Animation 3", "state", 2, "Animation 2", "state", 3, "Animation 4" ]

[sub_resource type="SphereShape" id=53]
radius = 1.11815
Expand Down Expand Up @@ -771,7 +771,7 @@ script = ExtResource( 1 )
bones/14/bound_children = [ NodePath("RayFrom") ]

[node name="RayFrom" type="BoneAttachment" parent="RedRobotModel/Armature/Skeleton" index="4"]
transform = Transform( -0.999676, 0.0252579, 0.00304912, 0.0252842, 0.99964, 0.00893937, -0.00282223, 0.00901357, -0.999955, 0.0411851, 2.0763, 0.18828 )
transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, -1, 1.04199e-07, 1.9381, 0.190446 )
bone_name = "CannonAnimRecoil"

[node name="Circle" type="MeshInstance" parent="RedRobotModel/Armature/Skeleton/RayFrom"]
Expand Down
3 changes: 3 additions & 0 deletions level/forklift/flying_forklift.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ func _ready():
for i in range(child_count):
children[i].visible = i == which_enabled

# Make sure shows up when portals are on.
Portals.change_portal_mode_recursive(self, CullInstance.PORTAL_MODE_ROAMING)


# TODO: We can maybe implement func hit():
3 changes: 3 additions & 0 deletions level/geometry/scenes/core.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ mesh = ExtResource( 7 )

[node name="CPUParticles" type="CPUParticles" parent="Plasma"]
physics_interpolation_mode = 1
portal_mode = 1
material_override = SubResource( 20 )
amount = 3
preprocess = 5.29
Expand All @@ -236,6 +237,7 @@ color_ramp = SubResource( 22 )

[node name="CPUParticles2" type="CPUParticles" parent="Plasma"]
physics_interpolation_mode = 1
portal_mode = 1
material_override = SubResource( 23 )
amount = 5
mesh = ExtResource( 12 )
Expand All @@ -251,6 +253,7 @@ color_ramp = SubResource( 25 )

[node name="CPUParticles3" type="CPUParticles" parent="Plasma"]
physics_interpolation_mode = 1
portal_mode = 1
material_override = SubResource( 23 )
amount = 7
explosiveness = 0.14
Expand Down
10 changes: 10 additions & 0 deletions level/level.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ signal replace_main_scene # Useless, but needed as there is no clean way to chec
onready var world_environment = $WorldEnvironment

func _ready():
$RoomManager.call_deferred("rooms_convert")

if Settings.gi_quality == Settings.GIQuality.HIGH:
ProjectSettings["rendering/quality/voxel_cone_tracing/high_quality"] = true
elif Settings.gi_quality == Settings.GIQuality.LOW:
Expand Down Expand Up @@ -70,3 +72,11 @@ func _input(event):
if event.is_action_pressed("quit"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
emit_signal("quit")

if event.is_action_pressed("ui_portals"):
if $RoomManager.rooms_get_active():
$RoomManager.rooms_set_active(false)
print("portals off")
else:
$RoomManager.rooms_set_active(true)
print("portals on")
69 changes: 47 additions & 22 deletions level/level.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[gd_scene load_steps=37 format=2]

[ext_resource path="res://level/level.gd" type="Script" id=1]
[ext_resource path="res://level/geometry/scenes/props.tscn" type="PackedScene" id=2]
[ext_resource path="res://level/geometry/giprobe_data.res" type="GIProbeData" id=5]
[ext_resource path="res://player/player.tscn" type="PackedScene" id=6]
[ext_resource path="res://enemies/red_robot/red_robot.tscn" type="PackedScene" id=7]
[ext_resource path="res://level/geometry/scenes/core.tscn" type="PackedScene" id=2]
[ext_resource path="res://player/player.tscn" type="PackedScene" id=3]
[ext_resource path="res://enemies/red_robot/red_robot.tscn" type="PackedScene" id=4]
[ext_resource path="res://level/geometry/scenes/props.tscn" type="PackedScene" id=5]
[ext_resource path="res://level/geometry/environment.tres" type="Environment" id=6]
[ext_resource path="res://level/geometry/giprobe_data.res" type="GIProbeData" id=7]
[ext_resource path="res://level/level_music.ogg" type="AudioStream" id=8]
[ext_resource path="res://level/debug.gd" type="Script" id=9]
[ext_resource path="res://level/forklift/flying_forklift.tscn" type="PackedScene" id=12]
[ext_resource path="res://level/geometry/scenes/lights.tscn" type="PackedScene" id=13]
[ext_resource path="res://level/geometry/scenes/core.tscn" type="PackedScene" id=14]
[ext_resource path="res://level/geometry/scenes/structure.tscn" type="PackedScene" id=15]
[ext_resource path="res://level/geometry/environment.tres" type="Environment" id=16]
[ext_resource path="res://level/geometry/scenes/structure.tscn" type="PackedScene" id=10]
[ext_resource path="res://level/forklift/flying_forklift.tscn" type="PackedScene" id=11]
[ext_resource path="res://level/geometry/scenes/lights.tscn" type="PackedScene" id=12]

[sub_resource type="CapsuleShape" id=1]
radius = 39.7506
Expand Down Expand Up @@ -103,31 +103,53 @@ polygon_points = PoolVector2Array( 26.3687, -60.868, -21.2648, 34.8682, 17.8021,
[node name="Level" type="Spatial"]
script = ExtResource( 1 )

[node name="Core" parent="." instance=ExtResource( 14 )]
[node name="RoomManager" type="RoomManager" parent="."]
roomlist = NodePath("../RoomList")
gameplay_monitor = true
show_margins = false

[node name="Structure" parent="." instance=ExtResource( 15 )]
[node name="RoomList" type="Spatial" parent="."]

[node name="Props" parent="." instance=ExtResource( 2 )]
[node name="Lights" parent="RoomList" instance=ExtResource( 12 )]

[node name="Lights" parent="." instance=ExtResource( 13 )]
[node name="Room_Structure" type="Room" parent="RoomList"]
points = PoolVector3Array( 105.313, -44.2188, -111.056, 105.313, -44.2188, 115.054, 105.313, 47.0312, -111.056, 105.313, 47.0312, 115.054, -115.713, -44.2188, -111.056, -115.713, -44.2188, 115.054, -115.713, 47.0312, -111.056, -115.713, 47.0312, 115.054 )

[node name="Structure" parent="RoomList/Room_Structure" instance=ExtResource( 10 )]

[node name="Props" parent="RoomList/Room_Structure" instance=ExtResource( 5 )]

[node name="RoomGroup_Core" type="RoomGroup" parent="RoomList"]
roomgroup_priority = 1

[node name="Room_Core" type="Room" parent="RoomList/RoomGroup_Core"]
points = PoolVector3Array( 42.7086, -31.1906, -42.1428, 42.7086, 20.3199, -42.1428, -41.2881, -31.1906, -42.1428, -41.2881, 20.3199, -42.1428, 42.7086, -31.1906, 5.68789, 42.7086, 20.3199, 5.68789, -41.2881, -31.1906, 41.2592, 31.1507, -31.1906, 41.2592, -41.2881, 20.3199, 41.2592, 31.1507, 20.3199, 41.2592 )

[node name="Core" parent="RoomList/RoomGroup_Core/Room_Core" instance=ExtResource( 2 )]

[node name="Portal" type="Portal" parent="RoomList/RoomGroup_Core/Room_Core"]
transform = Transform( -0.309017, 0, -0.951056, 0, 1, 0, 0.951056, 0, -0.309017, 40.424, -4.63176, 12.7192 )
points = PoolVector2Array( 3.01481, -1.4125, 2.82033, 1.86893, -2.53423, 2.07699, -2.62032, -1.4285 )

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource( 16 )
environment = ExtResource( 6 )

[node name="GIProbe" type="GIProbe" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.09263, 1.28266, 2.88598 )
portal_mode = 3
subdiv = 2
extents = Vector3( 113.946, 48.8048, 117.028 )
energy = 4.0
propagation = 1.0
interior = true
data = ExtResource( 5 )
data = ExtResource( 7 )

[node name="ReflectionProbes" type="Spatial" parent="."]
visible = false

[node name="ReflectionProbe1" type="ReflectionProbe" parent="ReflectionProbes"]
transform = Transform( 0.494055, 0, -0.869431, 0, 1, 0, 0.869431, 0, 0.494055, 28.1433, -18.8082, 71.0693 )
portal_mode = 3
extents = Vector3( 37.3556, 50, 83.0437 )
box_projection = true
interior_enable = true
Expand All @@ -137,6 +159,7 @@ interior_ambient_contrib = 0.8

[node name="ReflectionProbe2" type="ReflectionProbe" parent="ReflectionProbes"]
transform = Transform( 0.999799, 0, -0.0200534, 0, 1, 0, 0.0200534, 0, 0.999799, 73.9972, 0, -12.2086 )
portal_mode = 3
extents = Vector3( 35.8169, 50, 64.5769 )
box_projection = true
interior_enable = true
Expand All @@ -146,26 +169,27 @@ interior_ambient_contrib = 0.8

[node name="ReflectionProbe3" type="ReflectionProbe" parent="ReflectionProbes"]
transform = Transform( 0.999799, 0, -0.0200534, 0, 1, 0, 0.0200534, 0, 0.999799, -0.392717, -7.57649, 0.0575469 )
portal_mode = 3
extents = Vector3( 38.9134, 50, 37.1232 )
box_projection = true
interior_enable = true
interior_ambient_color = Color( 0.2, 0.1595, 0.11, 1 )
interior_ambient_energy = 16.0
interior_ambient_contrib = 0.8

[node name="Player" parent="." instance=ExtResource( 6 )]
[node name="Player" parent="." instance=ExtResource( 3 )]
transform = Transform( -0.575826, 0, -0.817573, 0, 1, 0, 0.817573, 0, -0.575826, 64.8183, -1.0765, 78.7639 )

[node name="RedRobot1" parent="." instance=ExtResource( 7 )]
[node name="RedRobot1" parent="." instance=ExtResource( 4 )]
transform = Transform( 0.843905, 0, -0.536493, 0, 1, 0, 0.536493, 0, 0.843905, 71.5907, -6.05686, 46.2736 )

[node name="RedRobot2" parent="." instance=ExtResource( 7 )]
[node name="RedRobot2" parent="." instance=ExtResource( 4 )]
transform = Transform( 0.338334, 0, 0.941027, 0, 1, 0, -0.941027, 0, 0.338334, 53.2126, -6.05686, 15.9321 )

[node name="RedRobot3" parent="." instance=ExtResource( 7 )]
[node name="RedRobot3" parent="." instance=ExtResource( 4 )]
transform = Transform( -0.164432, 0, 0.986389, 0, 1, 0, -0.986389, 0, -0.164432, -2.96096, -11.6923, 20.2343 )

[node name="RedRobot4" parent="." instance=ExtResource( 7 )]
[node name="RedRobot4" parent="." instance=ExtResource( 4 )]
transform = Transform( -0.164432, 0, 0.986389, 0, 1, 0, -0.986389, 0, -0.164432, -9.15526, -11.6923, -16.9238 )

[node name="Music" type="AudioStreamPlayer" parent="."]
Expand Down Expand Up @@ -193,10 +217,10 @@ shape = SubResource( 1 )

[node name="FlyingForklifts" type="Spatial" parent="."]

[node name="FlyingForklift1" parent="FlyingForklifts" instance=ExtResource( 12 )]
[node name="FlyingForklift1" parent="FlyingForklifts" instance=ExtResource( 11 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 67.8049, 2.27771, 0 )

[node name="FlyingForklift2" parent="FlyingForklifts" instance=ExtResource( 12 )]
[node name="FlyingForklift2" parent="FlyingForklifts" instance=ExtResource( 11 )]
transform = Transform( -1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1, -68.2496, 2.27771, 0 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="FlyingForklifts"]
Expand All @@ -218,6 +242,7 @@ __meta__ = {
}

[node name="Occluders" type="Spatial" parent="."]
visible = false

[node name="StartWall" type="Occluder" parent="Occluders"]
transform = Transform( 0.137929, 0, 0.990442, 0, 1, 0, -0.990442, 0, 0.137929, -6.13814, 0, 82.9737 )
Expand Down
12 changes: 12 additions & 0 deletions main/portals.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends Node

func change_portal_mode_recursive(node : Node, portal_mode):
if node is MeshInstance:
node.portal_mode = portal_mode
if node is CPUParticles:
node.portal_mode = portal_mode
if node is Particles:
node.portal_mode = portal_mode

for i in range (0, node.get_child_count()):
change_portal_mode_recursive(node.get_child(i), portal_mode)
4 changes: 4 additions & 0 deletions player/bullet/bullet.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ var hit = false
onready var animation_player = $AnimationPlayer
onready var collision_shape = $CollisionShape

func _ready():
# Make sure shows up when portals are on.
Portals.change_portal_mode_recursive(self, CullInstance.PORTAL_MODE_GLOBAL)

func _physics_process(delta):
if hit:
return
Expand Down
3 changes: 3 additions & 0 deletions player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func _ready():
# Pre-initialize orientation transform.
orientation = player_model.global_transform
orientation.origin = Vector3()

# Make sure player shows up when portals are on.
Portals.change_portal_mode_recursive(self, CullInstance.PORTAL_MODE_GLOBAL)


func _process(delta):
Expand Down
7 changes: 2 additions & 5 deletions player/player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ nodes/walk/node = SubResource( 29 )
nodes/walk/position = Vector2( -460, 40 )
nodes/walk_speed/node = SubResource( 36 )
nodes/walk_speed/position = Vector2( -280, 60 )
node_connections = [ "state", 0, "strafe_speed", "state", 1, "walk_speed", "state", 2, "jumpup", "state", 3, "jumpdown", "output", 0, "eye_blend", "aim", 0, "aimdown", "aim", 1, "land", "aim", 2, "aimup", "strafe_speed", 0, "strafe", "walk_speed", 0, "walk", "eye_blend", 0, "aim", "eye_blend", 1, "eyes", "land", 0, "state", "land", 1, "hardland" ]
node_connections = [ "aim", 0, "aimdown", "aim", 1, "land", "aim", 2, "aimup", "eye_blend", 0, "aim", "eye_blend", 1, "eyes", "land", 0, "state", "land", 1, "hardland", "output", 0, "eye_blend", "state", 0, "strafe_speed", "state", 1, "walk_speed", "state", 2, "jumpup", "state", 3, "jumpdown", "strafe_speed", 0, "strafe", "walk_speed", 0, "walk" ]

[sub_resource type="CapsuleShape" id=31]
radius = 0.5
Expand Down Expand Up @@ -309,11 +309,8 @@ script = ExtResource( 1 )
[node name="Robot_Skeleton" parent="PlayerModel" index="0"]
transform = Transform( 0.803991, 0, 0, 0, 0.803991, 0, 0, 0, 0.803991, 0, 0, 0 )

[node name="Skeleton" parent="PlayerModel/Robot_Skeleton" index="0"]
bones/55/bound_children = [ NodePath("GunBone") ]

[node name="GunBone" type="BoneAttachment" parent="PlayerModel/Robot_Skeleton/Skeleton" index="5"]
transform = Transform( 0.91932, -0.392972, -0.0252594, -0.0172128, 0.0239966, -0.999572, 0.393456, 0.919237, 0.0152949, -0.20712, 1.3628, 0.544873 )
transform = Transform( 0.26227, 0.157959, -0.951995, 0.562358, 0.77673, 0.283771, 0.784361, -0.609705, 0.11487, -0.3262, 1.07735, -0.0608009 )
bone_name = "hand.R"

[node name="ShootFrom" type="Position3D" parent="PlayerModel/Robot_Skeleton/Skeleton/GunBone"]
Expand Down
17 changes: 13 additions & 4 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ config/icon="res://icon.png"
[autoload]

Settings="*res://menu/settings.gd"
Portals="*res://main/portals.gd"

[debug]

settings/stdout/print_fps=true

[display]

window/size/width=1920
window/size/height=1080
window/size/fullscreen=true
window/vsync/use_vsync=false
window/stretch/mode="2d"
window/stretch/aspect="expand"

Expand Down Expand Up @@ -157,13 +161,13 @@ jump={
}
aim={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":6,"pressure":0.0,"pressed":false,"script":null)
]
}
shoot={
"deadzone": 0.5,
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"doubleclick":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
]
}
Expand Down Expand Up @@ -204,6 +208,11 @@ toggle_debug={
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777246,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
ui_portals={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":80,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}

[layer_names]

Expand Down

0 comments on commit c506454

Please sign in to comment.