Uniforms.glsl 4.0 KB

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