Shaders Compile.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. #include "../Shaders/!Header CPU.h"
  4. namespace EE{
  5. /******************************************************************************/
  6. #define BUMP_MAPPING 1
  7. #define MULTI_MATERIAL 1
  8. #define FORCE_LOG 0
  9. #if WINDOWS // DirectX 9
  10. #define COMPILE_3 0
  11. #endif
  12. #if DX11 // DirectX 10+
  13. #define COMPILE_4 0
  14. #endif
  15. #if GL && !GL_ES // Desktop OpenGL
  16. #define COMPILE_GL 0
  17. #endif
  18. /**
  19. #define MAIN
  20. #define SIMPLE
  21. #define DEFERRED
  22. #define FORWARD // Forward Shaders in OpenGL compile almost an entire day and use ~5 GB memory during compilation
  23. #define BLEND_LIGHT
  24. #define AMBIENT
  25. #define POSITION
  26. #define BLEND
  27. #define SET_COLOR
  28. #define BEHIND
  29. #define OVERLAY
  30. #define EARLY_Z
  31. #define FUR
  32. #define AMBIENT_OCCLUSION
  33. #define VOLUMETRIC_LIGHTS
  34. #define VOLUMETRIC_CLOUDS
  35. #define LAYERED_CLOUDS
  36. #define HDR
  37. #define MOTION_BLUR
  38. #define DEPTH_OF_FIELD
  39. #define WATER
  40. #define WORLD_EDITOR
  41. /******************************************************************************
  42. #define DX10_INPUT_LAYOUT
  43. /******************************************************************************/
  44. // SHADER TECHNIQUE NAMES
  45. /******************************************************************************/
  46. Str8 TechNameSimple (Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int reflect, Int color, Int mtrl_blend, Int heightmap, Int fx, Int per_pixel, Int tess) {return S8+"T"+skin+materials+textures+bump_mode+alpha_test+light_map+reflect+color+mtrl_blend+heightmap+fx+per_pixel+tess;}
  47. Str8 TechNameDeferred (Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int detail, Int macro, Int rflct, Int color, Int mtrl_blend, Int heightmap, Int fx, Int tess) {return S8+"T"+skin+materials+textures+bump_mode+alpha_test+light_map+detail+macro+rflct+color+mtrl_blend+heightmap+fx+tess;}
  48. Str8 TechNameForward (Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int detail, Int rflct, Int color, Int mtrl_blend, Int heightmap, Int fx, Int light_dir, Int light_dir_shd, Int light_dir_shd_num, Int light_point, Int light_point_shd, Int light_sqr, Int light_sqr_shd, Int light_cone, Int light_cone_shd, Int tess) {return S8+"T"+skin+materials+textures+bump_mode+alpha_test+light_map+detail+rflct+color+mtrl_blend+heightmap+fx+light_dir+light_dir_shd+light_dir_shd_num+light_point+light_point_shd+light_sqr+light_sqr_shd+light_cone+light_cone_shd+tess;}
  49. Str8 TechNameBlendLight(Int skin, Int color , Int textures, Int bump_mode, Int alpha_test, Int alpha, Int light_map, Int rflct, Int fx, Int per_pixel, Int shadow_maps) {return S8+"T"+skin+color+textures+bump_mode+alpha_test+alpha+light_map+rflct+fx+per_pixel+shadow_maps;}
  50. Str8 TechNamePosition (Int skin, Int textures, Int test_blend, Int fx, Int tess) {return S8+"T"+skin+textures+test_blend+fx+tess;}
  51. Str8 TechNameBlend (Int skin, Int color, Int rflct, Int textures, Int light_map) {return S8+"T"+skin+color+rflct+textures+light_map;}
  52. Str8 TechNameSetColor (Int skin, Int textures, Int tess) {return S8+"T"+skin+textures+tess;}
  53. Str8 TechNameBehind (Int skin, Int textures) {return S8+"T"+skin+textures;}
  54. Str8 TechNameEarlyZ (Int skin) {return S8+"T"+skin;}
  55. Str8 TechNameAmbient (Int skin, Int alpha_test) {return S8+"T"+skin+alpha_test;}
  56. Str8 TechNameOverlay (Int skin, Int normal) {return S8+"T"+skin+normal;}
  57. Str8 TechNameFurBase (Int skin, Int size, Int diffuse) {return S8+"Base"+skin+size+diffuse;}
  58. Str8 TechNameFurSoft (Int skin, Int size, Int diffuse) {return S8+"Soft"+skin+size+diffuse;}
  59. Str8 TechNameTattoo (Int skin, Int tess ) {return S8+"T"+skin+tess;}
  60. /******************************************************************************/
  61. #if COMPILE_3 || COMPILE_4 || COMPILE_GL
  62. /******************************************************************************/
  63. // SHADER TECHNIQUE DECLARATIONS
  64. /******************************************************************************/
  65. static Str TechSimple(Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int reflect, Int color, Int mtrl_blend, Int heightmap, Int fx, Int per_pixel, Int tess)
  66. {
  67. Str params= S+skin+','+materials+','+textures+','+bump_mode+','+alpha_test+','+light_map+','+reflect+','+color+','+mtrl_blend+','+heightmap+','+fx+','+per_pixel+','+tess,
  68. name =TechNameSimple(skin , materials , textures , bump_mode , alpha_test , light_map , reflect , color , mtrl_blend , heightmap , fx , per_pixel , tess);
  69. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  70. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  71. }
  72. static ShaderGLSL TechSimpleGlsl(Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int reflect, Int color, Int mtrl_blend, Int heightmap, Int fx, Int per_pixel, Int tess)
  73. {
  74. return ShaderGLSL().set("Main", TechNameSimple(skin, materials, textures, bump_mode, alpha_test, light_map, reflect, color, mtrl_blend, heightmap, fx, per_pixel, tess))
  75. .par("skin" , skin )
  76. .par("materials" , materials )
  77. .par("textures" , textures )
  78. .par("bump_mode" , bump_mode )
  79. .par("alpha_test", alpha_test)
  80. .par("light_map" , light_map )
  81. .par("rflct" , reflect )
  82. .par("COLOR" , color )
  83. .par("mtrl_blend", mtrl_blend)
  84. .par("heightmap" , heightmap )
  85. .par("fx" , fx )
  86. .par("per_pixel" , per_pixel )
  87. .par("tesselate" , tess );
  88. }
  89. static Str TechDeferred(Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int detail, Int macro, Int rflct, Int color, Int mtrl_blend, Int heightmap, Int fx, Int tess)
  90. {
  91. Str params= S+skin+','+materials+','+textures+','+bump_mode+','+alpha_test+','+light_map+','+detail+','+macro+','+rflct+','+color+','+mtrl_blend+','+heightmap+','+fx+','+tess,
  92. name =TechNameDeferred(skin , materials , textures , bump_mode , alpha_test , light_map , detail , macro , rflct , color , mtrl_blend , heightmap , fx , tess);
  93. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  94. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  95. }
  96. static Str TechForward(Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int detail, Int rflct, Int color, Int mtrl_blend, Int heightmap, Int fx, Int light_dir, Int light_dir_shd, Int light_dir_shd_num, Int light_point, Int light_point_shd, Int light_sqr, Int light_sqr_shd, Int light_cone, Int light_cone_shd, Int tess)
  97. {
  98. Str params= S+skin+','+materials+','+textures+','+bump_mode+','+alpha_test+','+light_map+','+detail+','+rflct+','+color+','+mtrl_blend+','+heightmap+','+fx+',' +light_dir+','+light_dir_shd+','+light_dir_shd_num+ ','+light_point+','+light_point_shd+ ','+light_sqr+','+light_sqr_shd+ ','+light_cone+','+light_cone_shd+','+tess,
  99. name =TechNameForward(skin , materials , textures , bump_mode , alpha_test , light_map , detail , rflct , color , mtrl_blend , heightmap , fx , light_dir , light_dir_shd , light_dir_shd_num , light_point , light_point_shd , light_sqr , light_sqr_shd , light_cone , light_cone_shd , tess);
  100. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  101. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  102. }
  103. static Str TechForwardLight(Int skin, Int materials, Int textures, Int bump_mode, Int alpha_test, Int light_map, Int detail, Int rflct, Int color, Int mtrl_blend, Int heightmap, Int fx, Int tess, SHADER_MODEL model)
  104. {
  105. Str names;
  106. REPD(shd, 2)
  107. {
  108. if(shd)for(Int maps=2; maps<=6; maps+=2) // 2, 4, 6 maps
  109. names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, true ,shd ,maps, false,false, false,false, false,false, tess);else // light dir with shadow maps
  110. names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, true ,false, 0, false,false, false,false, false,false, tess); // light dir no shadow
  111. names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, false,false, 0, true ,shd , false,false, false,false, tess); // light point
  112. names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, false,false, 0, false,false, true ,shd , false,false, tess); // light sqr
  113. names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, false,false, 0, false,false, false,false, true ,shd , tess); // light cone
  114. } names+=TechForward(skin, materials, textures, bump_mode, alpha_test, light_map, detail, rflct, color, mtrl_blend, heightmap, fx, false,false, 0, false,false, false,false, false,false, tess); // no light
  115. return names;
  116. }
  117. static Str TechPosition(Int skin, Int textures, Int test_blend, Int fx, Int tess)
  118. {
  119. Str params= S+skin+','+textures+','+test_blend+','+fx+','+tess,
  120. name =TechNamePosition(skin , textures , test_blend , fx , tess);
  121. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  122. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  123. }
  124. static Str TechBlend(Int skin, Int color, Int rflct, Int textures, Int light_map)
  125. {
  126. Str params= S+skin+','+color+','+rflct+','+textures+','+light_map,
  127. name =TechNameBlend(skin , color , rflct , textures, light_map);
  128. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  129. }
  130. static ShaderGLSL TechBlendGlsl(Int skin, Int color, Int rflct, Int textures, Int light_map)
  131. {
  132. return ShaderGLSL().set("Main", TechNameBlend(skin, color, rflct, textures, light_map))
  133. .par("skin" , skin )
  134. .par("COLOR" , color )
  135. .par("rflct" , rflct )
  136. .par("textures" , textures )
  137. .par("light_map", light_map);
  138. }
  139. static Str TechBlendLight(Int skin, Int color, Int textures, Int bump_mode, Int alpha_test, Int alpha, Int light_map, Int rflct, Int fx, Int per_pixel, Int shadow_maps)
  140. {
  141. Str params= S+skin+','+color+','+textures+','+bump_mode+','+alpha_test+','+alpha+','+light_map+','+rflct+','+fx+','+per_pixel+','+shadow_maps,
  142. name =TechNameBlendLight(skin , color , textures , bump_mode , alpha_test , alpha , light_map , rflct , fx , per_pixel , shadow_maps);
  143. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  144. }
  145. static ShaderGLSL TechBlendLightGlsl(Int skin, Int color, Int textures, Int bump_mode, Int alpha_test, Int alpha, Int light_map, Int rflct, Int fx, Int per_pixel, Int shadow_maps)
  146. {
  147. return ShaderGLSL().set("Main", TechNameBlendLight(skin, color, textures, bump_mode, alpha_test, alpha, light_map, rflct, fx, per_pixel, shadow_maps))
  148. .par("skin" , skin )
  149. .par("COLOR" , color )
  150. .par("textures" , textures )
  151. .par("bump_mode" , bump_mode )
  152. .par("alpha_test" , alpha_test )
  153. .par("ALPHA" , alpha )
  154. .par("light_map" , light_map )
  155. .par("rflct" , rflct )
  156. .par("fx" , fx )
  157. .par("per_pixel" , per_pixel )
  158. .par("shadow_maps", shadow_maps);
  159. }
  160. static Str TechSetColor(Int skin, Int textures, Int tess)
  161. {
  162. Str params= S+skin+','+textures+','+tess,
  163. name =TechNameSetColor(skin , textures , tess);
  164. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  165. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  166. }
  167. static Str TechBehind(Int skin, Int textures)
  168. {
  169. Str params= S+skin+','+textures,
  170. name =TechNameBehind(skin , textures);
  171. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  172. }
  173. static Str TechEarlyZ(Int skin)
  174. {
  175. Str params= S+skin,
  176. name =TechNameEarlyZ(skin);
  177. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  178. }
  179. static Str TechAmbient(Int skin, Int alpha_test)
  180. {
  181. Str params= S+skin+','+alpha_test,
  182. name =TechNameAmbient(skin , alpha_test);
  183. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  184. }
  185. static Str TechOverlay(Int skin, Int normal)
  186. {
  187. Str params= S+skin+','+normal,
  188. name =TechNameOverlay(skin , normal);
  189. return S+"TECHNIQUE("+name+", VS("+params+"), PS("+params+"));";
  190. }
  191. static Str TechTattoo(Int skin, Int tess)
  192. {
  193. Str params= S+skin+','+tess,
  194. name =TechNameTattoo(skin , tess);
  195. return tess ? S+"TECHNIQUE_TESSELATION("+name+", VS("+params+"), PS("+params+"), HS("+params+"), DS("+params+"));"
  196. : S+"TECHNIQUE ("+name+", VS("+params+"), PS("+params+") );";
  197. }
  198. static Str TechFurBase(Int skin, Int size, Int diffuse)
  199. {
  200. Str params= S+skin+','+size+','+diffuse,
  201. name =TechNameFurBase(skin , size , diffuse);
  202. return S+"TECHNIQUE("+name+", Base_VS("+params+"), Base_PS("+params+"));";
  203. }
  204. static Str TechFurSoft(Int skin, Int size, Int diffuse)
  205. {
  206. Str params= S+skin+','+size+','+diffuse,
  207. name =TechNameFurSoft(skin , size , diffuse);
  208. return S+"TECHNIQUE("+name+", Soft_VS("+params+"), Soft_PS("+params+"));";
  209. }
  210. /******************************************************************************/
  211. // COMPILER
  212. /******************************************************************************/
  213. struct ShaderCompiler
  214. {
  215. Str src, dest;
  216. SHADER_MODEL model;
  217. Memc<ShaderMacro> macros;
  218. Memc<ShaderGLSL > glsl;
  219. void compile()
  220. {
  221. Str messages; Bool ok=ShaderCompileTry(src, dest, model, macros, glsl, &messages);
  222. if(!ok || DEBUG || FORCE_LOG)if(messages.is())LogN(S+"Shader\n\""+src+"\"\nto file\n\""+dest+"\"\n"+messages);
  223. if(!ok)
  224. {
  225. #if !WINDOWS
  226. if(model==SM_3)Exit("Can't compile DX9 Shaders when not using Windows engine version");
  227. #endif
  228. #if !DX11
  229. if(model>=SM_4)Exit("Can't compile DX10+ Shaders when not using DX10+ engine version");
  230. #endif
  231. #if DX9 || DX11
  232. if(model>=SM_GL_ES_2 && model<=SM_GL)Exit("Can't compile OpenGL Shaders when not using OpenGL engine version");
  233. #endif
  234. Exit(S+"Error compiling shader\n\""+src+"\"\nto file\n\""+dest+"\"."+(messages.is() ? S+"\n\nCompilation Messages:\n"+messages : S));
  235. }
  236. }
  237. };
  238. /******************************************************************************/
  239. static Memc<ShaderCompiler> ShaderCompilers;
  240. /******************************************************************************/
  241. static void Add(C Str &src, C Str &dest, SHADER_MODEL model, C MemPtr<ShaderGLSL> &glsl=null)
  242. {
  243. ShaderCompiler &sc=ShaderCompilers.New();
  244. sc.src =src ;
  245. sc.dest =dest ;
  246. sc.model=model;
  247. sc.glsl =glsl ;
  248. }
  249. static void Add(C Str &src, C Str &dest, SHADER_MODEL model, C Str &names, C MemPtr<ShaderGLSL> &glsl=null)
  250. {
  251. ShaderCompiler &sc=ShaderCompilers.New();
  252. sc.src =src ;
  253. sc.dest =dest ;
  254. sc.model=model;
  255. sc.glsl =glsl ;
  256. sc.macros.New().set("CUSTOM_TECHNIQUE", names);
  257. }
  258. /******************************************************************************/
  259. // LISTING ALL SHADER TECHNIQUES
  260. /******************************************************************************/
  261. static void Compile(SHADER_MODEL model)
  262. {
  263. if(!DataPath().is())Exit("Can't compile default shaders - 'DataPath' not specified");
  264. Str src,
  265. src_path=GetPath(GetPath(__FILE__))+"\\Shaders\\", // for example "C:/Esenthel/Engine/Src/Shaders/"
  266. dest_path=DataPath(); // for example "C:/Esenthel/Data/Shader/4/"
  267. switch(model)
  268. {
  269. case SM_UNKNOWN: return;
  270. case SM_GL_ES_2:
  271. case SM_GL_ES_3:
  272. case SM_GL : dest_path+="Shader\\GL\\"; break;
  273. case SM_3 : dest_path+="Shader\\3\\" ; break;
  274. default : dest_path+="Shader\\4\\" ; break;
  275. }
  276. FCreateDirs(dest_path);
  277. // list first those that take the most time to compile
  278. #ifdef FORWARD
  279. {
  280. #if GL && !X64 && COMPILE_GL
  281. #error "Can't compile GL forward shaders on 32-bit because you will run out of memory"
  282. #endif
  283. Str names;
  284. // zero
  285. REPD(skin , 2)
  286. REPD(color, 2)names+=TechForward(skin, 1, 0, SBUMP_ZERO, false, false, false, false, color, false, false, FX_NONE, false,false,0, false,false, false,false, false,false, false);
  287. REPD(tess , (model>=SM_4) ? 2 : 1)
  288. REPD(heightmap, 2)
  289. {
  290. // 1 material, 0-2 textures, flat
  291. REPD(skin , heightmap ? 1 : 2)
  292. REPD(detail, 2)
  293. REPD(rflct , 2)
  294. REPD(color , 2)
  295. {
  296. names+=TechForwardLight(skin, 1, 0, SBUMP_FLAT, false, false, detail, rflct, color, false, heightmap, FX_NONE, tess, model); // 1 material, 0 tex
  297. REPD(alpha_test, heightmap ? 1 : 2)
  298. REPD(light_map , 2)
  299. {
  300. names+=TechForwardLight(skin, 1, 1, SBUMP_FLAT, alpha_test, light_map, detail, rflct, color, false, heightmap, FX_NONE, tess, model); // 1 material, 1 tex
  301. names+=TechForwardLight(skin, 1, 2, SBUMP_FLAT, alpha_test, light_map, detail, rflct, color, false, heightmap, FX_NONE, tess, model); // 1 material, 2 tex
  302. }
  303. }
  304. #if BUMP_MAPPING
  305. // 1 material, 2 tex, normal
  306. REPD(skin , heightmap ? 1 : 2)
  307. REPD(alpha_test, heightmap ? 1 : 2)
  308. REPD(light_map , 2)
  309. REPD(detail , 2)
  310. REPD(rflct , 2)
  311. REPD(color , 2)names+=TechForwardLight(skin, 1, 2, SBUMP_NORMAL, alpha_test, light_map, detail, rflct, color, false, heightmap, FX_NONE, tess, model);
  312. #endif
  313. #if MULTI_MATERIAL
  314. for(Int materials=2; materials<=MAX_MTRLS; materials++)
  315. REPD(color , 2)
  316. REPD(mtrl_blend, 2)
  317. REPD(rflct , 2)
  318. {
  319. // 2-4 materials, 1-2 textures, flat
  320. for(Int textures=1; textures<=2; textures ++)names+=TechForwardLight(false, materials, textures, SBUMP_FLAT, false, false, false, rflct, color, mtrl_blend, heightmap, FX_NONE, tess, model);
  321. #if BUMP_MAPPING
  322. // 2-4 materials, 2 textures, normal
  323. names+=TechForwardLight(false, materials, 2, SBUMP_NORMAL, false, false, false, rflct, color, mtrl_blend, heightmap, FX_NONE, tess, model);
  324. #endif
  325. }
  326. #endif
  327. }
  328. // grass + leaf
  329. for(Int textures=1; textures<=2; textures++)
  330. REPD(color, 2)
  331. {
  332. names+=TechForwardLight(false, 1, textures, SBUMP_FLAT, true, false, false, false, color, false, false, FX_GRASS, false, model); // 1 material, 1-2 tex, grass, flat
  333. names+=TechForwardLight(false, 1, textures, SBUMP_FLAT, true, false, false, false, color, false, false, FX_LEAF , false, model); // 1 material, 1-2 tex, leaf , flat
  334. names+=TechForwardLight(false, 1, textures, SBUMP_FLAT, true, false, false, false, color, false, false, FX_LEAFS, false, model); // 1 material, 1-2 tex, leafs, flat
  335. if(textures==2)
  336. {
  337. names+=TechForwardLight(false, 1, textures, SBUMP_NORMAL, true, false, false, false, color, false, false, FX_GRASS, false, model); // 1 material, 1-2 tex, grass, normal
  338. names+=TechForwardLight(false, 1, textures, SBUMP_NORMAL, true, false, false, false, color, false, false, FX_LEAF , false, model); // 1 material, 1-2 tex, leaf , normal
  339. names+=TechForwardLight(false, 1, textures, SBUMP_NORMAL, true, false, false, false, color, false, false, FX_LEAFS, false, model); // 1 material, 1-2 tex, leafs, normal
  340. }
  341. }
  342. Add(src_path+"Forward.cpp", dest_path+"Forward", model, names);
  343. }
  344. #endif
  345. #ifdef BLEND_LIGHT
  346. {
  347. #if GL && !X64 && COMPILE_GL
  348. #error "Can't compile GL Blend Light shaders on 32-bit because you will run out of memory"
  349. #endif
  350. Str names; Memc<ShaderGLSL> glsl;
  351. REPD(per_pixel , 2)
  352. REPD(shadow_maps, per_pixel ? 7 : 1) // 7=(6+off), 1=off
  353. {
  354. // base
  355. REPD(skin , 2)
  356. REPD(color , 2)
  357. REPD(textures , 3)
  358. REPD(bump_mode , (per_pixel && textures==2) ? 2 : 1)
  359. REPD(alpha_test, textures ? 2 : 1)
  360. REPD(alpha , textures ? 2 : 1)
  361. REPD(light_map , textures ? 2 : 1)
  362. REPD(rflct , 2)
  363. {
  364. names+=(TechBlendLight (skin, color, textures, bump_mode ? SBUMP_NORMAL: SBUMP_FLAT, alpha_test, alpha, light_map, rflct, FX_NONE, per_pixel, shadow_maps));
  365. if(shadow_maps==0 && bump_mode==0)glsl.add(TechBlendLightGlsl(skin, color, textures, bump_mode ? SBUMP_NORMAL: SBUMP_FLAT, alpha_test, alpha, light_map, rflct, FX_NONE, per_pixel, shadow_maps));
  366. }
  367. // grass+leaf
  368. REPD(color , 2)
  369. REPD(textures , 3)
  370. REPD(bump_mode , (per_pixel && textures==2) ? 2 : 1)
  371. REPD(alpha_test, textures ? 2 : 1)
  372. {
  373. names+=(TechBlendLight (false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_GRASS, per_pixel, shadow_maps));
  374. names+=(TechBlendLight (false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_LEAF , per_pixel, shadow_maps));
  375. names+=(TechBlendLight (false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_LEAFS, per_pixel, shadow_maps));
  376. if(shadow_maps==0 && bump_mode==0)glsl.add(TechBlendLightGlsl(false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_GRASS, per_pixel, shadow_maps));
  377. if(shadow_maps==0 && bump_mode==0)glsl.add(TechBlendLightGlsl(false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_LEAF , per_pixel, shadow_maps));
  378. if(shadow_maps==0 && bump_mode==0)glsl.add(TechBlendLightGlsl(false, color, textures, bump_mode ? SBUMP_NORMAL : SBUMP_FLAT, alpha_test, true, false, false, FX_LEAFS, per_pixel, shadow_maps));
  379. }
  380. }
  381. Add(src_path+"Blend Light.cpp", dest_path+"Blend Light", model, names, glsl);
  382. }
  383. #endif
  384. #ifdef DEFERRED
  385. {
  386. Str names;
  387. // zero
  388. REPD(skin , 2)
  389. REPD(color, 2)names+=TechDeferred(skin, 1, 0, SBUMP_ZERO, false, false, false, false, false, color, false, false, FX_NONE, false);
  390. REPD(tess , (model>=SM_4) ? 2 : 1)
  391. REPD(heightmap, 2)
  392. {
  393. // 1 material, 0-2 tex, flat
  394. REPD(skin , heightmap ? 1 : 2)
  395. REPD(detail, 2)
  396. REPD(rflct , 2)
  397. REPD(color , 2)
  398. {
  399. names+=TechDeferred(skin, 1, 0, SBUMP_FLAT, false, false, detail, false, rflct, color, false, heightmap, FX_NONE, tess); // 1 material, 0 tex
  400. REPD(alpha_test, heightmap ? 1 : 2)
  401. REPD(light_map , 2)
  402. {
  403. names+=TechDeferred(skin, 1, 1, SBUMP_FLAT, alpha_test, light_map, detail, false, rflct, color, false, heightmap, FX_NONE, tess); // 1 material, 1 tex
  404. names+=TechDeferred(skin, 1, 2, SBUMP_FLAT, alpha_test, light_map, detail, false, rflct, color, false, heightmap, FX_NONE, tess); // 1 material, 2 tex
  405. }
  406. }
  407. // 1 material, 1-2 tex, flat, macro
  408. REPD(light_map, 2)
  409. REPD(color , 2)
  410. for(Int textures=1; textures<=2; textures++)names+=TechDeferred(false, 1, textures, SBUMP_FLAT, false, light_map, false, true, false, color, false, heightmap, FX_NONE, tess);
  411. #if BUMP_MAPPING
  412. // 1 material, 2 tex, normal + parallax
  413. REPD(skin , heightmap ? 1 : 2)
  414. REPD(alpha_test, heightmap ? 1 : 2)
  415. REPD(light_map , 2)
  416. REPD(detail , 2)
  417. REPD(rflct , 2)
  418. REPD(color , 2)
  419. for(Int bump_mode=SBUMP_NORMAL; bump_mode<=SBUMP_PARALLAX_MAX; bump_mode++)if(bump_mode==SBUMP_NORMAL || bump_mode>=SBUMP_PARALLAX_MIN)
  420. names+=TechDeferred(skin, 1, 2, bump_mode, alpha_test, light_map, detail, false, rflct, color, false, heightmap, FX_NONE, tess);
  421. // 1 material, 1-2 tex, normal, macro
  422. REPD(light_map, 2)
  423. REPD(color , 2)
  424. for(Int textures=1; textures<=2; textures++)names+=TechDeferred(false, 1, textures, SBUMP_NORMAL, false, light_map, false, true, false, color, false, heightmap, FX_NONE, tess);
  425. // 1 material, 2 tex, relief
  426. REPD(skin , heightmap ? 1 : 2)
  427. REPD(alpha_test, heightmap ? 1 : 2)
  428. REPD(light_map , 2)
  429. REPD(detail , 2)
  430. REPD(rflct , 2)
  431. REPD(color , 2)names+=TechDeferred(skin, 1, 2, SBUMP_RELIEF, alpha_test, light_map, detail, false, rflct, color, false, heightmap, FX_NONE, tess);
  432. #endif
  433. #if MULTI_MATERIAL
  434. for(Int materials=2; materials<=MAX_MTRLS; materials++)
  435. REPD(color , 2)
  436. REPD(mtrl_blend, 2)
  437. REPD(rflct , 2)
  438. {
  439. // 2-4 materials, 1-2 tex, flat
  440. REPD(detail, 2)
  441. for(Int textures=1; textures<=2; textures++)names+=TechDeferred(false, materials, textures, SBUMP_FLAT, false, false, detail, false, rflct, color, mtrl_blend, heightmap, FX_NONE, tess);
  442. // 2-4 materials, 1-2 tex, flat, macro
  443. for(Int textures=1; textures<=2; textures++)names+=TechDeferred(false, materials, textures, SBUMP_FLAT, false, false, false, true, rflct, color, mtrl_blend, heightmap, FX_NONE, tess);
  444. #if BUMP_MAPPING
  445. // 2-4 materials, 2 textures, normal + parallax
  446. REPD(detail, 2)
  447. for(Int bump_mode=SBUMP_NORMAL; bump_mode<=SBUMP_PARALLAX_MAX_MULTI; bump_mode++)if(bump_mode==SBUMP_NORMAL || bump_mode>=SBUMP_PARALLAX_MIN)
  448. names+=TechDeferred(false, materials, 2, bump_mode, false, false, detail, false, rflct, color, mtrl_blend, heightmap, FX_NONE, tess);
  449. // 2-4 materials, 2 textures, normal, macro
  450. names+=TechDeferred(false, materials, 2, SBUMP_NORMAL, false, false, false, true, rflct, color, mtrl_blend, heightmap, FX_NONE, tess);
  451. // 2-4 materials, 2 textures, relief
  452. REPD(detail, 2)
  453. names+=TechDeferred(false, materials, 2, SBUMP_RELIEF, false, false, detail, false, rflct, color, mtrl_blend, heightmap, FX_NONE, tess);
  454. #endif
  455. }
  456. #endif
  457. }
  458. // grass + leaf
  459. for(Int textures=1; textures<=2; textures++)
  460. REPD(color, 2)
  461. {
  462. names+=TechDeferred(false, 1, textures, SBUMP_FLAT, true, false, false, false, false, color, false, false, FX_GRASS, false); // 1 material, 1-2 tex, grass, flat
  463. names+=TechDeferred(false, 1, textures, SBUMP_FLAT, true, false, false, false, false, color, false, false, FX_LEAF , false); // 1 material, 1-2 tex, leaf , flat
  464. names+=TechDeferred(false, 1, textures, SBUMP_FLAT, true, false, false, false, false, color, false, false, FX_LEAFS, false); // 1 material, 1-2 tex, leafs, flat
  465. if(textures==2)
  466. {
  467. names+=TechDeferred(false, 1, textures, SBUMP_NORMAL, true, false, false, false, false, color, false, false, FX_GRASS, false); // 1 material, 1-2 tex, grass, normal
  468. names+=TechDeferred(false, 1, textures, SBUMP_NORMAL, true, false, false, false, false, color, false, false, FX_LEAF , false); // 1 material, 1-2 tex, leaf , normal
  469. names+=TechDeferred(false, 1, textures, SBUMP_NORMAL, true, false, false, false, false, color, false, false, FX_LEAFS, false); // 1 material, 1-2 tex, leafs, normal
  470. }
  471. }
  472. Add(src_path+"Deferred.cpp", dest_path+"Deferred", model, names);
  473. }
  474. #endif
  475. #ifdef SIMPLE
  476. {
  477. Str names; Memc<ShaderGLSL> glsl;
  478. REPD(per_pixel, 2)
  479. {
  480. // zero
  481. REPD(skin , 2)
  482. REPD(color, 2)
  483. {
  484. names+=(TechSimple (skin, 1, 0, SBUMP_ZERO, false, false, false, color, false, false, FX_NONE, per_pixel, false));
  485. glsl.add(TechSimpleGlsl(skin, 1, 0, SBUMP_ZERO, false, false, false, color, false, false, FX_NONE, per_pixel, false));
  486. }
  487. REPD(tess , (model>=SM_4) ? 2 : 1)
  488. REPD(heightmap, 2)
  489. {
  490. // 1 material, 0-2 textures
  491. REPD(skin , heightmap ? 1 : 2)
  492. REPD(rflct , 2)
  493. REPD(color , 2)
  494. //REPD(instance, (model>=SM_4 && !skin) ? 2 : 1)
  495. {
  496. names+=(TechSimple (skin, 1, 0, SBUMP_FLAT, false, false, rflct, color, false, heightmap, FX_NONE, per_pixel, tess)); // 1 material, 0 tex
  497. glsl.add(TechSimpleGlsl(skin, 1, 0, SBUMP_FLAT, false, false, rflct, color, false, heightmap, FX_NONE, per_pixel, tess));
  498. REPD(alpha_test, heightmap ? 1 : 2)
  499. REPD(light_map , 2)
  500. {
  501. names+=(TechSimple (skin, 1, 1, SBUMP_FLAT, alpha_test, light_map, rflct, color, false, heightmap, FX_NONE, per_pixel, tess)); // 1 material, 1 tex
  502. names+=(TechSimple (skin, 1, 2, SBUMP_FLAT, alpha_test, light_map, rflct, color, false, heightmap, FX_NONE, per_pixel, tess)); // 1 material, 2 tex
  503. glsl.add(TechSimpleGlsl(skin, 1, 1, SBUMP_FLAT, alpha_test, light_map, rflct, color, false, heightmap, FX_NONE, per_pixel, tess));
  504. glsl.add(TechSimpleGlsl(skin, 1, 2, SBUMP_FLAT, alpha_test, light_map, rflct, color, false, heightmap, FX_NONE, per_pixel, tess));
  505. }
  506. }
  507. #if MULTI_MATERIAL
  508. // 2-4 materials, 1 textures
  509. for(Int materials=2; materials<=MAX_MTRLS; materials++)
  510. REPD(color , 2)
  511. REPD(mtrl_blend, 2)
  512. REPD(rflct , 2)
  513. {
  514. names+=(TechSimple (false, materials, 1, SBUMP_FLAT, false, false, rflct, color, mtrl_blend, heightmap, FX_NONE, per_pixel, tess));
  515. if(!rflct)glsl.add(TechSimpleGlsl(false, materials, 1, SBUMP_FLAT, false, false, rflct, color, mtrl_blend, heightmap, FX_NONE, per_pixel, tess));
  516. }
  517. #endif
  518. }
  519. // grass + leaf
  520. //REPD(instance, (model>=SM_4) ? 2 : 1)
  521. REPD(color, 2)
  522. for(Int textures=1; textures<=2; textures++)
  523. {
  524. names+=(TechSimple (false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_GRASS, per_pixel, false));
  525. names+=(TechSimple (false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_LEAF , per_pixel, false));
  526. names+=(TechSimple (false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_LEAFS, per_pixel, false));
  527. glsl.add(TechSimpleGlsl(false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_GRASS, per_pixel, false));
  528. glsl.add(TechSimpleGlsl(false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_LEAF , per_pixel, false));
  529. glsl.add(TechSimpleGlsl(false, 1, textures, SBUMP_FLAT, true, false, false, color, false, false, FX_LEAFS, per_pixel, false));
  530. }
  531. }
  532. // bone highlight
  533. REPD(skin, 2)names+=TechSimple(skin, 1, 0, SBUMP_FLAT, false, false, false, false, false, false, FX_BONE, true, false); // !! this name must be in sync with other calls in the engine that use FX_BONE !!
  534. Add(src_path+"Simple.cpp", dest_path+"Simple", model, names, glsl);
  535. }
  536. #endif
  537. #ifdef MAIN
  538. Memc<ShaderGLSL> glsl;
  539. // Draw2DTex
  540. REPD(c, 2) // color
  541. glsl.New().set("Draw2DTex", S+"Draw2DTex"+(c?'C':'\0')).par("COLOR", c);
  542. // Draw3DTex
  543. REPD(c , 2) // color
  544. REPD(at, 2) // alpha_test
  545. glsl.New().set("Draw3DTex", S+"Draw3DTex"+(c?"Col":"")+(at?"AT":"")).par("COLOR", c).par("alpha_test", at);
  546. // font
  547. glsl.New().set("Font", "Font");
  548. // blur
  549. REPD(x, 2) // axis
  550. REPD(h, 2) // high
  551. glsl.New().set("Blur", S+"Blur"+(x?'X':'Y')+(h?'H':'\0')).par("axis", x ? '0' : '1').par("high", h);
  552. // bloom downsample
  553. REPD(g, 2) // glow
  554. REPD(c, 2) // clamp
  555. REPD(h, 2) // half
  556. REPD(s, 2) // saturate
  557. glsl.New().set("BloomDS", S+"Bloom"+(g?'G':'\0')+"DS"+(c?'C':'\0')+(h?'H':'\0')+(s?'S':'\0')).par("DoGlow", g).par("DoClamp", c).par("half", h).par("saturate", s);
  558. // bloom
  559. glsl.New().set("Bloom", "Bloom");
  560. // shd blur
  561. glsl.New().set("ShdBlurX", "ShdBlurX2").par("range", 2);
  562. glsl.New().set("ShdBlurY", "ShdBlurY2").par("range", 2);
  563. // particles
  564. REPD(p, 2) // palette
  565. REPD(a, 3) // anim
  566. REPD(m, 2) // motion
  567. glsl.New().set("Particle", S+"ParticleTex"+(p?'P':'\0')+((a==2)?"AA":(a==1)?"A":"")+(m?'M':'\0')).par("palette", p ).par("anim", a ).par("motion_stretch", "1").par("stretch_alpha", m );
  568. glsl.New().set("Particle", S+"Bilb" ).par("palette", "0").par("anim", "0").par("motion_stretch", "0").par("stretch_alpha", "0");
  569. // sky
  570. // Textures Flat
  571. REPD(t, 2) // textures
  572. REPD(c, 2) // clouds
  573. glsl.New().set("Sky", S+"SkyTF"+(t+1)+(c?'C':'\0')).par("per_vertex", "0").par("DENSITY", "0").par("textures", t+1).par("stars", "0").par("clouds", c);
  574. // Atmospheric Flat
  575. REPD(v, 2) // per-vertex
  576. REPD(s, 2) // stars
  577. REPD(c, 2) // clouds
  578. glsl.New().set("Sky", S+"SkyAF"+(v?'V':'\0')+(s?'S':'\0')+(c?'C':'\0')).par("per_vertex", v).par("DENSITY", "0").par("textures", "0").par("stars", s).par("clouds", c);
  579. // AA
  580. #if 0 // disable GLSL versions because neither Mac/Linux succeed in compiling them
  581. glsl.New().set("FXAA" , "FXAA");
  582. glsl.New().set("SMAAEdge" , "SMAAEdgeColor");
  583. glsl.New().set("SMAABlend", "SMAABlend");
  584. glsl.New().set("SMAA" , "SMAA");
  585. #endif
  586. Add(src_path+"Main.cpp", dest_path+"Main", model, glsl);
  587. #endif
  588. #ifdef BLEND
  589. {
  590. Str names; Memc<ShaderGLSL> glsl;
  591. REPD(skin , 2)
  592. REPD(color , 2)
  593. REPD(rflct , 2)
  594. REPD(textures , 3)
  595. REPD(light_map, 2)
  596. {
  597. names+=(TechBlend (skin, color, rflct, textures, light_map));
  598. glsl.add(TechBlendGlsl(skin, color, rflct, textures, light_map));
  599. }
  600. Add(src_path+"Blend.cpp", dest_path+"Blend", model, names, glsl);
  601. }
  602. #endif
  603. #ifdef AMBIENT_OCCLUSION
  604. Add(src_path+"Ambient Occlusion.cpp", dest_path+"Ambient Occlusion", model);
  605. #endif
  606. #ifdef VOLUMETRIC_LIGHTS
  607. Add(src_path+"Volumetric Lights.cpp", dest_path+"Volumetric Lights", model);
  608. #endif
  609. #ifdef VOLUMETRIC_CLOUDS
  610. Add(src_path+"Volumetric Clouds.cpp", dest_path+"Volumetric Clouds", model);
  611. #endif
  612. #ifdef LAYERED_CLOUDS
  613. Add(src_path+"Layered Clouds.cpp", dest_path+"Layered Clouds", model);
  614. #endif
  615. #ifdef HDR
  616. Add(src_path+"Hdr.cpp", dest_path+"Hdr", model);
  617. #endif
  618. #ifdef MOTION_BLUR
  619. Add(src_path+"Motion Blur.cpp", dest_path+"Motion Blur", model);
  620. #endif
  621. #ifdef DEPTH_OF_FIELD
  622. Add(src_path+"Depth of Field.cpp", dest_path+"Depth of Field", model);
  623. #endif
  624. #ifdef WATER
  625. Add(src_path+"Water.cpp", dest_path+"Water", model);
  626. #endif
  627. #ifdef POSITION
  628. {
  629. Str names;
  630. REPD(tess, (model>=SM_4) ? 2 : 1)
  631. {
  632. // base
  633. REPD(skin , 2 )
  634. REPD(textures , 3 )
  635. REPD(test_blend, textures ? 2 : 1)names+=TechPosition(skin, textures, test_blend, FX_NONE, tess);
  636. }
  637. // grass + leafs
  638. for(Int textures=1; textures<=2; textures++)
  639. REPD(test_blend, 2)
  640. {
  641. names+=TechPosition(0, textures, test_blend, FX_GRASS, false);
  642. names+=TechPosition(0, textures, test_blend, FX_LEAF , false);
  643. names+=TechPosition(0, textures, test_blend, FX_LEAFS, false);
  644. }
  645. Add(src_path+"Position.cpp", dest_path+"Position", model, names);
  646. }
  647. #endif
  648. #ifdef SET_COLOR
  649. {
  650. Str names;
  651. // base
  652. REPD(tess , (model>=SM_4) ? 2 : 1)
  653. REPD(skin , 2)
  654. REPD(textures, 3)names+=TechSetColor(skin, textures, tess);
  655. Add(src_path+"Set Color.cpp", dest_path+"Set Color", model, names);
  656. }
  657. #endif
  658. #ifdef BEHIND
  659. {
  660. Str names;
  661. // base
  662. REPD(skin , 2)
  663. REPD(textures, 3)names+=TechBehind(skin, textures);
  664. Add(src_path+"Behind.cpp", dest_path+"Behind", model, names);
  665. }
  666. #endif
  667. #ifdef AMBIENT
  668. {
  669. Str names;
  670. // base
  671. REPD(skin , 2)
  672. REPD(alpha_test, 3)names+=TechAmbient(skin, alpha_test);
  673. Add(src_path+"Ambient.cpp", dest_path+"Ambient", model, names);
  674. }
  675. #endif
  676. #ifdef OVERLAY
  677. {
  678. Str names;
  679. // base
  680. REPD(skin , 2)
  681. REPD(normal, 2)names+=TechOverlay(skin, normal);
  682. Add(src_path+"Overlay.cpp", dest_path+"Overlay", model, names);
  683. }
  684. {
  685. Str names;
  686. // base
  687. REPD(tess, (model>=SM_4) ? 2 : 1)
  688. REPD(skin, 2)names+=TechTattoo(skin, tess);
  689. Add(src_path+"Tattoo.cpp", dest_path+"Tattoo", model, names);
  690. }
  691. #endif
  692. #ifdef EARLY_Z
  693. {
  694. Str names;
  695. // base
  696. REPD(skin, 2)names+=TechEarlyZ(skin);
  697. Add(src_path+"Early Z.cpp", dest_path+"Early Z", model, names);
  698. }
  699. #endif
  700. #ifdef FUR
  701. {
  702. Str names;
  703. // base
  704. REPD(skin , 2)
  705. REPD(size , 2)
  706. REPD(diffuse, 2)names+=TechFurBase(skin, size, diffuse);
  707. // soft
  708. REPD(skin , 2)
  709. REPD(size , 2)
  710. REPD(diffuse, 2)names+=TechFurSoft(skin, size, diffuse);
  711. Add(src_path+"Fur.cpp", dest_path+"Fur", model, names);
  712. }
  713. #endif
  714. #ifdef WORLD_EDITOR
  715. Add(src_path+"World Editor.cpp", dest_path+"World Editor", model);
  716. #endif
  717. #ifdef DX10_INPUT_LAYOUT
  718. Add(src_path+"DX10+ Input Layout.cpp", S, model);
  719. #endif
  720. }
  721. /******************************************************************************/
  722. static void ThreadCompile(ShaderCompiler &shader_compiler, Ptr user, Int thread_index)
  723. {
  724. ThreadMayUseGPUData();
  725. shader_compiler.compile();
  726. }
  727. /******************************************************************************/
  728. #endif // COMPILE
  729. /******************************************************************************/
  730. void MainShaderClass::compile()
  731. {
  732. #if COMPILE_3 || COMPILE_4 || COMPILE_GL
  733. App.stayAwake(AWAKE_SYSTEM);
  734. #if COMPILE_GL
  735. Compile(SM_GL);
  736. #endif
  737. #if COMPILE_3
  738. Compile(SM_3);
  739. #endif
  740. #if COMPILE_4
  741. Compile(SM_4);
  742. #endif
  743. ProcPriority(-1); // compiling shaders may slow down entire CPU, so make this process have smaller priority
  744. Dbl t=Time.curTime();
  745. MultiThreadedCall(ShaderCompilers, ThreadCompile);
  746. LogN(S+"Shaders compiled in: "+Flt(Time.curTime()-t)+'s');
  747. App.stayAwake(AWAKE_OFF);
  748. #endif
  749. }
  750. /******************************************************************************/
  751. }
  752. /******************************************************************************/