some environnement and water stuff

This commit is contained in:
Victor Turgeon
2023-06-11 10:44:54 -04:00
parent 5614495e12
commit 19847bd56c
4 changed files with 126 additions and 2 deletions

33
shaders/water.gdshader Normal file
View File

@@ -0,0 +1,33 @@
shader_type spatial;
uniform vec3 albedo : source_color;
uniform vec3 albedo2 : 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 texture_image;
uniform vec2 wave_direction = vec2(2.0,0.0);
uniform vec2 wave_direction2 = vec2(0.0,1.0);
uniform float time_scale : hint_range(0.0, 0.2, 0.005) = 0.005;
float fresnel(float amount, vec3 normal, vec3 view){
return pow((1.0 - clamp(dot(normalize(normal), normalize(view)),0.0,1.0)),amount);
}
void fragment() {
vec2 time = (TIME * wave_direction) * time_scale;
vec2 time2 = (TIME * wave_direction2) * time_scale;
vec3 normal_blend = mix(texture(texture_normal, UV + time).rgb, texture(texture_normal2, UV + time2).rgb, 0.5);
float fresnel = fresnel(5.0, NORMAL, VIEW);
vec3 surface_color = mix(albedo, albedo2, fresnel);
vec3 surface_texture = mix(surface_color, texture(texture_image, UV + time).rgb, 0.2);
ALBEDO = surface_texture;
METALLIC = metallic;
ROUGHNESS = roughness;
NORMAL_MAP = normal_blend;
ALPHA = 0.8;
}

48
shaders/water_plane.tscn Normal file
View File

@@ -0,0 +1,48 @@
[gd_scene load_steps=9 format=3 uid="uid://c2casdi4d2o3j"]
[ext_resource type="Shader" path="res://shaders/water.gdshader" id="1_yfj5n"]
[ext_resource type="Texture2D" uid="uid://bsw8l5crn3aid" path="res://assets/textures/water.png" id="2_83coh"]
[sub_resource type="QuadMesh" id="QuadMesh_x322w"]
subdivide_width = 200
subdivide_depth = 200
orientation = 1
[sub_resource type="FastNoiseLite" id="FastNoiseLite_ido7w"]
noise_type = 3
fractal_type = 2
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_ntr7e"]
seamless = true
as_normal_map = true
bump_strength = 1.5
noise = SubResource("FastNoiseLite_ido7w")
[sub_resource type="FastNoiseLite" id="FastNoiseLite_bfpu3"]
noise_type = 3
seed = 69
fractal_type = 2
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_wvpl0"]
seamless = true
as_normal_map = true
bump_strength = 1.5
noise = SubResource("FastNoiseLite_bfpu3")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_yma05"]
render_priority = 0
shader = ExtResource("1_yfj5n")
shader_parameter/albedo = Color(0.101961, 0.0509804, 0.431373, 1)
shader_parameter/albedo2 = Color(0.658824, 0.905882, 0.929412, 1)
shader_parameter/metallic = 0.0
shader_parameter/roughness = 0.02
shader_parameter/wave_direction = Vector2(2, 0)
shader_parameter/wave_direction2 = Vector2(0, 1)
shader_parameter/time_scale = 0.025
shader_parameter/texture_normal = SubResource("NoiseTexture2D_ntr7e")
shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_wvpl0")
shader_parameter/texture_image = ExtResource("2_83coh")
[node name="water_plane" type="MeshInstance3D"]
mesh = SubResource("QuadMesh_x322w")
surface_material_override/0 = SubResource("ShaderMaterial_yma05")