220 lines
6.7 KiB
Plaintext
220 lines
6.7 KiB
Plaintext
[gd_scene load_steps=13 format=2]
|
|
|
|
[ext_resource path="res://entities/Player3D.tscn" type="PackedScene" id=1]
|
|
[ext_resource path="res://scenes/HexGrid3DTest.gd" type="Script" id=2]
|
|
[ext_resource path="res://scenes/NoiseWorld.gd" type="Script" id=4]
|
|
[ext_resource path="res://assets/water_diffuse.png" type="Texture" id=5]
|
|
|
|
[sub_resource type="CylinderMesh" id=7]
|
|
top_radius = 0.5
|
|
bottom_radius = 0.5
|
|
height = 0.1
|
|
radial_segments = 6
|
|
rings = 1
|
|
|
|
[sub_resource type="SpatialMaterial" id=8]
|
|
render_priority = 1
|
|
flags_transparent = true
|
|
albedo_color = Color( 1, 1, 1, 0.407843 )
|
|
roughness = 0.0
|
|
|
|
[sub_resource type="PlaneMesh" id=1]
|
|
size = Vector2( 1, 1 )
|
|
subdivide_width = 24
|
|
subdivide_depth = 24
|
|
|
|
[sub_resource type="Shader" id=2]
|
|
code = "shader_type spatial;
|
|
|
|
uniform vec2 amplitude = vec2(0.01, 0.05);
|
|
uniform vec2 frequency = vec2(3.0, 2.5);
|
|
uniform vec2 time_factor = vec2(2.0, 3.0);
|
|
|
|
uniform float beer_factor = 100.01;
|
|
uniform float refraction = 0.05;
|
|
|
|
uniform sampler2D uv_offset_texture : hint_black;
|
|
uniform vec2 uv_offset_scale = vec2(0.2, 0.2);
|
|
uniform float uv_offset_time_scale = 0.01;
|
|
uniform float uv_offset_amplitude = 0.2;
|
|
|
|
uniform sampler2D texturemap : hint_albedo;
|
|
uniform vec2 texture_scale = vec2(8.0, 4.0);
|
|
|
|
float height(vec2 pos, float time) {
|
|
return (amplitude.x * sin(pos.x * frequency.x + time * time_factor.x)) + (amplitude.y * sin(pos.y * frequency.y + time * time_factor.y));
|
|
}
|
|
|
|
void vertex() {
|
|
VERTEX.y += height(VERTEX.xz, TIME); // sample the height at the location of our vertex
|
|
TANGENT = normalize(vec3(0.0, height(VERTEX.xz + vec2(0.0, 0.2), TIME) - height(VERTEX.xz + vec2(0.0, -0.2), TIME), 0.4));
|
|
BINORMAL = normalize(vec3(0.4, height(VERTEX.xz + vec2(0.2, 0.0), TIME) - height(VERTEX.xz + vec2(-0.2, 0.0), TIME ), 0.0));
|
|
NORMAL = cross(TANGENT, BINORMAL);
|
|
}
|
|
|
|
void fragment() {
|
|
vec2 base_uv_offset = UV * uv_offset_scale; // Determine the UV that we use to look up our DuDv
|
|
base_uv_offset += TIME * uv_offset_time_scale;
|
|
|
|
vec2 texture_based_offset = texture(uv_offset_texture, base_uv_offset).rg; // Get our offset
|
|
texture_based_offset = texture_based_offset * 2.0 - 1.0; // Convert from 0.0 <=> 1.0 to -1.0 <=> 1.0
|
|
|
|
vec2 texture_uv = UV * texture_scale;
|
|
texture_uv += uv_offset_amplitude * texture_based_offset;
|
|
ALBEDO = texture(texturemap, texture_uv).rgb * 0.5;
|
|
METALLIC = 0.0;
|
|
ROUGHNESS = 0.5;
|
|
//NORMALMAP = texture(normalmap, base_uv_offset).rgb;
|
|
//NORMALMAP_DEPTH = 0.2;
|
|
|
|
if (ALBEDO.r > 0.9 && ALBEDO.g > 0.9 && ALBEDO.b > 0.9) {
|
|
ALPHA = 0.9;
|
|
} else {
|
|
// sample our depth buffer
|
|
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
|
|
|
|
// grab to values
|
|
//depth = depth * 50.0 - 49.0;
|
|
|
|
// unproject depth
|
|
depth = depth * 2.0 - 1.0;
|
|
float z = -PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
|
|
// float x = (SCREEN_UV.x * 2.0 - 1.0) * z / PROJECTION_MATRIX[0][0];
|
|
// float y = (SCREEN_UV.y * 2.0 - 1.0) * z / PROJECTION_MATRIX[1][1];
|
|
float delta = -(z - VERTEX.z); // z is negative.
|
|
// delta *= 0.1;
|
|
|
|
// beers law
|
|
float att = exp(-delta * beer_factor);
|
|
|
|
ALPHA = clamp(1.0 - att, 0.0, 1.0);
|
|
}
|
|
|
|
vec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) );
|
|
vec2 ref_ofs = SCREEN_UV - ref_normal.xy * refraction;
|
|
EMISSION += textureLod(SCREEN_TEXTURE,ref_ofs,ROUGHNESS * 2.0).rgb * (1.0 - ALPHA);
|
|
|
|
ALBEDO *= ALPHA;
|
|
ALPHA = 1.0;
|
|
}"
|
|
|
|
[sub_resource type="ShaderMaterial" id=3]
|
|
shader = SubResource( 2 )
|
|
shader_param/amplitude = Vector2( 0.005, 0.005 )
|
|
shader_param/frequency = Vector2( 50, 48 )
|
|
shader_param/time_factor = Vector2( 7, 8 )
|
|
shader_param/beer_factor = 2.0
|
|
shader_param/refraction = 0.001
|
|
shader_param/uv_offset_scale = Vector2( 0.2, 0.2 )
|
|
shader_param/uv_offset_time_scale = 0.1
|
|
shader_param/uv_offset_amplitude = 1.2
|
|
shader_param/texture_scale = Vector2( 8, 8 )
|
|
shader_param/texturemap = ExtResource( 5 )
|
|
|
|
[sub_resource type="HeightMapShape" id=6]
|
|
map_width = 1
|
|
map_depth = 1
|
|
map_data = PoolRealArray( 0 )
|
|
|
|
[sub_resource type="OpenSimplexNoise" id=11]
|
|
octaves = 1
|
|
period = 30.0
|
|
|
|
[sub_resource type="NoiseTexture" id=10]
|
|
flags = 3
|
|
width = 1024
|
|
height = 1024
|
|
seamless = true
|
|
noise = SubResource( 11 )
|
|
|
|
[node name="HexGrid3DTest" type="Spatial"]
|
|
script = ExtResource( 2 )
|
|
|
|
[node name="World" type="Spatial" parent="."]
|
|
script = ExtResource( 4 )
|
|
|
|
[node name="Scene" type="Spatial" parent="World"]
|
|
|
|
[node name="Navigation" type="Spatial" parent="World"]
|
|
|
|
[node name="Tiles" type="Spatial" parent="World"]
|
|
visible = false
|
|
|
|
[node name="Highlight" type="MeshInstance" parent="World"]
|
|
transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, 0, 0.2, 0 )
|
|
cast_shadow = 0
|
|
mesh = SubResource( 7 )
|
|
material/0 = SubResource( 8 )
|
|
|
|
[node name="Water" type="MeshInstance" parent="World"]
|
|
transform = Transform( 50, 0, 0, 0, 50, 0, 0, 0, 50, 0, 0, 0 )
|
|
visible = false
|
|
cast_shadow = 0
|
|
mesh = SubResource( 1 )
|
|
skeleton = NodePath("../..")
|
|
material/0 = SubResource( 3 )
|
|
|
|
[node name="ClckArea" type="Area" parent="World"]
|
|
transform = Transform( 50, 0, 0, 0, 50, 0, 0, 0, 50, 0, 0, 0 )
|
|
|
|
[node name="CollisionShape" type="CollisionShape" parent="World/ClckArea"]
|
|
transform = Transform( 2.5, 0, 0, 0, 1, 0, 0, 0, 2.5, 0, 0, 0 )
|
|
shape = SubResource( 6 )
|
|
|
|
[node name="Noise" type="Sprite" parent="World"]
|
|
visible = false
|
|
texture = SubResource( 10 )
|
|
|
|
[node name="PatchTiles" type="Spatial" parent="World"]
|
|
|
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
|
transform = Transform( 0.83729, 0.174005, 0.518332, -0.54676, 0.266466, 0.793757, 0, -0.948008, 0.318248, 0, 8.03448, 0 )
|
|
shadow_enabled = true
|
|
shadow_contact = 1.565
|
|
directional_shadow_mode = 0
|
|
directional_shadow_depth_range = 1
|
|
|
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
|
|
|
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer"]
|
|
margin_right = 40.0
|
|
margin_bottom = 40.0
|
|
__meta__ = {
|
|
"_edit_use_anchors_": false
|
|
}
|
|
|
|
[node name="FPSLabel" type="Label" parent="CanvasLayer/HBoxContainer"]
|
|
margin_top = 13.0
|
|
margin_right = 22.0
|
|
margin_bottom = 27.0
|
|
text = "FPS"
|
|
__meta__ = {
|
|
"_edit_use_anchors_": false
|
|
}
|
|
|
|
[node name="PlayerPos" type="Label" parent="CanvasLayer/HBoxContainer"]
|
|
margin_left = 26.0
|
|
margin_top = 13.0
|
|
margin_right = 88.0
|
|
margin_bottom = 27.0
|
|
text = "PlayerPos"
|
|
__meta__ = {
|
|
"_edit_use_anchors_": false
|
|
}
|
|
|
|
[node name="TilePos" type="Label" parent="CanvasLayer/HBoxContainer"]
|
|
margin_left = 92.0
|
|
margin_top = 13.0
|
|
margin_right = 138.0
|
|
margin_bottom = 27.0
|
|
text = "TilePos"
|
|
__meta__ = {
|
|
"_edit_use_anchors_": false
|
|
}
|
|
|
|
[node name="Player" parent="." instance=ExtResource( 1 )]
|
|
|
|
[connection signal="input_event" from="World/ClckArea" to="World" method="_on_ClckArea_input_event"]
|
|
[connection signal="mouse_entered" from="World/ClckArea" to="World" method="_on_ClckArea_mouse_entered"]
|
|
[connection signal="mouse_exited" from="World/ClckArea" to="World" method="_on_ClckArea_mouse_exited"]
|