water_shader.gdshader 972 B

123456789101112131415161718192021222324252627282930313233
  1. shader_type spatial;
  2. render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx;
  3. uniform vec3 albedo : source_color;
  4. uniform float metalic : hint_range(0.0, 1.0, 0.1) = 0.8;
  5. uniform float roughness : hint_range(0.0, 1.0, 0.1) = 0.2;
  6. uniform sampler2D effect_texture;
  7. uniform vec2 effect_texture_size;
  8. varying vec2 uv_tangent;
  9. varying vec2 uv_binormal;
  10. void vertex() {
  11. vec2 pixel_size = vec2(1.0, 1.0) / effect_texture_size;
  12. uv_tangent = UV + vec2(pixel_size.x, 0.0);
  13. uv_binormal = UV + vec2(0.0, pixel_size.y);
  14. }
  15. void fragment() {
  16. float f1 = texture(effect_texture, UV).r;
  17. float f2 = texture(effect_texture, uv_tangent).r;
  18. float f3 = texture(effect_texture, uv_binormal).r;
  19. vec3 tangent = normalize(vec3(1.0, 0.0, f2 - f1));
  20. vec3 binormal = normalize(vec3(0.0, 1.0, f3 - f1));
  21. NORMAL_MAP = normalize(cross(binormal, tangent)) * 0.5 + 0.5;
  22. ALBEDO = albedo.rgb;
  23. METALLIC = metalic;
  24. ROUGHNESS = roughness;
  25. SPECULAR = 0.5;
  26. }