36 lines
1.1 KiB
Plaintext
Raw Normal View History

2024-02-08 22:46:03 +00:00
shader_type spatial;
render_mode cull_disabled;
render_mode specular_toon;
// render_mode wireframe;
uniform vec3 color : source_color = vec3(0.055, 0.286, 0.62);
uniform vec3 fresnel_color : source_color = vec3(0.141, 0.447, 0.902);
uniform float fresnel_reduction = 5.0;
uniform float roughness : hint_range(0.0, 1.0) = 0.02;
uniform sampler2D height_map;
uniform sampler2D normal_map;
uniform float height_scale = 0.0;
uniform float noise_scale = 0.5;
varying vec2 noise_position;
float get_fresnel(float power, vec3 normal, vec3 view) {
return pow((1.0 - clamp(dot(normalize(normal), normalize(view)), 0.0, 1.0)), power);
}
void vertex() {
noise_position = VERTEX.xz * noise_scale + 0.5;
float height = texture(height_map, noise_position).x - 0.5;
VERTEX.y += height * height_scale;
}
void fragment() {
// NORMAL_MAP = texture(normal_map, UV).rgb;
NORMAL_MAP = texture(normal_map, noise_position).xyz;
float fresnel = get_fresnel(fresnel_reduction, NORMAL, VIEW);
RIM = 0.2;
METALLIC = 0.0;
ROUGHNESS = roughness * fresnel;
ALBEDO = mix(color, fresnel_color, fresnel);
}