Mutually_Assured_Destruction/shaders/water.gdshader
2023-06-11 10:44:54 -04:00

34 lines
1.1 KiB
Plaintext

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;
}