diff options
author | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-07-22 21:05:42 +0200 |
---|---|---|
committer | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-07-22 21:05:42 +0200 |
commit | 71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 (patch) | |
tree | b4280fde6eef2ae6987648bc7bf8e00e9011bb7f /game/testing | |
parent | ce9022d0df74d6c33db3686622be2050d873ab0b (diff) |
init_testtest3d
Diffstat (limited to 'game/testing')
38 files changed, 1121 insertions, 0 deletions
diff --git a/game/testing/21.gdshader b/game/testing/21.gdshader new file mode 100644 index 0000000..3db3341 --- /dev/null +++ b/game/testing/21.gdshader @@ -0,0 +1,76 @@ +shader_type spatial; + + +uniform float speed : hint_range(-1,1) = 0.0; + +//colors +uniform sampler2D noise1; //add Godot noise here +uniform sampler2D noise2; //add Godot noise here +uniform sampler2D normalmap : hint_normal; //add Godot noise here, enable as_normalmap +uniform vec4 color : hint_color; +uniform vec4 edge_color : hint_color; + +//foam +uniform float edge_scale = 0.25; +uniform float near = 0.1; +uniform float far = 100f; + +//waves +uniform vec2 wave_strengh = vec2(0.5, 0.25); +uniform vec2 wave_frequency = vec2(12.0, 12.0); +uniform vec2 time_factor = vec2(1.0, 2.0); + + + +float rim(float depth){ + depth = 2f * depth - 1f; + return near * far / (far + depth * (near - far)); +} + + +float waves(vec2 pos, float time){ + return (wave_strengh.y * sin(pos.y * wave_frequency.y + time * time_factor.y)) + (wave_strengh.x * sin(pos.x * wave_frequency.x + time * time_factor.x)); +} + + +void vertex(){ + VERTEX.y += waves(VERTEX.xy, TIME); +} + + +void fragment(){ + float time = TIME * speed; + 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; + + float sum = (n1.r + n2.r) - 1f; + + + float z_depth = rim(texture(DEPTH_TEXTURE, SCREEN_UV).x); + float z_pos = rim(FRAGCOORD.z); + float diff = z_depth - z_pos; + + vec2 displacement = vec2(sum * 0.05); + diff += displacement.x * 50f; + + + vec4 col = mix(edge_color, color, step(edge_scale, diff)); + + vec4 alpha = vec4(1.0); + alpha = texture(SCREEN_TEXTURE, SCREEN_UV + displacement); + + + 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; + + ALBEDO = vec3(fin) + mix(alpha.rgb, col.rgb, color.a); + + NORMALMAP = texture(normalmap, uv_movement).rgb; + ROUGHNESS = 0.1; + SPECULAR = 1f; +}
\ No newline at end of file diff --git a/game/testing/Buoyancy-in-Godot-4-master/.gitattributes b/game/testing/Buoyancy-in-Godot-4-master/.gitattributes new file mode 100644 index 0000000..8ad74f7 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/.gitattributes @@ -0,0 +1,2 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf diff --git a/game/testing/Buoyancy-in-Godot-4-master/.gitignore b/game/testing/Buoyancy-in-Godot-4-master/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/game/testing/Buoyancy-in-Godot-4-master/Cube.gd b/game/testing/Buoyancy-in-Godot-4-master/Cube.gd new file mode 100644 index 0000000..075e532 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/Cube.gd @@ -0,0 +1,34 @@ +extends RigidBody3D + +@export var float_force := 1.0 +@export var water_drag := 0.05 +@export var water_angular_drag := 0.05 + +@onready var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") +@onready var water = get_node('/root/Main/Water') + +@onready var probes = $ProbeContainer.get_children() + +var submerged := false + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _physics_process(delta): + submerged = false + for p in probes: + var depth = water.get_height(p.global_position) - p.global_position.y + if depth > 0: + submerged = true + apply_force(Vector3.UP * float_force * gravity * depth, p.global_position - global_position) + +func _integrate_forces(state: PhysicsDirectBodyState3D): + if submerged: + state.linear_velocity *= 1 - water_drag + state.angular_velocity *= 1 - water_angular_drag diff --git a/game/testing/Buoyancy-in-Godot-4-master/README.md b/game/testing/Buoyancy-in-Godot-4-master/README.md new file mode 100644 index 0000000..9e0e449 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/README.md @@ -0,0 +1,3 @@ +# Simple Buoyancy implemented in Godot 4.0 RC + +Water shader from here: https://stayathomedev.com/?utm_source=youtube&utm_medium=desc&utm_content=watershader diff --git a/game/testing/Buoyancy-in-Godot-4-master/Water.gd b/game/testing/Buoyancy-in-Godot-4-master/Water.gd new file mode 100644 index 0000000..b5e2fe7 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/Water.gd @@ -0,0 +1,32 @@ +extends MeshInstance3D + +var material: ShaderMaterial +var noise: Image + +var noise_scale: float +var wave_speed: float +var height_scale: float + +var time: float + +# Called when the node enters the scene tree for the first time. +func _ready(): + material = mesh.surface_get_material(0) + noise = material.get_shader_parameter("wave").noise.get_seamless_image(512, 512) + noise_scale = material.get_shader_parameter("noise_scale") + wave_speed = material.get_shader_parameter("wave_speed") + height_scale = material.get_shader_parameter("height_scale") + + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + time += delta + material.set_shader_parameter("wave_time", time) + +func get_height(world_position: Vector3) -> float: + var uv_x = wrapf(world_position.x / noise_scale + time * wave_speed, 0, 1) + var uv_y = wrapf(world_position.z / noise_scale + time * wave_speed, 0, 1) + + var pixel_pos = Vector2(uv_x * noise.get_width(), uv_y * noise.get_height()) + return global_position.y + noise.get_pixelv(pixel_pos).r * height_scale; diff --git a/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr b/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr Binary files differnew file mode 100644 index 0000000..3343d2c --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr diff --git a/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr.import b/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr.import new file mode 100644 index 0000000..3f1eca0 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/assets/kloppenheim_06_puresky_4k.exr.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bay3ak8k8pevv" +path.bptc="res://.godot/imported/kloppenheim_06_puresky_4k.exr-b16989c6338774c04a5c25df6ac154bf.bptc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://assets/kloppenheim_06_puresky_4k.exr" +dest_files=["res://.godot/imported/kloppenheim_06_puresky_4k.exr-b16989c6338774c04a5c25df6ac154bf.bptc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/game/testing/Buoyancy-in-Godot-4-master/assets/shaders/water.gdshader b/game/testing/Buoyancy-in-Godot-4-master/assets/shaders/water.gdshader new file mode 100644 index 0000000..5fba7f9 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/assets/shaders/water.gdshader @@ -0,0 +1,81 @@ +shader_type spatial; +render_mode depth_draw_always; + +uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap; +uniform sampler2D DEPTH_TEXTURE: hint_depth_texture, filter_linear_mipmap; + +uniform vec3 albedo : source_color; +uniform vec3 albedo2 : source_color; +uniform vec4 color_deep : source_color; +uniform vec4 color_shallow : source_color; + +uniform float metallic : hint_range(0.0, 1.0) = 0; +uniform float roughness : hint_range(0.0, 1.0) = 0.02; + +uniform sampler2D texture_normal; +uniform sampler2D texture_normal2; +uniform sampler2D wave; + +uniform float wave_time = 0; +uniform vec2 wave_direction = vec2(2.0,0.0); +uniform vec2 wave_2_direction = vec2(0.0,1.0); +uniform float time_scale : hint_range(0.0, 0.2, 0.005) = 0.025; +uniform float wave_speed = 2.0; +uniform float noise_scale = 10.0; +uniform float height_scale = 0.15; +uniform float beers_law = 2.0; +uniform float depth_offset = -0.75; + +varying float height; +varying vec3 world_pos; + +uniform float edge_scale = 0.1; +uniform float near = 0.5; +uniform float far = 100.0; +uniform vec3 edge_color : source_color; + +float fresnel(float amount, vec3 normal, vec3 view) +{ + return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0 )), amount); +} + +float edge(float depth) { + return near * far / (far + depth * (near - far)); +} + +void vertex() { + world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; + height = texture(wave, world_pos.xz / noise_scale + wave_time * wave_speed).r; + VERTEX.y += height * height_scale; +} + +void fragment() { + float depth_texture = texture(DEPTH_TEXTURE, SCREEN_UV).r; + float depth = PROJECTION_MATRIX[3][2] / (depth_texture + PROJECTION_MATRIX[2][2]); + depth = depth + VERTEX.z; + float depth_blend = exp((depth + depth_offset) * -beers_law); + depth_blend = clamp(1.0 - depth_blend, 0.0, 1.0); + + vec3 screen_color = textureLod(SCREEN_TEXTURE, SCREEN_UV, depth_blend * 2.5).rgb; + vec3 depth_color = mix(color_shallow.rgb, color_deep.rgb, depth_blend); + vec3 color = mix(screen_color * depth_color, depth_color * 0.25, depth_blend * 0.5); + + float z_depth = edge(texture(DEPTH_TEXTURE, SCREEN_UV).x); + float z_pos = edge(FRAGCOORD.z); + float z_dif = z_depth - z_pos; + + vec2 time = (TIME * wave_direction) * time_scale; + vec2 time2 = (TIME * wave_2_direction) * time_scale; + + vec3 normal_blend = mix(texture(texture_normal, world_pos.xz / noise_scale + time).rgb, texture(texture_normal2, world_pos.xz / noise_scale + time2).rgb, 0.5); + + float fresnel = fresnel(5.0, NORMAL, VIEW); + vec3 surface_color = mix(albedo, albedo2, fresnel); + vec3 depth_color_adj = mix(edge_color, color, step(edge_scale, z_dif)); + + ALBEDO = clamp(surface_color + depth_color_adj,vec3(0),vec3(1.0)); + ALPHA = 1.0; + METALLIC = metallic; + ROUGHNESS = roughness; + NORMAL_MAP = normal_blend; +}
\ No newline at end of file diff --git a/game/testing/Buoyancy-in-Godot-4-master/icon.svg b/game/testing/Buoyancy-in-Godot-4-master/icon.svg new file mode 100644 index 0000000..adc26df --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/icon.svg @@ -0,0 +1 @@ +<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><g transform="translate(32 32)"><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99z" fill="#363d52"/><path d="m-16-32c-8.86 0-16 7.13-16 15.99v95.98c0 8.86 7.13 15.99 16 15.99h96c8.86 0 16-7.13 16-15.99v-95.98c0-8.85-7.14-15.99-16-15.99zm0 4h96c6.64 0 12 5.35 12 11.99v95.98c0 6.64-5.35 11.99-12 11.99h-96c-6.64 0-12-5.35-12-11.99v-95.98c0-6.64 5.36-11.99 12-11.99z" fill-opacity=".4"/></g><g stroke-width="9.92746" transform="matrix(.10073078 0 0 .10073078 12.425923 2.256365)"><path d="m0 0s-.325 1.994-.515 1.976l-36.182-3.491c-2.879-.278-5.115-2.574-5.317-5.459l-.994-14.247-27.992-1.997-1.904 12.912c-.424 2.872-2.932 5.037-5.835 5.037h-38.188c-2.902 0-5.41-2.165-5.834-5.037l-1.905-12.912-27.992 1.997-.994 14.247c-.202 2.886-2.438 5.182-5.317 5.46l-36.2 3.49c-.187.018-.324-1.978-.511-1.978l-.049-7.83 30.658-4.944 1.004-14.374c.203-2.91 2.551-5.263 5.463-5.472l38.551-2.75c.146-.01.29-.016.434-.016 2.897 0 5.401 2.166 5.825 5.038l1.959 13.286h28.005l1.959-13.286c.423-2.871 2.93-5.037 5.831-5.037.142 0 .284.005.423.015l38.556 2.75c2.911.209 5.26 2.562 5.463 5.472l1.003 14.374 30.645 4.966z" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 919.24059 771.67186)"/><path d="m0 0v-47.514-6.035-5.492c.108-.001.216-.005.323-.015l36.196-3.49c1.896-.183 3.382-1.709 3.514-3.609l1.116-15.978 31.574-2.253 2.175 14.747c.282 1.912 1.922 3.329 3.856 3.329h38.188c1.933 0 3.573-1.417 3.855-3.329l2.175-14.747 31.575 2.253 1.115 15.978c.133 1.9 1.618 3.425 3.514 3.609l36.182 3.49c.107.01.214.014.322.015v4.711l.015.005v54.325c5.09692 6.4164715 9.92323 13.494208 13.621 19.449-5.651 9.62-12.575 18.217-19.976 26.182-6.864-3.455-13.531-7.369-19.828-11.534-3.151 3.132-6.7 5.694-10.186 8.372-3.425 2.751-7.285 4.768-10.946 7.118 1.09 8.117 1.629 16.108 1.846 24.448-9.446 4.754-19.519 7.906-29.708 10.17-4.068-6.837-7.788-14.241-11.028-21.479-3.842.642-7.702.88-11.567.926v.006c-.027 0-.052-.006-.075-.006-.024 0-.049.006-.073.006v-.006c-3.872-.046-7.729-.284-11.572-.926-3.238 7.238-6.956 14.642-11.03 21.479-10.184-2.264-20.258-5.416-29.703-10.17.216-8.34.755-16.331 1.848-24.448-3.668-2.35-7.523-4.367-10.949-7.118-3.481-2.678-7.036-5.24-10.188-8.372-6.297 4.165-12.962 8.079-19.828 11.534-7.401-7.965-14.321-16.562-19.974-26.182 4.4426579-6.973692 9.2079702-13.9828876 13.621-19.449z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 104.69892 525.90697)"/><path d="m0 0-1.121-16.063c-.135-1.936-1.675-3.477-3.611-3.616l-38.555-2.751c-.094-.007-.188-.01-.281-.01-1.916 0-3.569 1.406-3.852 3.33l-2.211 14.994h-31.459l-2.211-14.994c-.297-2.018-2.101-3.469-4.133-3.32l-38.555 2.751c-1.936.139-3.476 1.68-3.611 3.616l-1.121 16.063-32.547 3.138c.015-3.498.06-7.33.06-8.093 0-34.374 43.605-50.896 97.781-51.086h.066.067c54.176.19 97.766 16.712 97.766 51.086 0 .777.047 4.593.063 8.093z" fill="#478cbf" transform="matrix(4.162611 0 0 -4.162611 784.07144 817.24284)"/><path d="m0 0c0-12.052-9.765-21.815-21.813-21.815-12.042 0-21.81 9.763-21.81 21.815 0 12.044 9.768 21.802 21.81 21.802 12.048 0 21.813-9.758 21.813-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 389.21484 625.67104)"/><path d="m0 0c0-7.994-6.479-14.473-14.479-14.473-7.996 0-14.479 6.479-14.479 14.473s6.483 14.479 14.479 14.479c8 0 14.479-6.485 14.479-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 367.36686 631.05679)"/><path d="m0 0c-3.878 0-7.021 2.858-7.021 6.381v20.081c0 3.52 3.143 6.381 7.021 6.381s7.028-2.861 7.028-6.381v-20.081c0-3.523-3.15-6.381-7.028-6.381" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 511.99336 724.73954)"/><path d="m0 0c0-12.052 9.765-21.815 21.815-21.815 12.041 0 21.808 9.763 21.808 21.815 0 12.044-9.767 21.802-21.808 21.802-12.05 0-21.815-9.758-21.815-21.802" fill="#fff" transform="matrix(4.162611 0 0 -4.162611 634.78706 625.67104)"/><path d="m0 0c0-7.994 6.477-14.473 14.471-14.473 8.002 0 14.479 6.479 14.479 14.473s-6.477 14.479-14.479 14.479c-7.994 0-14.471-6.485-14.471-14.479" fill="#414042" transform="matrix(4.162611 0 0 -4.162611 656.64056 631.05679)"/></g></svg> diff --git a/game/testing/Buoyancy-in-Godot-4-master/icon.svg.import b/game/testing/Buoyancy-in-Godot-4-master/icon.svg.import new file mode 100644 index 0000000..30883ef --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/icon.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bin4yeou0ftcw" +path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.svg" +dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/game/testing/Buoyancy-in-Godot-4-master/main.tscn b/game/testing/Buoyancy-in-Godot-4-master/main.tscn new file mode 100644 index 0000000..bd54991 --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/main.tscn @@ -0,0 +1,143 @@ +[gd_scene load_steps=18 format=3 uid="uid://b64rk3r14m5br"] + +[ext_resource type="Texture2D" uid="uid://bay3ak8k8pevv" path="res://assets/kloppenheim_06_puresky_4k.exr" id="1_cyo0m"] +[ext_resource type="Shader" path="res://assets/shaders/water.gdshader" id="2_twn8n"] +[ext_resource type="Script" path="res://Water.gd" id="3_t5r3v"] +[ext_resource type="Script" path="res://Cube.gd" id="3_wnrpb"] + +[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_vcvt7"] +panorama = ExtResource("1_cyo0m") + +[sub_resource type="Sky" id="Sky_wc0b5"] +sky_material = SubResource("PanoramaSkyMaterial_vcvt7") + +[sub_resource type="Environment" id="Environment_w5hlc"] +background_mode = 2 +sky = SubResource("Sky_wc0b5") +tonemap_mode = 2 +glow_enabled = true + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hy6fq"] +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_brvoh"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hy6fq") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hs2gb"] +noise_type = 3 +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_u5h0n"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hs2gb") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_jbi1g"] +noise_type = 3 +frequency = 0.001 +fractal_type = 2 +fractal_octaves = 3 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_7k2l2"] +seamless = true +noise = SubResource("FastNoiseLite_jbi1g") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0n3y0"] +render_priority = 0 +shader = ExtResource("2_twn8n") +shader_parameter/albedo = Color(0, 0.321569, 0.431373, 1) +shader_parameter/albedo2 = Color(0, 0.47451, 0.764706, 1) +shader_parameter/color_deep = Color(0.105882, 0.294118, 0.329412, 1) +shader_parameter/color_shallow = Color(0, 0.552941, 0.65098, 1) +shader_parameter/metallic = 0.0 +shader_parameter/roughness = 0.02 +shader_parameter/wave_time = 0.0 +shader_parameter/wave_direction = Vector2(2, 0) +shader_parameter/wave_2_direction = Vector2(0, 1) +shader_parameter/time_scale = 0.025 +shader_parameter/wave_speed = 0.2 +shader_parameter/noise_scale = 10.0 +shader_parameter/height_scale = 2.0 +shader_parameter/beers_law = 0.089 +shader_parameter/depth_offset = -0.75 +shader_parameter/edge_scale = 0.362 +shader_parameter/near = 0.5 +shader_parameter/far = 100.0 +shader_parameter/edge_color = Color(1, 1, 1, 1) +shader_parameter/texture_normal = SubResource("NoiseTexture2D_brvoh") +shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_u5h0n") +shader_parameter/wave = SubResource("NoiseTexture2D_7k2l2") + +[sub_resource type="PlaneMesh" id="PlaneMesh_0xwda"] +material = SubResource("ShaderMaterial_0n3y0") +size = Vector2(500, 500) +subdivide_width = 500 +subdivide_depth = 500 + +[sub_resource type="BoxMesh" id="BoxMesh_km0el"] +size = Vector3(5, 1, 10) + +[sub_resource type="BoxShape3D" id="BoxShape3D_lu3w5"] +size = Vector3(5, 1, 10) + +[node name="Main" type="Node3D"] + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_w5hlc") + +[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] +transform = Transform3D(-0.940098, 0.0859291, -0.329897, -0.23722, -0.859886, 0.452021, -0.244833, 0.503202, 0.828761, 0, 0, 0) +shadow_enabled = true + +[node name="Water" type="MeshInstance3D" parent="."] +mesh = SubResource("PlaneMesh_0xwda") +script = ExtResource("3_t5r3v") + +[node name="Camera3D" type="Camera3D" parent="."] +transform = Transform3D(0.0305324, 0.321287, -0.94649, 0, 0.946931, 0.321437, 0.999534, -0.00981422, 0.0289121, -11.6034, 4.14286, 1.45379) + +[node name="Cube" type="RigidBody3D" parent="."] +transform = Transform3D(-0.761663, 0, -0.647974, 0, 1, 0, 0.647974, 0, -0.761663, 0, 3.13922, 0) +mass = 10.0 +script = ExtResource("3_wnrpb") +float_force = 1.3 +water_angular_drag = 0.1 + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Cube"] +mesh = SubResource("BoxMesh_km0el") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Cube"] +shape = SubResource("BoxShape3D_lu3w5") + +[node name="ProbeContainer" type="Node3D" parent="Cube"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.590401, 0) + +[node name="Probe" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, 5) + +[node name="Probe2" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, 0) + +[node name="Probe3" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0, -5) + +[node name="Probe4" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5) + +[node name="Probe5" type="Marker3D" parent="Cube/ProbeContainer"] + +[node name="Probe6" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5) + +[node name="Probe7" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0, 5) + +[node name="Probe8" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0, 0) + +[node name="Probe9" type="Marker3D" parent="Cube/ProbeContainer"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.5, 0, -5) diff --git a/game/testing/Buoyancy-in-Godot-4-master/project.godot b/game/testing/Buoyancy-in-Godot-4-master/project.godot new file mode 100644 index 0000000..b10c22f --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/project.godot @@ -0,0 +1,25 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Buoyancy YT" +run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.1", "Forward Plus") +config/icon="res://icon.svg" + +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 + +[rendering] + +anti_aliasing/quality/msaa_3d=3 diff --git a/game/testing/Buoyancy-in-Godot-4-master/water.tscn b/game/testing/Buoyancy-in-Godot-4-master/water.tscn new file mode 100644 index 0000000..c336ccc --- /dev/null +++ b/game/testing/Buoyancy-in-Godot-4-master/water.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=11 format=3 uid="uid://cty2qgt0i5f4w"] + +[ext_resource type="Shader" path="res://assets/shaders/water.gdshader" id="1_oeaqx"] +[ext_resource type="Script" path="res://Water.gd" id="2_qv0cn"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hy6fq"] +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_brvoh"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hy6fq") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hs2gb"] +noise_type = 3 +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_u5h0n"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hs2gb") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_jbi1g"] +noise_type = 3 +frequency = 0.001 +fractal_type = 2 +fractal_octaves = 3 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_7k2l2"] +seamless = true +noise = SubResource("FastNoiseLite_jbi1g") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0n3y0"] +render_priority = 0 +shader = ExtResource("1_oeaqx") +shader_parameter/albedo = Color(0, 0.321569, 0.431373, 1) +shader_parameter/albedo2 = Color(0, 0.47451, 0.764706, 1) +shader_parameter/color_deep = Color(0.105882, 0.294118, 0.329412, 1) +shader_parameter/color_shallow = Color(0, 0.552941, 0.65098, 1) +shader_parameter/metallic = 0.0 +shader_parameter/roughness = 0.02 +shader_parameter/wave_time = 0.0 +shader_parameter/wave_direction = Vector2(2, 0) +shader_parameter/wave_2_direction = Vector2(0, 1) +shader_parameter/time_scale = 0.025 +shader_parameter/wave_speed = 0.2 +shader_parameter/noise_scale = 10.0 +shader_parameter/height_scale = 2.0 +shader_parameter/beers_law = 0.089 +shader_parameter/depth_offset = -0.75 +shader_parameter/edge_scale = 0.362 +shader_parameter/near = 0.5 +shader_parameter/far = 100.0 +shader_parameter/edge_color = Color(1, 1, 1, 1) +shader_parameter/texture_normal = SubResource("NoiseTexture2D_brvoh") +shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_u5h0n") +shader_parameter/wave = SubResource("NoiseTexture2D_7k2l2") + +[sub_resource type="PlaneMesh" id="PlaneMesh_0xwda"] +material = SubResource("ShaderMaterial_0n3y0") +size = Vector2(500, 500) +subdivide_width = 500 +subdivide_depth = 500 + +[node name="Water" type="MeshInstance3D"] +mesh = SubResource("PlaneMesh_0xwda") +script = ExtResource("2_qv0cn") diff --git a/game/testing/dataft/color.png b/game/testing/dataft/color.png Binary files differnew file mode 100644 index 0000000..3be5b60 --- /dev/null +++ b/game/testing/dataft/color.png diff --git a/game/testing/dataft/color.png.import b/game/testing/dataft/color.png.import new file mode 100644 index 0000000..3591560 --- /dev/null +++ b/game/testing/dataft/color.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcp5vyhccrty3" +path="res://.godot/imported/color.png-c4690dd6325517712e8b70b22ca954a9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/dataft/color.png" +dest_files=["res://.godot/imported/color.png-c4690dd6325517712e8b70b22ca954a9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=0 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/game/testing/dataft/data.hterrain b/game/testing/dataft/data.hterrain new file mode 100644 index 0000000..f137b21 --- /dev/null +++ b/game/testing/dataft/data.hterrain @@ -0,0 +1,29 @@ +{ + "maps": [ + [ + { + "id": 0 + } + ], + [ + { + "id": 0 + } + ], + [ + { + "id": 0 + } + ], + [ + { + "id": 0 + } + ], + [], + [], + [], + [] + ], + "version": "0.11" +}
\ No newline at end of file diff --git a/game/testing/dataft/height.res b/game/testing/dataft/height.res Binary files differnew file mode 100644 index 0000000..40c9f23 --- /dev/null +++ b/game/testing/dataft/height.res diff --git a/game/testing/dataft/normal.png b/game/testing/dataft/normal.png Binary files differnew file mode 100644 index 0000000..7b066a2 --- /dev/null +++ b/game/testing/dataft/normal.png diff --git a/game/testing/dataft/normal.png.import b/game/testing/dataft/normal.png.import new file mode 100644 index 0000000..14a20f4 --- /dev/null +++ b/game/testing/dataft/normal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b63bln6bdm576" +path="res://.godot/imported/normal.png-708bd8892e3c7ce2a513aa428c5cccdd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/dataft/normal.png" +dest_files=["res://.godot/imported/normal.png-708bd8892e3c7ce2a513aa428c5cccdd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=0 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/game/testing/dataft/splat.png b/game/testing/dataft/splat.png Binary files differnew file mode 100644 index 0000000..fd566ba --- /dev/null +++ b/game/testing/dataft/splat.png diff --git a/game/testing/dataft/splat.png.import b/game/testing/dataft/splat.png.import new file mode 100644 index 0000000..94c2e0d --- /dev/null +++ b/game/testing/dataft/splat.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bw8ut45mlcecc" +path="res://.godot/imported/splat.png-d72060e3fb78fb964805e101bd1cf6cc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/dataft/splat.png" +dest_files=["res://.godot/imported/splat.png-d72060e3fb78fb964805e101bd1cf6cc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=0 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=0 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=false +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/game/testing/exp.png b/game/testing/exp.png Binary files differnew file mode 100644 index 0000000..745cbcf --- /dev/null +++ b/game/testing/exp.png diff --git a/game/testing/exp.png.import b/game/testing/exp.png.import new file mode 100644 index 0000000..65405da --- /dev/null +++ b/game/testing/exp.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://drwpyov040ogl" +path="res://.godot/imported/exp.png-bcdceaa0bfebe20561d97ab9562c0911.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/exp.png" +dest_files=["res://.godot/imported/exp.png-bcdceaa0bfebe20561d97ab9562c0911.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/testing/mountains-nowater.png b/game/testing/mountains-nowater.png Binary files differnew file mode 100644 index 0000000..dad49ea --- /dev/null +++ b/game/testing/mountains-nowater.png diff --git a/game/testing/mountains-nowater.png.import b/game/testing/mountains-nowater.png.import new file mode 100644 index 0000000..52e22ec --- /dev/null +++ b/game/testing/mountains-nowater.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cgyx24o6h3xr1" +path="res://.godot/imported/mountains-nowater.png-b369ed175a3654361b5c3beacaa34fbd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/mountains-nowater.png" +dest_files=["res://.godot/imported/mountains-nowater.png-b369ed175a3654361b5c3beacaa34fbd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/testing/mountains.png b/game/testing/mountains.png Binary files differnew file mode 100644 index 0000000..f0cefc5 --- /dev/null +++ b/game/testing/mountains.png diff --git a/game/testing/mountains.png.import b/game/testing/mountains.png.import new file mode 100644 index 0000000..c3a266c --- /dev/null +++ b/game/testing/mountains.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c0epbaco34anq" +path="res://.godot/imported/mountains.png-3e801c8f292838974fa9af6a76a7e490.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/mountains.png" +dest_files=["res://.godot/imported/mountains.png-3e801c8f292838974fa9af6a76a7e490.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/testing/mountains1.png b/game/testing/mountains1.png Binary files differnew file mode 100644 index 0000000..9ea59cf --- /dev/null +++ b/game/testing/mountains1.png diff --git a/game/testing/mountains1.png.import b/game/testing/mountains1.png.import new file mode 100644 index 0000000..ba0d0d9 --- /dev/null +++ b/game/testing/mountains1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dl45nhftyvbof" +path.s3tc="res://.godot/imported/mountains1.png-625a23815c4f70ce0909a570b9dc103f.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://testing/mountains1.png" +dest_files=["res://.godot/imported/mountains1.png-625a23815c4f70ce0909a570b9dc103f.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/game/testing/mountains1.raw b/game/testing/mountains1.raw Binary files differnew file mode 100644 index 0000000..fff244f --- /dev/null +++ b/game/testing/mountains1.raw diff --git a/game/testing/mountains1.raw.pal b/game/testing/mountains1.raw.pal new file mode 100644 index 0000000..3c466ff --- /dev/null +++ b/game/testing/mountains1.raw.pal @@ -0,0 +1,4 @@ + !!!"""###$$$&&&(((***+++---...000111222///444666777999;;;===>>>???@@@<<<:::888555333,,,CCCEEEFFFHHHIIIJJJGGGDDDAAABBBMMMOOOQQQRRRSSSLLLKKKNNNPPPTTTUUUWWWXXXYYYZZZ\\\]]]^^^___)))'''%%%VVV[[[```aaabbbcccdddeeefffgggiiihhh
jjjkkklllmmmnnnooo + + +pppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{}}}|||~~~
ĄĄĄ˘˘˘ŁŁŁŚŚŚ¤¤¤ĽĽĽ§§§¨¨¨ŞŞŞŹŹŹŤŤŤŽŽŽŠŠŠŻŻŻ°°°łłłąąą¸¸¸˛˛˛´´´ľľľśśśˇˇˇšššşşşźźź˝˝˝ťťťžžžżżżŔŔŔÁÁÁÂÂÂĂĂĂÄÄÄĹĹĹĆĆĆÇÇÇËËËĘĘĘ
\ No newline at end of file diff --git a/game/testing/terrain.png b/game/testing/terrain.png Binary files differnew file mode 100644 index 0000000..eecedb3 --- /dev/null +++ b/game/testing/terrain.png diff --git a/game/testing/terrain.png.import b/game/testing/terrain.png.import new file mode 100644 index 0000000..184e17a --- /dev/null +++ b/game/testing/terrain.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://74rtygmbogbi" +path="res://.godot/imported/terrain.png-ffe6c2f8d5e846f787c1312f09317a21.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://testing/terrain.png" +dest_files=["res://.godot/imported/terrain.png-ffe6c2f8d5e846f787c1312f09317a21.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/game/testing/testing.gdshader b/game/testing/testing.gdshader new file mode 100644 index 0000000..bdc87df --- /dev/null +++ b/game/testing/testing.gdshader @@ -0,0 +1,11 @@ +shader_type spatial; +uniform sampler2D heightmap; +uniform float height_ration = 1.0; + +void fragment() { + // Place fragment code here. +} + +void vertex() { + VERTEX.y = texture(heightmap, UV).r * height_ration; +} diff --git a/game/testing/testing.tscn b/game/testing/testing.tscn new file mode 100644 index 0000000..993e318 --- /dev/null +++ b/game/testing/testing.tscn @@ -0,0 +1,115 @@ +[gd_scene load_steps=18 format=3 uid="uid://bh6us7qfprpc6"] + +[ext_resource type="Script" path="res://addons/zylann.hterrain/hterrain.gd" id="1_vnlln"] +[ext_resource type="Resource" path="res://testing/dataft/data.hterrain" id="2_7sfpq"] +[ext_resource type="Script" path="res://addons/zylann.hterrain/hterrain_texture_set.gd" id="3_l4lvw"] +[ext_resource type="Shader" path="res://testing/testing.gdshader" id="4_d4jdj"] +[ext_resource type="Texture2D" uid="uid://dl45nhftyvbof" path="res://testing/mountains1.png" id="5_u3vhh"] +[ext_resource type="Shader" path="res://testing/water.gdshader" id="6_y3s8d"] + +[sub_resource type="Resource" id="Resource_hwcui"] +script = ExtResource("3_l4lvw") +mode = 0 +textures = [[], []] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_u8as5"] +render_priority = 0 +shader = ExtResource("4_d4jdj") +shader_parameter/height_ration = 5.0 +shader_parameter/heightmap = ExtResource("5_u3vhh") + +[sub_resource type="PlaneMesh" id="PlaneMesh_cr2e3"] +size = Vector2(200, 200) +subdivide_width = 100 +subdivide_depth = 100 + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_i35q3"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_2oefh"] +seamless = true +as_normal_map = true +noise = SubResource("FastNoiseLite_i35q3") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_7emex"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_cga1x"] +seamless = true +as_normal_map = true +noise = SubResource("FastNoiseLite_7emex") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_oe6vd"] + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_esb1b"] +seamless = true +noise = SubResource("FastNoiseLite_oe6vd") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_k47d8"] +render_priority = 0 +shader = ExtResource("6_y3s8d") +shader_parameter/albedo = Color(0, 0, 0.0823529, 1) +shader_parameter/albedo2 = Color(0, 0, 0.301961, 1) +shader_parameter/color_shallow = Color(0, 0, 0, 1) +shader_parameter/metallic = 0.483 +shader_parameter/roughness = 0.02 +shader_parameter/wave_time = 0.0 +shader_parameter/wave_direction = Vector2(2, 0) +shader_parameter/wave_2_direction = Vector2(0, 1) +shader_parameter/time_scale = 0.025 +shader_parameter/wave_speed = 2.0 +shader_parameter/noise_scale = 10.0 +shader_parameter/height_scale = 0.15 +shader_parameter/beers_law = 0.0 +shader_parameter/depth_offset = 0.0 +shader_parameter/edge_scale = 0.1 +shader_parameter/near = 0.1 +shader_parameter/far = 10000.0 +shader_parameter/edge_color = Color(0.415686, 0.490196, 0.8, 1) +shader_parameter/texture_normal = SubResource("NoiseTexture2D_2oefh") +shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_cga1x") +shader_parameter/wave = SubResource("NoiseTexture2D_esb1b") + +[sub_resource type="QuadMesh" id="QuadMesh_8bjqq"] +size = Vector2(5000, 5000) +subdivide_width = 100 +subdivide_depth = 100 +orientation = 1 + +[node name="testing" type="Node"] + +[node name="HTerrain" type="Node3D" parent="."] +script = ExtResource("1_vnlln") +_terrain_data = ExtResource("2_7sfpq") +chunk_size = 32 +collision_enabled = true +collision_layer = 1 +collision_mask = 1 +shader_type = "Classic4" +custom_shader = null +custom_globalmap_shader = null +texture_set = SubResource("Resource_hwcui") +render_layers = 1 +cast_shadow = 0 +shader_params/u_ground_uv_scale_per_texture = null +shader_params/u_depth_blending = true +shader_params/u_triplanar = null +shader_params/u_tile_reduction = null +shader_params/u_globalmap_blend_start = null +shader_params/u_globalmap_blend_distance = null +shader_params/u_colormap_opacity_per_texture = null + +[node name="MeshInstance3D" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 346.259, 0, 97.7753) +visible = false +material_override = SubResource("ShaderMaterial_u8as5") +mesh = SubResource("PlaneMesh_cr2e3") + +[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.555969, -7.62939e-06, -0.0280457) + +[node name="MeshInstance3D2" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) +material_override = SubResource("ShaderMaterial_k47d8") +cast_shadow = 0 +mesh = SubResource("QuadMesh_8bjqq") diff --git a/game/testing/water.gdshader b/game/testing/water.gdshader new file mode 100644 index 0000000..2e1ebd0 --- /dev/null +++ b/game/testing/water.gdshader @@ -0,0 +1,80 @@ +shader_type spatial; +render_mode depth_draw_always; + +uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap; +uniform sampler2D DEPTH_TEXTURE: hint_depth_texture, filter_linear_mipmap; + +uniform vec3 albedo : source_color; +uniform vec3 albedo2 : source_color; +uniform vec4 color_shallow : source_color; + +uniform float metallic : hint_range(0.0, 1.0) = 0; +uniform float roughness : hint_range(0.0, 1.0) = 0.02; + +uniform sampler2D texture_normal; +uniform sampler2D texture_normal2; +uniform sampler2D wave; + +uniform float wave_time = 0; +uniform vec2 wave_direction = vec2(2.0,0.0); +uniform vec2 wave_2_direction = vec2(0.0,1.0); +uniform float time_scale : hint_range(0.0, 0.2, 0.005) = 0.025; +uniform float wave_speed = 2.0; +uniform float noise_scale = 10.0; +uniform float height_scale = 0.15; +uniform float beers_law = 2.0; +uniform float depth_offset = -0.75; + +varying float height; +varying vec3 world_pos; + +uniform float edge_scale = 0.1; +uniform float near = 0.5; +uniform float far = 100.0; +uniform vec3 edge_color : source_color; + +float fresnel(float amount, vec3 normal, vec3 view) +{ + return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0 )), amount); +} + +float edge(float depth) { + return near * far / (far + depth * (near - far)); +} + +void vertex() { + world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; + height = texture(wave, world_pos.xz / noise_scale + wave_time * wave_speed).r; + VERTEX.y += height * height_scale; +} + +void fragment() { + float depth_texture = texture(DEPTH_TEXTURE, SCREEN_UV).r; + float depth = PROJECTION_MATRIX[3][2] / (depth_texture + PROJECTION_MATRIX[2][2]); + depth = depth + VERTEX.z; + float depth_blend = exp((depth + depth_offset) * -beers_law); + depth_blend = clamp(1.0 - depth_blend, 0.0, 1.0); + + vec3 screen_color = textureLod(SCREEN_TEXTURE, SCREEN_UV, depth_blend * 2.5).rgb; + vec3 depth_color = mix(color_shallow.rgb, albedo.rgb, depth_blend); + vec3 color = mix(screen_color * depth_color, depth_color * 0.25, depth_blend * 0.5); + + float z_depth = edge(texture(DEPTH_TEXTURE, SCREEN_UV).x); + float z_pos = edge(FRAGCOORD.z); + float z_dif = z_depth - z_pos; + + vec2 time = (TIME * wave_direction) * time_scale; + vec2 time2 = (TIME * wave_2_direction) * time_scale; + + vec3 normal_blend = mix(texture(texture_normal, world_pos.xz / noise_scale + time).rgb, texture(texture_normal2, world_pos.xz / noise_scale + time2).rgb, 0.5); + + float fresnel = fresnel(5.0, NORMAL, VIEW); + vec3 surface_color = mix(albedo, albedo2, fresnel); + vec3 depth_color_adj = mix(edge_color, color, step(edge_scale, z_dif)); + + ALBEDO = clamp(surface_color + depth_color_adj,vec3(0),vec3(1.0)); + ALPHA = 1.0; + METALLIC = metallic; + ROUGHNESS = roughness; + NORMAL_MAP = normal_blend; +}
\ No newline at end of file diff --git a/game/testing/water.tscn b/game/testing/water.tscn new file mode 100644 index 0000000..c336ccc --- /dev/null +++ b/game/testing/water.tscn @@ -0,0 +1,69 @@ +[gd_scene load_steps=11 format=3 uid="uid://cty2qgt0i5f4w"] + +[ext_resource type="Shader" path="res://assets/shaders/water.gdshader" id="1_oeaqx"] +[ext_resource type="Script" path="res://Water.gd" id="2_qv0cn"] + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hy6fq"] +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_brvoh"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hy6fq") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_hs2gb"] +noise_type = 3 +fractal_type = 2 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_u5h0n"] +seamless = true +as_normal_map = true +bump_strength = 1.5 +noise = SubResource("FastNoiseLite_hs2gb") + +[sub_resource type="FastNoiseLite" id="FastNoiseLite_jbi1g"] +noise_type = 3 +frequency = 0.001 +fractal_type = 2 +fractal_octaves = 3 + +[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_7k2l2"] +seamless = true +noise = SubResource("FastNoiseLite_jbi1g") + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0n3y0"] +render_priority = 0 +shader = ExtResource("1_oeaqx") +shader_parameter/albedo = Color(0, 0.321569, 0.431373, 1) +shader_parameter/albedo2 = Color(0, 0.47451, 0.764706, 1) +shader_parameter/color_deep = Color(0.105882, 0.294118, 0.329412, 1) +shader_parameter/color_shallow = Color(0, 0.552941, 0.65098, 1) +shader_parameter/metallic = 0.0 +shader_parameter/roughness = 0.02 +shader_parameter/wave_time = 0.0 +shader_parameter/wave_direction = Vector2(2, 0) +shader_parameter/wave_2_direction = Vector2(0, 1) +shader_parameter/time_scale = 0.025 +shader_parameter/wave_speed = 0.2 +shader_parameter/noise_scale = 10.0 +shader_parameter/height_scale = 2.0 +shader_parameter/beers_law = 0.089 +shader_parameter/depth_offset = -0.75 +shader_parameter/edge_scale = 0.362 +shader_parameter/near = 0.5 +shader_parameter/far = 100.0 +shader_parameter/edge_color = Color(1, 1, 1, 1) +shader_parameter/texture_normal = SubResource("NoiseTexture2D_brvoh") +shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_u5h0n") +shader_parameter/wave = SubResource("NoiseTexture2D_7k2l2") + +[sub_resource type="PlaneMesh" id="PlaneMesh_0xwda"] +material = SubResource("ShaderMaterial_0n3y0") +size = Vector2(500, 500) +subdivide_width = 500 +subdivide_depth = 500 + +[node name="Water" type="MeshInstance3D"] +mesh = SubResource("PlaneMesh_0xwda") +script = ExtResource("2_qv0cn") |