72 lines
2.2 KiB
Plaintext
72 lines
2.2 KiB
Plaintext
shader_type spatial;
|
|
render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx;
|
|
uniform vec4 albedo : source_color;
|
|
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
|
|
uniform ivec2 albedo_texture_size;
|
|
uniform float point_size : hint_range(0.1, 128.0, 0.1);
|
|
|
|
uniform float roughness : hint_range(0.0, 1.0);
|
|
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
|
|
uniform vec4 metallic_texture_channel;
|
|
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
|
|
|
|
uniform float specular : hint_range(0.0, 1.0, 0.01);
|
|
uniform float metallic : hint_range(0.0, 1.0, 0.01);
|
|
|
|
uniform vec3 uv1_scale;
|
|
uniform vec3 uv1_offset;
|
|
uniform vec3 uv2_scale;
|
|
uniform vec3 uv2_offset;
|
|
|
|
// Controls the frequency of the waves
|
|
uniform float amount : hint_range(0.0, 100.0, 0.01) = 20.0;
|
|
|
|
// Controls the overall distortion intensity
|
|
uniform float move = 1.0;
|
|
|
|
// Base height of the sinusoidal bands
|
|
uniform float bandsize = 0.1;
|
|
|
|
// Speed of wave movement
|
|
uniform float speed = 1.0;
|
|
|
|
void vertex() {
|
|
// Center UV to create symmetrical effect
|
|
vec2 uv = UV - 0.5;
|
|
|
|
// Adds movement with time
|
|
uv.y += TIME * speed;
|
|
|
|
// Calculates animated sinusoidal value
|
|
float wave = sin(uv.y * amount) + bandsize;
|
|
|
|
// Applies distortion along the sphere normal
|
|
VERTEX += NORMAL * wave * move;
|
|
}
|
|
|
|
void fragment() {
|
|
// Center UV to keep the same pattern as vertex shader
|
|
vec2 uv = UV - 0.5;
|
|
|
|
// Animates the waves on the Y axis
|
|
uv.y += TIME * speed;
|
|
|
|
// Creates the same sinusoidal function to draw the pattern
|
|
float wave = sin(uv.y * amount) + bandsize;
|
|
|
|
// Sets the band color based on the sinusoidal value
|
|
ALBEDO = vec3(wave);
|
|
|
|
vec2 base_uv = UV;
|
|
|
|
vec4 albedo_tex = texture(texture_albedo, base_uv);
|
|
ALBEDO = albedo.rgb * albedo_tex.rgb;
|
|
|
|
float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
|
|
METALLIC = metallic_tex * metallic;
|
|
SPECULAR = specular;
|
|
|
|
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
|
|
float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
|
|
ROUGHNESS = roughness_tex * roughness;
|
|
} |