Skip to content

Commit

Permalink
Hide transparent materials behind FoW, fixes #58
Browse files Browse the repository at this point in the history
  • Loading branch information
Scony committed Jul 14, 2023
1 parent bd2ec90 commit e16035d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/generic-scenes-and-nodes/3d/Circle3D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extends Node3D
set = _set_width
@export var color = Color.WHITE:
set = _set_color
@export var render_priority = 0:
@export var render_priority: int = 0: # TODO: report Godot bug here when no type hint present
set = _set_render_priority

var _plane = null
Expand Down
4 changes: 3 additions & 1 deletion source/match/Match.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ shader = ExtResource("10_weh6c")
shader_parameter/color = Color(0.85, 0.6596, 0.578, 1)
shader_parameter/max_density_height = -0.5
shader_parameter/min_density_height = 0.4
shader_parameter/max_height = 9999.0
shader_parameter/min_height = -0.05

[sub_resource type="QuadMesh" id="QuadMesh_pv7fp"]
flip_faces = true
Expand All @@ -110,7 +112,7 @@ viewport_path = NodePath("FogOfWar/CombinedViewport")

[sub_resource type="ShaderMaterial" id="ShaderMaterial_5rcuq"]
resource_local_to_scene = true
render_priority = 1
render_priority = 2
shader = ExtResource("13_jo8b7")
shader_parameter/color = Color(0, 0, 0, 1)
shader_parameter/texture_units_per_world_unit = 2
Expand Down
2 changes: 1 addition & 1 deletion source/match/units/traits/HealthBar.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ billboard = 1
transparent = false
no_depth_test = true
texture_filter = 2
render_priority = 127
render_priority = 1
texture = SubResource("GradientTexture2D_p6fyg")

[node name="Timer" type="Timer" parent="."]
Expand Down
2 changes: 1 addition & 1 deletion source/match/units/traits/Highlight.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ script = ExtResource("1_68q8u")

[node name="Circle3D" parent="." instance=ExtResource("2_u8emv")]
width = 5.0
render_priority = 127
render_priority = 1
2 changes: 1 addition & 1 deletion source/match/units/traits/Selection.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ script = ExtResource("1_be1f2")

[node name="FadedCircle3D" parent="." instance=ExtResource("1_fvq0j")]
inner_edge_width = 10.0
render_priority = 127
render_priority = 1
2 changes: 1 addition & 1 deletion source/match/units/traits/Targetability.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ script = ExtResource("1_75uog")

[node name="Circle3D" parent="." instance=ExtResource("2_w8wca")]
width = 5.0
render_priority = 127
render_priority = 1
6 changes: 6 additions & 0 deletions source/shaders/3d/fog.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ render_mode unshaded;
uniform vec4 color : source_color = vec4(1.0);
uniform float max_density_height = 0.0;
uniform float min_density_height = 1.0;
uniform float max_height = 9999.0;
uniform float min_height = -9999.0;
uniform sampler2D depth_texture : hint_depth_texture;

void vertex()
Expand All @@ -26,4 +28,8 @@ void fragment()
INV_VIEW_MATRIX * inverse(PROJECTION_MATRIX) * vec4(normalized_device_coordinates, 1.0);
world_position.xyz /= world_position.w;
ALPHA = smoothstep(min_density_height, max_density_height, world_position.y);
if (world_position.y < min_height || world_position.y > max_height)
{
ALPHA = 0.0;
}
}
2 changes: 1 addition & 1 deletion source/shaders/3d/simple_fog_of_war.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void fragment()
}
else
{
ALPHA = 1.0;
ALPHA = 0.0;
}
}

Expand Down

0 comments on commit e16035d

Please sign in to comment.