Created
February 6, 2018 01:33
-
-
Save jedStevens/4bd98bfcce781ff7779a38d61396ec4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 3D Water Shader | |
// From: Mr. Jed's Water Shaders | Part 2 | |
shader_type spatial; | |
uniform sampler2D alb_texture; | |
uniform sampler2D flow_texture; | |
uniform float flow_amt = 0.1; | |
uniform float duration = 1.0; | |
uniform vec2 scale = vec2(1.0,1.0); | |
void fragment(){ | |
float time = mod(TIME, duration) / duration; | |
float time_shift = mod(TIME + duration / 2.0, duration) / duration; | |
vec2 dir0 = normalize(texture(flow_texture, scale * UV).rg) - vec2(0.5,0.5); | |
vec2 flow_uv0 = scale* UV + dir0 * time * flow_amt; | |
float alpha0 = 1.0 - abs(1.0 - 2.0 * time); | |
vec2 dir1 = normalize(texture(flow_texture, scale * UV).rg) - vec2(0.5,0.5); | |
vec2 flow_uv1 = scale * UV + dir1 * time_shift * flow_amt; | |
float alpha1 = 1.0 - abs(1.0 - 2.0 * time_shift); | |
vec3 color0 = texture(alb_texture, flow_uv0).rgb; | |
vec3 color1 = texture(alb_texture, flow_uv1).rgb; | |
ALBEDO = (color0 * alpha0 + color1 * alpha1); | |
ALPHA = 0.56; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment