Added water shader
parent
bd3d44a783
commit
4089a582e1
|
@ -21,7 +21,7 @@ var draw_island_bbox = false
|
|||
var zoom_sailing = 1.0
|
||||
var zoom_birdy = 4
|
||||
|
||||
var game_num_islands = 4
|
||||
var game_num_islands = 1
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
|
71
Menu.tscn
71
Menu.tscn
|
@ -6,12 +6,32 @@
|
|||
[node name="Menu" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
anchor_mode = 0
|
||||
current = true
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="CanvasLayer"]
|
||||
anchor_right = 1.0
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Camera2D"]
|
||||
rect_scale = Vector2( 0.4, 0.4 )
|
||||
custom_constants/separation = 64
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Camera2D/VBoxContainer"]
|
||||
margin_right = 1523.0
|
||||
margin_bottom = 445.0
|
||||
rect_scale = Vector2( 0.5, 0.5 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
texture = ExtResource( 2 )
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="Camera2D/VBoxContainer"]
|
||||
margin_top = 509.0
|
||||
margin_right = 1523.0
|
||||
margin_bottom = 509.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 5
|
||||
size_flags_vertical = 5
|
||||
alignment = 1
|
||||
|
@ -19,54 +39,35 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/HBoxContainer2"]
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Camera2D/VBoxContainer"]
|
||||
margin_top = 573.0
|
||||
margin_right = 1523.0
|
||||
margin_bottom = 445.0
|
||||
rect_scale = Vector2( 0.5, 0.5 )
|
||||
size_flags_horizontal = 13
|
||||
size_flags_vertical = 13
|
||||
texture = ExtResource( 2 )
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -278.0
|
||||
margin_top = -100.0
|
||||
margin_right = 278.0
|
||||
custom_constants/separation = 64
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/VBoxContainer"]
|
||||
margin_right = 556.0
|
||||
margin_bottom = -300.0
|
||||
margin_bottom = 673.0
|
||||
custom_constants/separation = 128
|
||||
|
||||
[node name="SimpleButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"]
|
||||
[node name="SimpleButton" type="Button" parent="Camera2D/VBoxContainer/HBoxContainer"]
|
||||
margin_right = 100.0
|
||||
margin_bottom = 100.0
|
||||
rect_min_size = Vector2( 100, 100 )
|
||||
text = "Leicht"
|
||||
|
||||
[node name="MediumButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"]
|
||||
[node name="MediumButton" type="Button" parent="Camera2D/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 228.0
|
||||
margin_right = 328.0
|
||||
margin_bottom = 100.0
|
||||
rect_min_size = Vector2( 100, 100 )
|
||||
text = "Mittel"
|
||||
|
||||
[node name="HardButton" type="Button" parent="CanvasLayer/VBoxContainer/HBoxContainer"]
|
||||
[node name="HardButton" type="Button" parent="Camera2D/VBoxContainer/HBoxContainer"]
|
||||
margin_left = 456.0
|
||||
margin_right = 556.0
|
||||
margin_bottom = 100.0
|
||||
rect_min_size = Vector2( 100, 100 )
|
||||
text = "Schwer"
|
||||
|
||||
[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/SimpleButton" to="." method="_on_SimpleButton_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/MediumButton" to="." method="_on_MediumButton_pressed"]
|
||||
[connection signal="pressed" from="CanvasLayer/VBoxContainer/HBoxContainer/HardButton" to="." method="_on_HardButton_pressed"]
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
follow_viewport_enable = true
|
||||
|
||||
[connection signal="pressed" from="Camera2D/VBoxContainer/HBoxContainer/SimpleButton" to="." method="_on_SimpleButton_pressed"]
|
||||
[connection signal="pressed" from="Camera2D/VBoxContainer/HBoxContainer/MediumButton" to="." method="_on_MediumButton_pressed"]
|
||||
[connection signal="pressed" from="Camera2D/VBoxContainer/HBoxContainer/HardButton" to="." method="_on_HardButton_pressed"]
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/water.png-60eb5d11192d61f791951f83acef7554.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/water.png"
|
||||
dest_files=[ "res://.import/water.png-60eb5d11192d61f791951f83acef7554.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=1
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
|
@ -0,0 +1,3 @@
|
|||
[gd_resource type="ImageTexture" format=2]
|
||||
|
||||
[resource]
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=29 format=2]
|
||||
[gd_scene load_steps=30 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/World.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scenes/Grid.gd" type="Script" id=2]
|
||||
|
@ -18,6 +18,7 @@
|
|||
[ext_resource path="res://assets/parrot.svg" type="Texture" id=16]
|
||||
[ext_resource path="res://assets/arrowback.svg" type="Texture" id=17]
|
||||
[ext_resource path="res://assets/arrowrepeat.svg" type="Texture" id=18]
|
||||
[ext_resource path="res://scenes/Water.tscn" type="PackedScene" id=19]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
size = 27
|
||||
|
@ -71,6 +72,11 @@ scale_curve = SubResource( 8 )
|
|||
|
||||
[node name="GameRoot" type="Node"]
|
||||
|
||||
[node name="WaterNode" parent="." instance=ExtResource( 19 )]
|
||||
position = Vector2( -102.276, -102.208 )
|
||||
scale = Vector2( 50, 50 )
|
||||
z_index = -5
|
||||
|
||||
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
|
||||
volume_db = -16.124
|
||||
autoplay = true
|
||||
|
@ -283,7 +289,6 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="DebugContainer" type="HBoxContainer" parent="World/UI"]
|
||||
visible = false
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -464,6 +469,8 @@ render_target_update_mode = 1
|
|||
|
||||
[node name="Camera2D" type="Camera2D" parent="IslandMapRenderer"]
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[connection signal="value_changed" from="Editor/UI/Editor/IslandIndex" to="Editor" method="_on_IslandIndex_value_changed"]
|
||||
[connection signal="pressed" from="Editor/UI/Editor/ClearWorldButton" to="Editor" method="_on_ClearWorldButton_pressed"]
|
||||
[connection signal="pressed" from="Editor/UI/Editor/LoadWorldButton" to="Editor" method="_on_LoadWorldButton_pressed"]
|
||||
|
|
|
@ -15,7 +15,6 @@ var obstacles_local_coords = {}
|
|||
var treasure_local_coords = null
|
||||
var highlight_treasure = false
|
||||
var prerender_texture = null
|
||||
var prerender = false
|
||||
var render_sprite = null
|
||||
|
||||
|
||||
|
@ -169,24 +168,15 @@ func draw_bsphere():
|
|||
|
||||
|
||||
func _draw():
|
||||
if prerender or highlight_treasure or render_sprite.texture == null:
|
||||
print ("Prerendering!")
|
||||
var transform = get_transform()
|
||||
|
||||
var transform = get_transform()
|
||||
for coord in tiles.keys():
|
||||
draw_set_transform (coord + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.get_tile_color(tiles[coord]))
|
||||
|
||||
for coord in tiles.keys():
|
||||
draw_set_transform (coord + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.get_tile_color(tiles[coord]))
|
||||
|
||||
if highlight_treasure and treasure_local_coords:
|
||||
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
|
||||
|
||||
prerender = false
|
||||
|
||||
return
|
||||
else:
|
||||
print ("using prerendered")
|
||||
if highlight_treasure and treasure_local_coords:
|
||||
draw_set_transform (treasure_local_coords + offset_world, 0, Vector2.ONE)
|
||||
draw_polygon(HexTileDrawer.HexPoints, HexTileDrawer.create_color_array("#922"))
|
||||
|
||||
if Globals.draw_island_bbox:
|
||||
# draw_set_transform(transform.origin, transform.get_rotation(), transform.get_scale())
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/water.png" type="Texture" id=1]
|
||||
[ext_resource path="res://scenes/water.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="Shader" id=1]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform vec2 tiled_factor = vec2(5.0, 5.0);
|
||||
uniform float aspect_ratio = 0.5;
|
||||
uniform float wave_speed = 0.4;
|
||||
|
||||
vec4 fragment_tiled_voronoi(vec2 uv) {
|
||||
vec2 tiled_uvs = uv * tiled_factor;
|
||||
tiled_uvs.y *= aspect_ratio;
|
||||
|
||||
vec2 i_st = floor(tiled_uvs);
|
||||
vec2 f_st = fract(tiled_uvs);
|
||||
|
||||
vec2 point = vec2 (0.2, 0.2);
|
||||
|
||||
|
||||
vec2 diff = point - f_st;
|
||||
float dist = length(diff);
|
||||
|
||||
return vec4(1.0, 0., 0., 1.0);
|
||||
}
|
||||
/*
|
||||
void fragment_old() {
|
||||
vec2 tiled_uvs = UV * tiled_factor;
|
||||
tiled_uvs.y *= aspect_ratio;
|
||||
|
||||
vec2 uv_offset = vec2(0., 0.);
|
||||
// uv_offset.x = sin(TIME * wave_speed);
|
||||
// uv_offset.y = cos(TIME * wave_speed);
|
||||
|
||||
tiled_uvs = tiled_uvs;
|
||||
|
||||
vec2 uv_repeat = tiled_uvs;
|
||||
uv_repeat.x = uv_repeat.x - round(uv_repeat.x) + 0.5;
|
||||
uv_repeat.y = uv_repeat.y - round(uv_repeat.y) + 0.5;
|
||||
|
||||
vec2 points[5];
|
||||
points[0] = vec2(0.83,0.75);
|
||||
points[1] = vec2(0.60,0.07);
|
||||
points[2] = vec2(0.28,0.64);
|
||||
points[3] = vec2(0.31,0.26);
|
||||
|
||||
float m_dist = 1.;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
float dist = distance (uv_repeat, points[i]);
|
||||
m_dist = min(m_dist, dist);
|
||||
}
|
||||
|
||||
COLOR = vec4(uv_repeat, 0., 1.);
|
||||
COLOR = vec4(m_dist, m_dist, m_dist, 1.0);
|
||||
// COLOR = texture(TEXTURE, uv_repeat);
|
||||
}
|
||||
*/
|
||||
|
||||
vec2 rand(vec2 co){
|
||||
return vec2(
|
||||
fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453),
|
||||
fract(sin(dot(co.yx ,vec2(12.9898,78.233))) * 43758.5453));
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec2 tiled_uvs = UV * tiled_factor;
|
||||
tiled_uvs.y *= aspect_ratio;
|
||||
|
||||
vec2 i_st = floor(tiled_uvs);
|
||||
vec2 f_st = fract(tiled_uvs);
|
||||
|
||||
float m_dist = 1.;
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
vec2 neighbour = vec2(float(x), float(y));
|
||||
|
||||
vec2 point = rand (i_st + neighbour);
|
||||
point = 0.5 + 0.5 * sin(TIME * 1. + 6.2831 * point);
|
||||
|
||||
vec2 diff = neighbour + point - f_st;
|
||||
float dist = length(diff);
|
||||
m_dist = min(m_dist, dist);
|
||||
}
|
||||
}
|
||||
|
||||
vec4 blue_color = vec4(0.04, 0.33, 1.0, 1.);
|
||||
vec4 m_dist_color = vec4(m_dist, m_dist, m_dist, 1.);
|
||||
float exponent = 4.;
|
||||
vec4 color = blue_color + 0.5 * pow(m_dist_color, vec4(exponent, exponent, exponent, 1.));
|
||||
// vec4 color =
|
||||
// color += 1.0 - m_dist;
|
||||
|
||||
COLOR = vec4(color);
|
||||
}"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=2]
|
||||
shader = SubResource( 1 )
|
||||
shader_param/tiled_factor = Vector2( 300, 300 )
|
||||
shader_param/aspect_ratio = 0.647
|
||||
shader_param/wave_speed = 0.4
|
||||
|
||||
[node name="Water" type="Node2D"]
|
||||
|
||||
[node name="water" type="Sprite" parent="."]
|
||||
material = SubResource( 2 )
|
||||
position = Vector2( -0.00827694, 0 )
|
||||
scale = Vector2( 0.444957, 0.287887 )
|
||||
texture = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[connection signal="item_rect_changed" from="water" to="water" method="calculate_aspect_ratio"]
|
|
@ -240,13 +240,6 @@ func place_treasure():
|
|||
treasure_island.update()
|
||||
|
||||
|
||||
# Creates a viewport and sets up the scene to render the
|
||||
# island
|
||||
func island_prerender_setup():
|
||||
for island in Islands.get_children():
|
||||
pass
|
||||
|
||||
|
||||
func prerender_island(island):
|
||||
var render_island = Island.new()
|
||||
render_island.tiles = island.tiles.duplicate()
|
||||
|
@ -372,7 +365,7 @@ func generate():
|
|||
print ("Could not place island! steps: " + str(overlap_retry_num))
|
||||
else:
|
||||
print ("Placed after " + str(overlap_retry_num) + " retries.")
|
||||
prerender_island(island)
|
||||
# prerender_island(island)
|
||||
Islands.add_child(island)
|
||||
|
||||
num_islands = Islands.get_child_count()
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
tool
|
||||
extends Sprite
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func calculate_aspect_ratio():
|
||||
material.set_shader_param("aspect_ratio", scale.y / scale.x)
|
|
@ -0,0 +1,12 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform vec2 tiled_factor = vec2(5.0, 5.0);
|
||||
uniform float aspect_ratio = 0.5;
|
||||
|
||||
void fragment() {
|
||||
vec2 tiled_uvs = UV * tiled_factor;
|
||||
tiled_uvs.y *= aspect_ratio;
|
||||
|
||||
COLOR= texture(TEXTURE, tiled_uvs);
|
||||
// COLOR = vec4(tiled_uvs, 0., 1.);
|
||||
}
|
Loading…
Reference in New Issue