JanusIIV

unfinished toon water shader

Mar 2nd, 2021
786
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shader_type spatial;
  2. render_mode unshaded;
  3.  
  4. uniform vec4 colour : hint_color = vec4(1, 1, 1, 1);
  5. uniform float udepth : hint_range(0, 30) = 18;
  6. uniform float vdepth : hint_range(0, 30) = 15;
  7. uniform float utime : hint_range(0, 10) = 18;
  8. uniform float vtime : hint_range(0, 10) = 18;
  9. uniform float uscale : hint_range(0, 1) = 0.1;
  10. uniform float vscale : hint_range(0, 1) = 0.2;
  11. uniform float umovement : hint_range(0, 5) = 2;
  12. uniform float vmovement : hint_range(0, 5) = 5;
  13.  
  14. uniform vec4 blend_colour : hint_color = vec4(1, 1, 1, 1);
  15. uniform float softness : hint_range(0.01, 3.0) = 1.0;
  16. uniform float fade_limit : hint_range(0.0, 1.0) = 0.3;
  17. uniform float wave_speed : hint_range(0.0, 100) = 10;
  18. uniform float wave_amp : hint_range(0.0, 1) = 0.25;
  19. uniform float wave_offset : hint_range(0.0, 5) = 2;
  20.  
  21. uniform sampler2D water_texture: hint_white;
  22. uniform sampler2D depth_texture;
  23.  
  24. void vertex(){
  25.     vec3 v0 = VERTEX.xyz;
  26.     float phase0 = wave_amp * sin((TIME * wave_speed) + (v0.x * wave_offset) + (v0.z * wave_offset));
  27.     float phase0_1 = wave_amp * cos((TIME * wave_speed) - (v0.x * -wave_offset) - (v0.z * -wave_offset));
  28.    
  29.     VERTEX.y += (phase0 + phase0_1) * wave_amp;
  30.     VERTEX.x -= (phase0_1 * 1.75) * wave_amp;
  31.     VERTEX.z += (phase0_1 * 3.5) * wave_amp;
  32. }
  33.  
  34. void fragment(){
  35.     float u = FRAGCOORD.x + sin(TIME * umovement);
  36.     float v = FRAGCOORD.y + sin(TIME * vmovement);
  37.    
  38.     float newU = sin((udepth * u + (TIME * utime)) * 0.25) * uscale + v;
  39.     float newV = sin((vdepth * v + (TIME * vtime)) * 0.25) * vscale + u;
  40.    
  41.     ALBEDO = (textureLod(water_texture, vec2(newU, newV), 0.0) * colour).rgb;
  42.     ALPHA = colour.a;
  43.     METALLIC = 0.0;
  44.     ROUGHNESS = 0.0;
  45.    
  46.     float rawZ = FRAGCOORD.z;
  47.     float sceneZ = NORMALMAP_DEPTH;
  48.     float partZ = FRAGCOORD.z;
  49.     float fade = 1.0;
  50.    
  51.     if (rawZ > 0.0) {
  52.         fade = clamp(0, 1.0, softness * (sceneZ - partZ));
  53.     }
  54.    
  55.     if (fade < fade_limit) {
  56.         ALBEDO = ALBEDO.rgb * fade + blend_colour.rgb * (1.0 - fade);
  57.     }
  58. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×