blender_anki_additions.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
  2. index 6cd725494b3..6ce61b8c7d6 100755
  3. --- a/build_files/build_environment/install_deps.sh
  4. +++ b/build_files/build_environment/install_deps.sh
  5. @@ -340,7 +340,7 @@ LLVM_FORCE_REBUILD=false
  6. LLVM_SKIP=false
  7. # OSL needs to be compiled for now!
  8. -OSL_VERSION="1.7.5"
  9. +OSL_VERSION="1.8.10"
  10. OSL_VERSION_MIN=$OSL_VERSION
  11. OSL_FORCE_BUILD=false
  12. OSL_FORCE_REBUILD=false
  13. diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp
  14. index d33ce725e58..bf36943b324 100644
  15. --- a/source/blender/collada/EffectExporter.cpp
  16. +++ b/source/blender/collada/EffectExporter.cpp
  17. @@ -46,7 +46,9 @@ extern "C" {
  18. #include "BKE_customdata.h"
  19. #include "BKE_mesh.h"
  20. #include "BKE_material.h"
  21. + #include "BKE_idprop.h"
  22. }
  23. +#include <sstream>
  24. EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryEffects(sw), export_settings(export_settings) {
  25. }
  26. @@ -196,6 +198,26 @@ void EffectsExporter::writeTextures(
  27. texture.setChildElementName("bump");
  28. ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  29. }
  30. + // AnKi: Add some textures
  31. + if (t->mapto & MAP_HAR) {
  32. + COLLADASW::Texture texture(key);
  33. + texture.setTexcoord(uvname);
  34. + texture.setSampler(*sampler);
  35. + texture.setProfileName("blender");
  36. + texture.setChildElementName("roughness_tex");
  37. + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  38. + }
  39. + if (t->mapto & MAP_DISPLACE) {
  40. + COLLADASW::Texture texture(key);
  41. + texture.setTexcoord(uvname);
  42. + texture.setSampler(*sampler);
  43. + texture.setProfileName("blender");
  44. + texture.setChildElementName("height");
  45. + ep.addExtraTechniqueColorOrTexture(COLLADASW::ColorOrTexture(texture));
  46. + }
  47. + if ((t->mapto & MAP_COLMIR) || (t->mapto & MAP_RAYMIRR)) {
  48. + ep.setReflective(createTexture(ima, uvname, sampler));
  49. + }
  50. }
  51. void EffectsExporter::operator()(Material *ma, Object *ob)
  52. @@ -358,6 +380,68 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
  53. writeTextures(ep, key, sampler, t, ima, uvname);
  54. }
  55. + // AnKi: Export extra properties
  56. + static const char *property_names[] = {
  57. + "diffuse_texture_detail",
  58. + "normal_texture_detail",
  59. + "material_override",
  60. + "metallic",
  61. + "roughness",
  62. + "subsurface",
  63. + NULL};
  64. + IDProperty *rprop = ma->id.properties;
  65. + while (rprop) {
  66. + if (rprop->type == IDP_GROUP) {
  67. + // Search properties
  68. + const char **iter = property_names;
  69. + while (*iter != NULL) {
  70. + const char *prop_name = *iter;
  71. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  72. +
  73. + if (prop) {
  74. + const char *value = NULL;
  75. + float valuef = 0.0;
  76. + bool ok = true;
  77. +
  78. + if(prop->type == IDP_STRING) {
  79. + value = IDP_String(prop);
  80. + }
  81. + else if (prop->type == IDP_FLOAT) {
  82. + valuef = IDP_Float(prop);
  83. + }
  84. + else if (prop->type == IDP_DOUBLE) {
  85. + valuef = IDP_Double(prop);
  86. + }
  87. + else if (prop->type == IDP_INT) {
  88. + valuef = IDP_Int(prop);
  89. + }
  90. + else {
  91. + printf("Property value type cannot be handled\n");
  92. + ok = false;
  93. + }
  94. +
  95. + if (ok)
  96. + {
  97. + if (value) {
  98. + printf("Found %s property \"%s\"\n", prop_name, value);
  99. + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value));
  100. + }
  101. + else {
  102. + printf("Found %s property %f\n", prop_name, valuef);
  103. + std::stringstream ss;
  104. + ss << valuef;
  105. + ep.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(ss.str()));
  106. + }
  107. + }
  108. + } // end found
  109. +
  110. + ++iter;
  111. + } // end iterate property_names
  112. + } // end group
  113. +
  114. + rprop = rprop->next;
  115. + }
  116. +
  117. // performs the actual writing
  118. ep.addProfileElements();
  119. bool twoSided = false;
  120. diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
  121. index 4b693332715..04fb3ee71f3 100644
  122. --- a/source/blender/collada/GeometryExporter.cpp
  123. +++ b/source/blender/collada/GeometryExporter.cpp
  124. @@ -47,6 +47,7 @@ extern "C" {
  125. #include "BKE_customdata.h"
  126. #include "BKE_material.h"
  127. #include "BKE_mesh.h"
  128. + #include "BKE_idprop.h"
  129. }
  130. #include "collada_internal.h"
  131. @@ -154,12 +155,135 @@ void GeometryExporter::operator()(Object *ob)
  132. }
  133. }
  134. + // AnKi: Export mesh properties
  135. + {
  136. + static const char *property_names[] = {
  137. + "particles",
  138. + "collision",
  139. + "sector",
  140. + "portal",
  141. + "lod1",
  142. + "skip",
  143. + "reflection_probe",
  144. + "gi_probe",
  145. + "gi_probe_fade_distance",
  146. + "gi_probe_cell_size",
  147. + "reflection_proxy",
  148. + "occluder",
  149. + "collision_mesh",
  150. + "decal_diffuse_atlas",
  151. + "decal_diffuse_sub_texture",
  152. + "decal_diffuse_factor",
  153. + "decal_normal_roughness_atlas",
  154. + "decal_normal_roughness_sub_texture",
  155. + "decal_normal_roughness_factor",
  156. + NULL};
  157. +
  158. + ID *mesh_id = (ID*)ob->data;
  159. + IDProperty *rprop = mesh_id->properties;
  160. + while (rprop) {
  161. + if (rprop->type == IDP_GROUP) {
  162. + const char **iter = property_names;
  163. + while (*iter != NULL) {
  164. + const char *prop_name = *iter;
  165. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  166. +
  167. + if (prop) {
  168. + const char *value = NULL;
  169. + float valuef = 0.0;
  170. + bool ok = true;
  171. +
  172. + if(prop->type == IDP_STRING) {
  173. + value = IDP_String(prop);
  174. + }
  175. + else if (prop->type == IDP_FLOAT) {
  176. + valuef = IDP_Float(prop);
  177. + }
  178. + else if (prop->type == IDP_DOUBLE) {
  179. + valuef = IDP_Double(prop);
  180. + }
  181. + else if (prop->type == IDP_INT) {
  182. + valuef = IDP_Int(prop);
  183. + }
  184. + else {
  185. + printf("Property value type cannot be handled\n");
  186. + ok = false;
  187. + }
  188. +
  189. + if (ok) {
  190. + if (value) {
  191. + printf("Found %s property \"%s\"\n", prop_name, value);
  192. +
  193. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  194. + mSW->appendTextBlock(str.c_str());
  195. + }
  196. + else {
  197. + printf("Found %s property \"%f\"\n", prop_name, valuef);
  198. +
  199. + std::stringstream ss;
  200. + ss << "<" << prop_name << ">" << valuef << "</" << prop_name << ">";
  201. + mSW->appendTextBlock(ss.str().c_str());
  202. + }
  203. + }
  204. + } // end found
  205. +
  206. + ++iter;
  207. + } // end iterate property_names
  208. + } // end group
  209. +
  210. + rprop = rprop->next;
  211. + }
  212. + }
  213. +
  214. closeMesh();
  215. if (me->flag & ME_TWOSIDED) {
  216. mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
  217. }
  218. + // AnKi: Export object properties
  219. + {
  220. + static const char *property_names[] = {
  221. + "add some",
  222. + NULL};
  223. + IDProperty *rprop = ob->id.properties;
  224. + while (rprop) {
  225. + if (rprop->type == IDP_GROUP) {
  226. + // Search properties
  227. + const char **iter = property_names;
  228. + while (*iter != NULL) {
  229. + const char *prop_name = *iter;
  230. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  231. +
  232. + if (prop) {
  233. + const char *value = NULL;
  234. +
  235. + if(prop->type == IDP_STRING) {
  236. + value = IDP_String(prop);
  237. + }
  238. + else {
  239. + printf("Property's value is not string\n");
  240. + }
  241. +
  242. + if (value) {
  243. + printf("Found %s property \"%s\"\n", prop_name, value);
  244. +
  245. + std::string str = std::string("<") + prop_name + ">" + value + "</" + prop_name + ">";
  246. + mSW->appendTextBlock(str.c_str());
  247. + }
  248. + else {
  249. + printf("Value error in %s property\n", prop_name);
  250. + }
  251. + } // end found
  252. +
  253. + ++iter;
  254. + } // end iterate property_names
  255. + } // end group
  256. +
  257. + rprop = rprop->next;
  258. + }
  259. + }
  260. +
  261. closeGeometry();
  262. if (this->export_settings->include_shapekeys) {
  263. diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp
  264. index 02c5438ec47..6db17d8d082 100644
  265. --- a/source/blender/collada/LightExporter.cpp
  266. +++ b/source/blender/collada/LightExporter.cpp
  267. @@ -31,6 +31,9 @@
  268. #include "COLLADASWLight.h"
  269. #include "BLI_math.h"
  270. +extern "C" {
  271. +#include "BKE_idprop.h"
  272. +}
  273. #include "LightExporter.h"
  274. #include "collada_internal.h"
  275. @@ -107,6 +110,7 @@ void LightsExporter::operator()(Object *ob)
  276. cla.setLinearAttenuation(linatt);
  277. cla.setQuadraticAttenuation(quadatt);
  278. exportBlenderProfile(cla, la);
  279. + cla.addExtraTechniqueParameter("FCOLLADA", "outer_cone", RAD2DEGF(la->spotsize)); // AnKi: Add cone angle
  280. addLight(cla);
  281. }
  282. // lamp
  283. @@ -191,5 +195,48 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
  284. cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure);
  285. cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace);
  286. + // AnKi: Export properties
  287. + static const char *property_names[] = {
  288. + "lens_flare",
  289. + "lens_flare_first_sprite_size",
  290. + "lens_flare_color",
  291. + "specular_color",
  292. + "shadow",
  293. + "light_event_intensity",
  294. + "light_event_frequency",
  295. + NULL};
  296. + IDProperty *rprop = la->id.properties;
  297. + while (rprop) {
  298. + if (rprop->type == IDP_GROUP) {
  299. + // Search properties
  300. + const char **iter = property_names;
  301. + while (*iter != NULL) {
  302. + const char *prop_name = *iter;
  303. + IDProperty *prop = IDP_GetPropertyFromGroup(rprop, prop_name);
  304. +
  305. + if (prop) {
  306. + const char *value = NULL;
  307. +
  308. + if(prop->type == IDP_STRING) {
  309. + value = IDP_String(prop);
  310. + }
  311. +
  312. + if (value) {
  313. + printf("Found %s property \"%s\"\n", prop_name, value);
  314. +
  315. + cla.addExtraTechniqueParameter("blender", prop_name, COLLADASW::String(value));
  316. + }
  317. + else {
  318. + printf("Value error in %s property\n", prop_name);
  319. + }
  320. + } // end found
  321. +
  322. + ++iter;
  323. + } // end iterate property_names
  324. + } // end group
  325. +
  326. + rprop = rprop->next;
  327. + }
  328. +
  329. return true;
  330. }
  331. diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
  332. index 4e08548449f..4eb2580dd6b 100644
  333. --- a/source/blender/collada/SceneExporter.cpp
  334. +++ b/source/blender/collada/SceneExporter.cpp
  335. @@ -28,6 +28,7 @@ extern "C" {
  336. #include "BLI_utildefines.h"
  337. #include "BKE_object.h"
  338. #include "BLI_listbase.h"
  339. + #include "BKE_group.h"
  340. }
  341. #include "SceneExporter.h"
  342. @@ -232,6 +233,14 @@ void SceneExporter::writeNodes(bContext *C, Object *ob, Scene *sce)
  343. }
  344. }
  345. + // AnKi: Export group
  346. + Group *group = BKE_group_object_find(NULL, ob);
  347. + if (group) {
  348. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String(group->id.name));
  349. + } else {
  350. + colladaNode.addExtraTechniqueParameter("blender", "group", COLLADASW::String("none"));
  351. + }
  352. +
  353. for (std::list<Object *>::iterator i = child_objects.begin(); i != child_objects.end(); ++i) {
  354. if (bc_is_marked(*i)) {
  355. bc_remove_mark(*i);