legacypbr.vertex.fx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. precision mediump float;
  2. // Attributes
  3. attribute vec3 position;
  4. attribute vec3 normal;
  5. #ifdef UV1
  6. attribute vec2 uv;
  7. #endif
  8. #ifdef UV2
  9. attribute vec2 uv2;
  10. #endif
  11. #ifdef VERTEXCOLOR
  12. attribute vec4 color;
  13. #endif
  14. #include<bonesDeclaration>
  15. // Uniforms
  16. uniform mat4 world;
  17. uniform mat4 view;
  18. uniform mat4 viewProjection;
  19. #ifdef ALBEDO
  20. varying vec2 vAlbedoUV;
  21. uniform mat4 albedoMatrix;
  22. uniform vec2 vAlbedoInfos;
  23. #endif
  24. #ifdef AMBIENT
  25. varying vec2 vAmbientUV;
  26. uniform mat4 ambientMatrix;
  27. uniform vec2 vAmbientInfos;
  28. #endif
  29. #ifdef OPACITY
  30. varying vec2 vOpacityUV;
  31. uniform mat4 opacityMatrix;
  32. uniform vec2 vOpacityInfos;
  33. #endif
  34. #ifdef EMISSIVE
  35. varying vec2 vEmissiveUV;
  36. uniform vec2 vEmissiveInfos;
  37. uniform mat4 emissiveMatrix;
  38. #endif
  39. #if defined(REFLECTIVITY)
  40. varying vec2 vReflectivityUV;
  41. uniform vec2 vReflectivityInfos;
  42. uniform mat4 reflectivityMatrix;
  43. #endif
  44. // Output
  45. varying vec3 vPositionW;
  46. varying vec3 vNormalW;
  47. #ifdef VERTEXCOLOR
  48. varying vec4 vColor;
  49. #endif
  50. #include<clipPlaneVertexDeclaration>
  51. void main(void) {
  52. mat4 finalWorld = world;
  53. #include<bonesVertex>
  54. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  55. vec4 worldPos = finalWorld * vec4(position, 1.0);
  56. vPositionW = vec3(worldPos);
  57. vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
  58. // Texture coordinates
  59. #ifndef UV1
  60. vec2 uv = vec2(0., 0.);
  61. #endif
  62. #ifndef UV2
  63. vec2 uv2 = vec2(0., 0.);
  64. #endif
  65. #ifdef ALBEDO
  66. if (vAlbedoInfos.x == 0.)
  67. {
  68. vAlbedoUV = vec2(albedoMatrix * vec4(uv, 1.0, 0.0));
  69. }
  70. else
  71. {
  72. vAlbedoUV = vec2(albedoMatrix * vec4(uv2, 1.0, 0.0));
  73. }
  74. #endif
  75. #ifdef AMBIENT
  76. if (vAmbientInfos.x == 0.)
  77. {
  78. vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
  79. }
  80. else
  81. {
  82. vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
  83. }
  84. #endif
  85. #ifdef OPACITY
  86. if (vOpacityInfos.x == 0.)
  87. {
  88. vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
  89. }
  90. else
  91. {
  92. vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
  93. }
  94. #endif
  95. #ifdef EMISSIVE
  96. if (vEmissiveInfos.x == 0.)
  97. {
  98. vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
  99. }
  100. else
  101. {
  102. vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
  103. }
  104. #endif
  105. #if defined(REFLECTIVITY)
  106. if (vReflectivityInfos.x == 0.)
  107. {
  108. vReflectivityUV = vec2(reflectivityMatrix * vec4(uv, 1.0, 0.0));
  109. }
  110. else
  111. {
  112. vReflectivityUV = vec2(reflectivityMatrix * vec4(uv2, 1.0, 0.0));
  113. }
  114. #endif
  115. #include<clipPlaneVertex>
  116. // Vertex color
  117. #ifdef VERTEXCOLOR
  118. vColor = color;
  119. #endif
  120. }