You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
1.3 KiB

  1. shader_type spatial;
  2. uniform vec4 out_color : hint_color = vec4(0.0, 0.2, 1.0, 1.0);
  3. uniform float amount : hint_range(0.2, 1.5) = 0.8;
  4. uniform float beer_factor : hint_range(0.01, 1.5) = 0.2;
  5. float generate_offset(float x, float z, float val1, float val2, float time) {
  6. float speed = 1.0;
  7. float radiansx = ((mod(x + z * x * val1, amount) / amount) + (time * speed) * mod(x * 0.8 + z, 1.5)) * 2.0 * 3.14;
  8. float radiansz = ((mod(val2 * (z * x + z * x), amount) / amount) + (time * speed) * 2.0 * mod(x, 2.0)) * 2.0 * 3.14;
  9. return amount * 0.5 * (sin(radiansz) + cos(radiansx));
  10. }
  11. vec3 apply_distortion(vec3 vertex, float time) {
  12. float xd = generate_offset(vertex.x, vertex.z, 0.2, 0.1, time);
  13. float yd = generate_offset(vertex.x, vertex.z, 0.1, 0.3, time);
  14. float zd = generate_offset(vertex.x, vertex.z, 0.15, 0.2, time);
  15. return vertex + vec3(xd, yd, zd);
  16. }
  17. void vertex() {
  18. VERTEX = apply_distortion(VERTEX, TIME * 0.1);
  19. }
  20. void fragment() {
  21. NORMAL = normalize(cross(dFdx(VERTEX), dFdy(VERTEX)));
  22. METALLIC = 0.6;
  23. SPECULAR = 0.5;
  24. ROUGHNESS = 0.2;
  25. ALBEDO = out_color.xyz;
  26. float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
  27. depth = depth * 2.0 - 1.0;
  28. depth = PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
  29. depth = depth + VERTEX.z;
  30. depth = exp(-depth * beer_factor);
  31. ALPHA = clamp(1.0 - depth, 0.0, 1.0);
  32. }