Uniforms.glsl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // Use of constant buffers on OpenGL 3 commented out for now as it seems to be slower in practice
  2. //#define USE_CBUFFERS
  3. #if !defined(GL3) || !defined(USE_CBUFFERS)
  4. // OpenGL 2 uniforms (no constant buffers)
  5. #ifdef COMPILEVS
  6. // Vertex shader uniforms
  7. uniform vec3 cAmbientStartColor;
  8. uniform vec3 cAmbientEndColor;
  9. uniform mat3 cBillboardRot;
  10. uniform vec3 cCameraPos;
  11. uniform mat3 cCameraRot;
  12. uniform float cNearClip;
  13. uniform float cFarClip;
  14. uniform vec4 cDepthMode;
  15. uniform vec3 cFrustumSize;
  16. uniform float cDeltaTime;
  17. uniform float cElapsedTime;
  18. uniform vec4 cGBufferOffsets;
  19. uniform vec3 cLightDir;
  20. uniform vec4 cLightPos;
  21. uniform mat4 cModel;
  22. uniform mat4 cViewProj;
  23. uniform vec4 cUOffset;
  24. uniform vec4 cVOffset;
  25. uniform mat4 cZone;
  26. #if !defined(GL_ES) || defined(WEBGL)
  27. uniform mat4 cLightMatrices[4];
  28. #else
  29. uniform mat4 cLightMatrices[2];
  30. #endif
  31. #ifdef SKINNED
  32. uniform vec4 cSkinMatrices[MAXBONES*3];
  33. #endif
  34. #ifdef NUMVERTEXLIGHTS
  35. uniform vec4 cVertexLights[4*3];
  36. #endif
  37. #ifdef GL3
  38. uniform vec4 cClipPlane;
  39. #endif
  40. #endif
  41. #ifdef COMPILEPS
  42. // Fragment shader uniforms
  43. #ifdef GL_ES
  44. precision mediump float;
  45. #endif
  46. uniform vec3 cAmbientColor;
  47. uniform vec3 cCameraPosPS;
  48. uniform float cDeltaTimePS;
  49. uniform vec4 cDepthReconstruct;
  50. uniform float cElapsedTimePS;
  51. uniform vec4 cFogParams;
  52. uniform vec3 cFogColor;
  53. uniform vec2 cGBufferInvSize;
  54. uniform vec4 cLightColor;
  55. uniform vec3 cLightDirPS;
  56. uniform vec4 cLightPosPS;
  57. uniform vec4 cMatDiffColor;
  58. uniform vec3 cMatEmissiveColor;
  59. uniform vec3 cMatEnvMapColor;
  60. uniform vec4 cMatSpecColor;
  61. uniform float cNearClipPS;
  62. uniform float cFarClipPS;
  63. uniform vec4 cShadowCubeAdjust;
  64. uniform vec4 cShadowDepthFade;
  65. uniform vec2 cShadowIntensity;
  66. uniform vec2 cShadowMapInvSize;
  67. uniform vec4 cShadowSplits;
  68. uniform mat4 cLightMatricesPS[4];
  69. #endif
  70. #else
  71. // OpenGL 3 uniforms (using constant buffers)
  72. #ifdef COMPILEVS
  73. uniform FrameVS
  74. {
  75. float cDeltaTime;
  76. float cElapsedTime;
  77. };
  78. uniform CameraVS
  79. {
  80. vec3 cCameraPos;
  81. mat3 cCameraRot;
  82. float cNearClip;
  83. float cFarClip;
  84. vec4 cDepthMode;
  85. vec3 cFrustumSize;
  86. vec4 cGBufferOffsets;
  87. mat4 cViewProj;
  88. vec4 cClipPlane;
  89. };
  90. uniform ZoneVS
  91. {
  92. vec3 cAmbientStartColor;
  93. vec3 cAmbientEndColor;
  94. mat4 cZone;
  95. };
  96. uniform LightVS
  97. {
  98. vec3 cLightDir;
  99. vec4 cLightPos;
  100. #ifdef NUMVERTEXLIGHTS
  101. vec4 cVertexLights[4 * 3];
  102. #else
  103. mat4 cLightMatrices[4];
  104. #endif
  105. };
  106. #ifndef CUSTOM_MATERIAL_CBUFFER
  107. uniform MaterialVS
  108. {
  109. vec4 cUOffset;
  110. vec4 cVOffset;
  111. };
  112. #endif
  113. uniform ObjectVS
  114. {
  115. mat4 cModel;
  116. #ifdef BILLBOARD
  117. mat3 cBillboardRot;
  118. #endif
  119. #ifdef SKINNED
  120. uniform vec4 cSkinMatrices[MAXBONES*3];
  121. #endif
  122. };
  123. #endif
  124. #ifdef COMPILEPS
  125. // Pixel shader uniforms
  126. uniform FramePS
  127. {
  128. float cDeltaTimePS;
  129. float cElapsedTimePS;
  130. };
  131. uniform CameraPS
  132. {
  133. vec3 cCameraPosPS;
  134. vec4 cDepthReconstruct;
  135. vec2 cGBufferInvSize;
  136. float cNearClipPS;
  137. float cFarClipPS;
  138. };
  139. uniform ZonePS
  140. {
  141. vec3 cAmbientColor;
  142. vec4 cFogParams;
  143. vec3 cFogColor;
  144. };
  145. uniform LightPS
  146. {
  147. vec4 cLightColor;
  148. vec4 cLightPosPS;
  149. vec3 cLightDirPS;
  150. vec4 cShadowCubeAdjust;
  151. vec4 cShadowDepthFade;
  152. vec2 cShadowIntensity;
  153. vec2 cShadowMapInvSize;
  154. vec4 cShadowSplits;
  155. mat4 cLightMatricesPS[4];
  156. };
  157. #ifndef CUSTOM_MATERIAL_CBUFFER
  158. uniform MaterialPS
  159. {
  160. vec4 cMatDiffColor;
  161. vec3 cMatEmissiveColor;
  162. vec3 cMatEnvMapColor;
  163. vec4 cMatSpecColor;
  164. };
  165. #endif
  166. #endif
  167. #endif