Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. shader_type spatial;
  2.  
  3. render_mode unshaded;
  4.  
  5. uniform sampler2D colorA :hint_albedo;
  6. uniform sampler2D colorB :hint_albedo;
  7. uniform sampler2D colorC :hint_albedo;
  8.  
  9. uniform sampler2D normalA :hint_normal;
  10. uniform sampler2D normalB :hint_normal;
  11. uniform sampler2D normalC :hint_normal;
  12.  
  13. /////////////////////////////
  14. /*MASKING:
  15. R = METALIC
  16. G = ROUGHTNESS
  17. B = HEIGHT
  18. */
  19. uniform sampler2D maskingA;
  20. uniform sampler2D maskingB;
  21. uniform sampler2D maskingC;
  22. ////////////////////////////
  23. /*VERTEX COLOR:
  24. R = textureA
  25. G = textureB
  26. B = textureC
  27. */
  28. varying vec4 vertexColor;
  29.  
  30. void vertex() {
  31. vertexColor = COLOR;
  32. }
  33.  
  34. vec3 hlerp(vec4 texture1, float a1, vec4 texture2, float a2)
  35. {
  36. float depth = 0.2;
  37. float ma = max(texture1.a + a1, texture2.a + a2) - depth;
  38.  
  39. float b1 = max(texture1.a + a1 - ma, 0);
  40. float b2 = max(texture2.a + a2 - ma, 0);
  41.  
  42. return (texture1.rgb * b1 + texture2.rgb * b2) / (b1 + b2);
  43. }
  44.  
  45.  
  46.  
  47. float vColAdd (float a, float b){
  48. float result = max(a + b, 0);
  49. }
  50.  
  51.  
  52. void fragment(){
  53. vec4 colA = texture(colorA, UV);
  54. vec4 colB = texture(colorB, UV);
  55. vec4 colC = texture(colorC, UV);
  56.  
  57. vec4 norA = texture(normalA, UV);
  58. vec4 norB = texture(normalB, UV);
  59. vec4 norC = texture(normalC, UV);
  60.  
  61. vec4 maskA = texture(maskingA, UV);
  62. vec4 maskB = texture(maskingB, UV);
  63. vec4 maskC = texture(maskingC, UV);
  64.  
  65. // ALBEDO = hlerp(colA, vertexColor.r, colB, vertexColor.g).rgb;
  66.  
  67. // ALBEDO = colA.rgb;
  68.  
  69. NORMAL = hlerp(norA, vertexColor.r, norB, vertexColor.g).rgb;
  70. ROUGHNESS = 1f;
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement