std.glsl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #ifndef STD_ENUMS_GLSL
  2. #define STD_ENUMS_GLSL
  3. /*==============================================================================
  4. VARS
  5. ==============================================================================*/
  6. #var CONSTANTS_HACK 0
  7. /*============================================================================*/
  8. // textures
  9. #define TEXTURE_COORDS_NONE 0
  10. #define TEXTURE_COORDS_UV_ORCO 1
  11. #define TEXTURE_COORDS_NORMAL 2
  12. #define TEXTURE_BLEND_TYPE_MIX 1
  13. #define TEXTURE_BLEND_TYPE_MULTIPLY 2
  14. // shadows
  15. #define SHADOW_SRC_NONE 1
  16. #define SHADOW_SRC_DEPTH 2
  17. #define SHADOW_SRC_MASK 3
  18. #define SHADOW_DST_NONE 1
  19. #define SHADOW_DST_DEPTH 2
  20. #define SHADOW_DST_MASK 3
  21. // no shadows: full disabled shadows, certain subs without shadows (REFLECT/GLOW),
  22. // non-casting and/or non-receiving batches
  23. #define NO_SHADOWS 1
  24. // shadow casting: SHADOW_CAST subs
  25. #define SHADOW_CASTING 2
  26. // shadow mask generation: DEPTH subs
  27. #define SHADOW_MASK_GENERATION 3
  28. // shadow mapping: MAIN_OPAQUE subs
  29. #define SHADOW_MAPPING_OPAQUE 4
  30. // shadow mapping: MAIN_BLEND/MAIN_XRAY subs
  31. #define SHADOW_MAPPING_BLEND 5
  32. #define POISSON_X_16 4
  33. #define POISSON_X_8 2
  34. #define POISSON_X_4 1
  35. #define NO_SOFT_SHADOWS 0
  36. // materials
  37. #define SPECULAR_PHONG 1
  38. #define SPECULAR_COOKTORR 2
  39. #define SPECULAR_WARDISO 3
  40. #define SPECULAR_BLINN 4
  41. #define SPECULAR_TOON 5
  42. #define DIFFUSE_LAMBERT 1
  43. #define DIFFUSE_OREN_NAYAR 2
  44. #define DIFFUSE_FRESNEL 3
  45. #define DIFFUSE_MINNAERT 4
  46. #define DIFFUSE_TOON 5
  47. // world textures
  48. #define MIX 0
  49. #define ADD 1
  50. #define SUBTRACT 2
  51. #define MULTIPLY 3
  52. #define SCREEN 4
  53. #define OVERLAY 5
  54. #define DIFFERENCE 6
  55. #define DIVIDE 7
  56. #define DARKEN 8
  57. #define LIGHTEN 9
  58. #define HUE 10
  59. #define SATURATION 11
  60. #define VALUE 12
  61. #define COLOR 13
  62. #define SOFT_LIGHT 14
  63. #define LINEAR_LIGHT 15
  64. // reflections
  65. #define REFL_NONE 0
  66. #define REFL_MIRRORMAP 1
  67. #define REFL_PLANE 2
  68. #define REFL_CUBE 3
  69. // fog types
  70. #define INVERSE_QUADRATIC 0
  71. #define LINEAR 1
  72. #define QUADRATIC 2
  73. // lamps
  74. #define HEMI 1
  75. #define SPOT 2
  76. #define POINT 3
  77. #define SUN 4
  78. // dof
  79. #define DOF_SIMPLE 0
  80. #define DOF_BOKEH 1
  81. // coc
  82. #define COC_ALL 0
  83. #define COC_FOREGROUND 1
  84. #define COC_COMBINE 2
  85. // NOTE: keep node constants synchronized with:
  86. // src/nodemat.js : append_nmat_node
  87. // src/batch.js : update_batch_material_nodes
  88. //
  89. // for vector transform
  90. #define VT_WORLD_TO_WORLD 0
  91. #define VT_WORLD_TO_OBJECT 1
  92. #define VT_WORLD_TO_CAMERA 2
  93. #define VT_OBJECT_TO_WORLD 3
  94. #define VT_OBJECT_TO_OBJECT 4
  95. #define VT_OBJECT_TO_CAMERA 5
  96. #define VT_CAMERA_TO_WORLD 6
  97. #define VT_CAMERA_TO_OBJECT 7
  98. #define VT_CAMERA_TO_CAMERA 8
  99. #define VT_POINT 0
  100. #define VT_VECTOR 1
  101. #define VT_NORMAL 2
  102. // for normal map
  103. #define NM_TANGENT 0
  104. #define NM_OBJECT 1
  105. #define NM_WORLD 2
  106. #define NM_BLENDER_OBJECT 3
  107. #define NM_BLENDER_WORLD 4
  108. // billboard particles
  109. #define BILLBOARD_ALIGN_VIEW 1
  110. #define BILLBOARD_ALIGN_XY 2
  111. #define BILLBOARD_ALIGN_YZ 3
  112. #define BILLBOARD_ALIGN_ZX 4
  113. // postprocessing effects
  114. #define POST_EFFECT_NONE 1
  115. #define POST_EFFECT_GRAYSCALE 2
  116. #define POST_EFFECT_BLUR 3
  117. #define POST_EFFECT_GLOW_BLUR 4
  118. #define POST_EFFECT_DOF_BLUR 5
  119. #define POST_EFFECT_ALPHA_BLUR 6
  120. #define POST_EFFECT_EXTEND 7
  121. #define FLIP_CUBEMAP_COORDS 8
  122. // debug view modes
  123. #define DV_NONE 0
  124. #define DV_OPAQUE_WIREFRAME 1
  125. #define DV_TRANSPARENT_WIREFRAME 2
  126. #define DV_FRONT_BACK_VIEW 3
  127. #define DV_BOUNDINGS 4
  128. #define DV_CLUSTERS_VIEW 5
  129. #define DV_BATCHES_VIEW 6
  130. #define DV_RENDER_TIME 7
  131. // SSAO quality
  132. #define SSAO_QUALITY_8 1
  133. #define SSAO_QUALITY_16 2
  134. #define SSAO_QUALITY_24 3
  135. #define SSAO_QUALITY_32 4
  136. // AA stuff
  137. #define AA_METHOD_FXAA_LIGHT 1
  138. #define AA_METHOD_FXAA_QUALITY 2
  139. #define AA_QUALITY_LOW 0
  140. #define AA_QUALITY_MEDIUM 1
  141. #define AA_QUALITY_HIGH 2
  142. // SMAA pass
  143. #define SMAA_RESOLVE 1
  144. #define SMAA_EDGE_DETECTION 2
  145. #define SMAA_BLENDING_WEIGHT_CALCULATION 3
  146. #define SMAA_NEIGHBORHOOD_BLENDING 4
  147. // SMAA antialiasing method
  148. #define AA_METHOD_SMAA_LOW 1
  149. #define AA_METHOD_SMAA_MEDIUM 2
  150. #define AA_METHOD_SMAA_HIGH 3
  151. #define AA_METHOD_SMAA_ULTRA 4
  152. // REFLECTION_PASS type
  153. #define REFL_PASS_NONE 0
  154. #define REFL_PASS_PLANE 1
  155. #define REFL_PASS_CUBE 2
  156. // SRGB type
  157. #define SRGB_NONE 0
  158. #define SRGB_SIMPLE 1
  159. #define SRGB_PROPER 2
  160. // CAMERA type
  161. #define CAM_TYPE_ORTHO 0
  162. #define CAM_TYPE_PERSP 1
  163. #define M_PI 3.14159265359
  164. #define M_PI_4 0.785398163
  165. #define INV_PI 0.318309886
  166. #define UP_VECTOR vec3(0.0, 0.0, 1.0)
  167. #define RIGHT_VECTOR vec3(1.0, 0.0, 0.0)
  168. #define TOWARD_VECTOR vec3(0.0, -1.0, 0.0)
  169. // NOTE: "too many shader constants" hack for some mobile devices;
  170. // use glsl variables, defines don't work here
  171. #if CONSTANTS_HACK
  172. float _0_0 = 0.0;
  173. float _0_5 = 0.5;
  174. float _1_0 = 1.0;
  175. float _255_0 = 255.0;
  176. #else
  177. #define _0_0 0.0
  178. #define _0_5 0.5
  179. #define _1_0 1.0
  180. #define _255_0 255.0
  181. #endif
  182. #endif