background.vertex.fx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. precision highp float;
  2. #include<__decl__backgroundVertex>
  3. #include<helperFunctions>
  4. // Attributes
  5. attribute vec3 position;
  6. #ifdef NORMAL
  7. attribute vec3 normal;
  8. #endif
  9. #include<bonesDeclaration>
  10. // Uniforms
  11. #include<instancesDeclaration>
  12. // Output
  13. varying vec3 vPositionW;
  14. #ifdef NORMAL
  15. varying vec3 vNormalW;
  16. #endif
  17. #ifdef UV1
  18. attribute vec2 uv;
  19. #endif
  20. #ifdef UV2
  21. attribute vec2 uv2;
  22. #endif
  23. #ifdef MAINUV1
  24. varying vec2 vMainUV1;
  25. #endif
  26. #ifdef MAINUV2
  27. varying vec2 vMainUV2;
  28. #endif
  29. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  30. varying vec2 vDiffuseUV;
  31. #endif
  32. #include<clipPlaneVertexDeclaration>
  33. #include<fogVertexDeclaration>
  34. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  35. #ifdef REFLECTIONMAP_SKYBOX
  36. varying vec3 vPositionUVW;
  37. #endif
  38. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  39. varying vec3 vDirectionW;
  40. #endif
  41. void main(void) {
  42. #ifdef REFLECTIONMAP_SKYBOX
  43. #ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED
  44. vPositionUVW = (reflectionMatrix * vec4(position, 1.0)).xyz;
  45. #else
  46. vPositionUVW = position;
  47. #endif
  48. #endif
  49. #include<instancesVertex>
  50. #include<bonesVertex>
  51. #ifdef MULTIVIEW
  52. if (gl_ViewID_OVR == 0u) {
  53. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  54. } else {
  55. gl_Position = viewProjectionR * finalWorld * vec4(position, 1.0);
  56. }
  57. #else
  58. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  59. #endif
  60. vec4 worldPos = finalWorld * vec4(position, 1.0);
  61. vPositionW = vec3(worldPos);
  62. #ifdef NORMAL
  63. mat3 normalWorld = mat3(finalWorld);
  64. #ifdef NONUNIFORMSCALING
  65. normalWorld = transposeMat3(inverseMat3(normalWorld));
  66. #endif
  67. vNormalW = normalize(normalWorld * normal);
  68. #endif
  69. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  70. vDirectionW = normalize(vec3(finalWorld * vec4(position, 0.0)));
  71. #ifdef EQUIRECTANGULAR_RELFECTION_FOV
  72. mat3 screenToWorld = inverseMat3(mat3(finalWorld * viewProjection));
  73. vec3 segment = mix(vDirectionW, screenToWorld * vec3(0.0,0.0, 1.0), abs(fFovMultiplier - 1.0));
  74. if (fFovMultiplier <= 1.0) {
  75. vDirectionW = normalize(segment);
  76. } else {
  77. vDirectionW = normalize(vDirectionW + (vDirectionW - segment));
  78. }
  79. #endif
  80. #endif
  81. #ifndef UV1
  82. vec2 uv = vec2(0., 0.);
  83. #endif
  84. #ifndef UV2
  85. vec2 uv2 = vec2(0., 0.);
  86. #endif
  87. #ifdef MAINUV1
  88. vMainUV1 = uv;
  89. #endif
  90. #ifdef MAINUV2
  91. vMainUV2 = uv2;
  92. #endif
  93. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  94. if (vDiffuseInfos.x == 0.)
  95. {
  96. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  97. }
  98. else
  99. {
  100. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  101. }
  102. #endif
  103. // Clip plane
  104. #include<clipPlaneVertex>
  105. // Fog
  106. #include<fogVertex>
  107. // Shadows
  108. #include<shadowsVertex>[0..maxSimultaneousLights]
  109. // Vertex color
  110. #ifdef VERTEXCOLOR
  111. vColor = color;
  112. #endif
  113. // Point size
  114. #ifdef POINTSIZE
  115. gl_PointSize = pointSize;
  116. #endif
  117. }