50 lines
1.4 KiB
Plaintext
50 lines
1.4 KiB
Plaintext
shader_type spatial;
|
|
|
|
uniform vec3 albedo : source_color;
|
|
uniform vec3 albedo_fresnel : source_color;
|
|
|
|
uniform float metallic : hint_range(0.0,1.0) = 0;
|
|
uniform float roughness : hint_range(0.0,1.0) = 0.02;
|
|
uniform float transparency : hint_range(0.0,1.0) = 0.9;
|
|
uniform sampler2D texture_normal;
|
|
uniform sampler2D texture_normal2;
|
|
|
|
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.025;
|
|
|
|
void vertex() {
|
|
// Called for every vertex the material is visible on.
|
|
|
|
}
|
|
|
|
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() {
|
|
// Time calculations for wave/normal map movement
|
|
vec2 time = (TIME * wave_direction) * time_scale;
|
|
vec2 time2 = (TIME * wave_direction2) * time_scale;
|
|
|
|
// Blend normal meps into one
|
|
vec3 normal_blend = mix(texture(texture_normal,UV + time).rgb, texture(texture_normal2,UV + time2).rgb, 0.5);
|
|
|
|
// Fresnel
|
|
float fresnel = fresnel(5.0, NORMAL, VIEW);
|
|
vec3 surface_color = mix(albedo, albedo_fresnel, fresnel); // INterpolate albedo values by fresnel
|
|
|
|
ALBEDO = surface_color;
|
|
METALLIC = metallic;
|
|
ROUGHNESS = roughness;
|
|
NORMAL_MAP = normal_blend;
|
|
ALPHA = transparency;
|
|
|
|
}
|
|
|
|
//void light() {
|
|
// Called for every pixel for every light affecting the material.
|
|
// Uncomment to replace the default light processing function with this one.
|
|
//}
|