Uniforms.glsl 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. uniform float cLightRad;
  68. uniform float cLightLength;
  69. #endif
  70. uniform vec3 cZoneMin;
  71. uniform vec3 cZoneMax;
  72. uniform float cNearClipPS;
  73. uniform float cFarClipPS;
  74. uniform vec4 cShadowCubeAdjust;
  75. uniform vec4 cShadowDepthFade;
  76. uniform vec2 cShadowIntensity;
  77. uniform vec2 cShadowMapInvSize;
  78. uniform vec4 cShadowSplits;
  79. uniform mat4 cLightMatricesPS[4];
  80. #ifdef VSM_SHADOW
  81. uniform vec2 cVSMShadowParams;
  82. #endif
  83. #endif
  84. #else
  85. // OpenGL 3 uniforms (using constant buffers)
  86. #ifdef COMPILEVS
  87. uniform FrameVS
  88. {
  89. float cDeltaTime;
  90. float cElapsedTime;
  91. };
  92. uniform CameraVS
  93. {
  94. vec3 cCameraPos;
  95. float cNearClip;
  96. float cFarClip;
  97. vec4 cDepthMode;
  98. vec3 cFrustumSize;
  99. vec4 cGBufferOffsets;
  100. mat4 cView;
  101. mat4 cViewInv;
  102. mat4 cViewProj;
  103. vec4 cClipPlane;
  104. };
  105. uniform ZoneVS
  106. {
  107. vec3 cAmbientStartColor;
  108. vec3 cAmbientEndColor;
  109. mat4 cZone;
  110. };
  111. uniform LightVS
  112. {
  113. vec4 cLightPos;
  114. vec3 cLightDir;
  115. vec4 cNormalOffsetScale;
  116. #ifdef NUMVERTEXLIGHTS
  117. vec4 cVertexLights[4 * 3];
  118. #else
  119. mat4 cLightMatrices[4];
  120. #endif
  121. };
  122. #ifndef CUSTOM_MATERIAL_CBUFFER
  123. uniform MaterialVS
  124. {
  125. vec4 cUOffset;
  126. vec4 cVOffset;
  127. };
  128. #endif
  129. uniform ObjectVS
  130. {
  131. mat4 cModel;
  132. #ifdef BILLBOARD
  133. mat3 cBillboardRot;
  134. #endif
  135. #ifdef SKINNED
  136. uniform vec4 cSkinMatrices[MAXBONES*3];
  137. #endif
  138. };
  139. #endif
  140. #ifdef COMPILEPS
  141. // Pixel shader uniforms
  142. uniform FramePS
  143. {
  144. float cDeltaTimePS;
  145. float cElapsedTimePS;
  146. };
  147. uniform CameraPS
  148. {
  149. vec3 cCameraPosPS;
  150. vec4 cDepthReconstruct;
  151. vec2 cGBufferInvSize;
  152. float cNearClipPS;
  153. float cFarClipPS;
  154. };
  155. uniform ZonePS
  156. {
  157. vec4 cAmbientColor;
  158. vec4 cFogParams;
  159. vec3 cFogColor;
  160. vec3 cZoneMin;
  161. vec3 cZoneMax;
  162. };
  163. uniform LightPS
  164. {
  165. vec4 cLightColor;
  166. vec4 cLightPosPS;
  167. vec3 cLightDirPS;
  168. vec4 cNormalOffsetScalePS;
  169. vec4 cShadowCubeAdjust;
  170. vec4 cShadowDepthFade;
  171. vec2 cShadowIntensity;
  172. vec2 cShadowMapInvSize;
  173. vec4 cShadowSplits;
  174. mat4 cLightMatricesPS[4];
  175. #ifdef VSM_SHADOW
  176. vec2 cVSMShadowParams;
  177. #endif
  178. #ifdef PBR
  179. float cLightRad;
  180. float cLightLength;
  181. #endif
  182. };
  183. #ifndef CUSTOM_MATERIAL_CBUFFER
  184. uniform MaterialPS
  185. {
  186. vec4 cMatDiffColor;
  187. vec3 cMatEmissiveColor;
  188. vec3 cMatEnvMapColor;
  189. vec4 cMatSpecColor;
  190. #ifdef PBR
  191. float cRoughness;
  192. float cMetallic;
  193. #endif
  194. };
  195. #endif
  196. #endif
  197. #endif