Skip to content

Commit

Permalink
feat/godot-3-5 (#60)
Browse files Browse the repository at this point in the history
* Replaced float literal syntax in stylized water shader to work with Godot 3.5 RC 2

* Fixed bug of water cutting through other assets/shaders; Implemented portal labels.

Co-authored-by: Telmo Valverde <[email protected]>
  • Loading branch information
telmotrooper and telmotrooper authored May 26, 2022
1 parent 5d570a4 commit b1e74c0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 83 deletions.
3 changes: 1 addition & 2 deletions maps/mountain_map.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ tracks/1/keys = {
}

[sub_resource type="CylinderShape" id=5]
radius = 5.0
height = 5.0
radius = 5.0

[node name="MontainMap" type="Spatial"]
script = ExtResource( 3 )
Expand Down Expand Up @@ -115,7 +115,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 66.935, 9.89507, 94.6744 )
[node name="WaterPlane" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 54.2274, -2.38324, 91.0514 )
mesh = SubResource( 2 )
material/0 = null

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/RESET = SubResource( 4 )
Expand Down
5 changes: 2 additions & 3 deletions maps/test_map.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ __meta__ = {
"_editor_description_": "One of the most simple setup. The Scatter node have a ScatterItem child. This child tells you what scene to scatter around.
The parent node have a stack of modifiers. First randomly distribute points, the second moves them around randomly. You can add as many modifier as you want in any order, but make sure to start with a \"Distribute\" modifier."
}
modifier_stack = Object(Node,"_import_path":NodePath(""),"pause_mode":0,"process_priority":0,"script":Resource( "res://addons/scatter/src/core/modifier_stack.gd" ),"stack":[ Object(Node,"_import_path":NodePath(""),"pause_mode":0,"process_priority":0,"script":Resource( "res://addons/scatter/src/modifiers/distribute_inside_random.gd" ),"enabled":true,"display_name":"Distribute Inside (Random)","category":"Distribute","warning":"","warning_ignore_no_transforms":true,"warning_ignore_no_path":false,"override_global_seed":false,"custom_seed":0,"instance_count":3000,"_rng":Object(RandomNumberGenerator,"seed":7796409484863506231,"state":1715213465578901578,"script":null)
modifier_stack = Object(Node,"_import_path":NodePath(""),"pause_mode":0,"physics_interpolation_mode":0,"unique_name_in_owner":false,"process_priority":0,"script":Resource( "res://addons/scatter/src/core/modifier_stack.gd" ),"stack":[ Object(Node,"_import_path":NodePath(""),"pause_mode":0,"physics_interpolation_mode":0,"unique_name_in_owner":false,"process_priority":0,"script":Resource( "res://addons/scatter/src/modifiers/distribute_inside_random.gd" ),"enabled":true,"display_name":"Distribute Inside (Random)","category":"Distribute","warning":"","warning_ignore_no_transforms":true,"warning_ignore_no_path":false,"override_global_seed":false,"custom_seed":0,"instance_count":3000,"_rng":Object(RandomNumberGenerator,"seed":7796409484863506231,"state":1715213465578901578,"script":null)
)
, Object(Node,"_import_path":NodePath(""),"pause_mode":0,"process_priority":0,"script":Resource( "res://addons/scatter/src/modifiers/randomize_transforms.gd" ),"enabled":true,"display_name":"Randomize Transforms","category":"Edit","warning":"","warning_ignore_no_transforms":false,"warning_ignore_no_path":true,"override_global_seed":false,"custom_seed":0,"local_space":true,"position":Vector3( 0, 0, 0 ),"rotation":Vector3( 0, 180, 0 ),"scale":Vector3( 1, 1, 1 ),"_rng":Object(RandomNumberGenerator,"seed":5570693362334884271,"state":3772973385647095650,"script":null)
, Object(Node,"_import_path":NodePath(""),"pause_mode":0,"physics_interpolation_mode":0,"unique_name_in_owner":false,"process_priority":0,"script":Resource( "res://addons/scatter/src/modifiers/randomize_transforms.gd" ),"enabled":true,"display_name":"Randomize Transforms","category":"Edit","warning":"","warning_ignore_no_transforms":false,"warning_ignore_no_path":true,"override_global_seed":false,"custom_seed":0,"local_space":true,"position":Vector3( 0, 0, 0 ),"rotation":Vector3( 0, 180, 0 ),"scale":Vector3( 1, 1, 1 ),"_rng":Object(RandomNumberGenerator,"seed":5570693362334884271,"state":3772973385647095650,"script":null)
)
],"just_created":false,"undo_redo":Object(UndoRedo,"script":null)
)
Expand Down Expand Up @@ -303,7 +303,6 @@ transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 61.775,
[node name="WaterPlane" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.583241, -76.0941 )
mesh = SubResource( 12 )
material/0 = null

[node name="Spaceship" parent="." instance=ExtResource( 13 )]
transform = Transform( 1.40736, 0.518979, 0, -0.518979, 1.40736, 0, 0, 0, 1.5, 0.0366802, 1.80064, 14.178 )
Expand Down
3 changes: 3 additions & 0 deletions props/portal/portal_placeholder.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ extends CSGCylinder

export var map_name: String

func _ready():
$Label3D.text = map_name

func _on_Portal_entered(_body):
#$AudioStreamPlayer.play()
GameState.Player.get_node("EffectsAnimationPlayer").play("shrink")
Expand Down
10 changes: 9 additions & 1 deletion props/portal/portal_placeholder.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://props/portal/portal_placeholder.gd" type="Script" id=1]
[ext_resource path="res://fonts/montserrat_extra_bold_48.tres" type="DynamicFont" id=2]

[sub_resource type="SpatialMaterial" id=19]
albedo_color = Color( 0.639216, 0.141176, 0.141176, 1 )
Expand All @@ -27,4 +28,11 @@ shape = SubResource( 20 )
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
bus = "Sound"

[node name="Label3D" type="Label3D" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6.2, 0 )
pixel_size = 0.025
billboard = 2
text = "Portal"
font = ExtResource( 2 )

[connection signal="body_entered" from="Area" to="." method="_on_Portal_entered"]
70 changes: 0 additions & 70 deletions shaders/stylized_water/simple_stylized_water.shader

This file was deleted.

14 changes: 7 additions & 7 deletions shaders/stylized_water/stylized_water.shader
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ uniform float _distance = 0.0;
uniform vec4 edge_color: hint_color;
uniform float edge_scale = 0.25;
uniform float near = 0.1;
uniform float far = 100f;
uniform float far = 100.0;

// wave var
uniform vec2 wave_strength = vec2(0.5, 0.25);
Expand All @@ -34,7 +34,7 @@ void vertex() {
}

float rim(float depth) {
depth = 2f * depth - 1f;
depth = 2.0 * depth - 1.0;
return near * far / (far + depth * (near - far));
}

Expand Down Expand Up @@ -65,10 +65,10 @@ void fragment() {
vec3 n1 = texture(noise1, UV + time).rgb;
vec3 n2 = texture(noise2, UV - time * 0.2).rgb;

vec2 uv_movement = UV * 4f;
uv_movement += TIME * speed * 4f;
vec2 uv_movement = UV * 4.0;
uv_movement += TIME * speed * 4.0;

float sum = (n1.r + n2.r) - 1f;
float sum = (n1.r + n2.r) - 1.0;

float z_depth = rim(texture(DEPTH_TEXTURE, SCREEN_UV).x);
float z_pos = rim(FRAGCOORD.z);
Expand All @@ -82,7 +82,7 @@ void fragment() {
vec4 gradientcolor = mix(color, deep_water, z_depth_fade);

vec2 displacement = vec2(sum * 0.1);
diff += displacement.x * 70f;
diff += displacement.x * 70.0;

vec4 col = mix(edge_color, gradientcolor, step(edge_scale, diff));

Expand All @@ -92,7 +92,7 @@ void fragment() {
float fin = 0.0;
if (sum > 0.0 && sum < 0.4) fin = 0.1;
if (sum > 0.4 && sum < 0.8) fin = 0.0;
if (sum > 0.8) fin = 1f;
if (sum > 0.8) fin = 1.0;

// konvertier fin in vec3 um
ALBEDO = vec3(fin) + mix(alpha.rgb, col.rgb, gradientcolor.a);
Expand Down
1 change: 1 addition & 0 deletions shaders/stylized_water/stylized_water_material.tres
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bump_strength = 4.0
noise = SubResource( 5 )

[resource]
render_priority = -1
shader = ExtResource( 1 )
shader_param/speed = 0.021
shader_param/color = Color( 0.0352941, 0.658824, 0.929412, 0.635294 )
Expand Down

0 comments on commit b1e74c0

Please sign in to comment.