splatting.frag 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifdef Use_Bindless_Texture
  2. layout(bindless_sampler) uniform sampler2D tex_layout;
  3. layout(bindless_sampler) uniform sampler2D tex_detail0;
  4. layout(bindless_sampler) uniform sampler2D tex_detail1;
  5. layout(bindless_sampler) uniform sampler2D tex_detail2;
  6. layout(bindless_sampler) uniform sampler2D tex_detail3;
  7. #else
  8. uniform sampler2D tex_layout;
  9. uniform sampler2D tex_detail0;
  10. uniform sampler2D tex_detail1;
  11. uniform sampler2D tex_detail2;
  12. uniform sampler2D tex_detail3;
  13. #endif
  14. in vec2 uv;
  15. in vec2 uv_bis;
  16. out vec4 FragColor;
  17. vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
  18. void main() {
  19. // Splatting part
  20. vec4 splatting = texture(tex_layout, uv_bis);
  21. vec4 detail0 = texture(tex_detail0, uv);
  22. vec4 detail1 = texture(tex_detail1, uv);
  23. vec4 detail2 = texture(tex_detail2, uv);
  24. vec4 detail3 = texture(tex_detail3, uv);
  25. vec4 detail4 = vec4(0.0);
  26. #ifdef Use_Bindless_Texture
  27. #ifdef SRGBBindlessFix
  28. detail0.xyz = pow(detail0.xyz, vec3(2.2));
  29. detail1.xyz = pow(detail1.xyz, vec3(2.2));
  30. detail2.xyz = pow(detail2.xyz, vec3(2.2));
  31. detail3.xyz = pow(detail3.xyz, vec3(2.2));
  32. #endif
  33. #endif
  34. vec4 splatted = splatting.r * detail0 +
  35. splatting.g * detail1 +
  36. splatting.b * detail2 +
  37. max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
  38. FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0., 0.), 1.);
  39. }