com.warwlock.mtree 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.github/workflows/npm.yml +19 -0
  2. package/CHANGELOG.md +17 -0
  3. package/CHANGELOG.md.meta +7 -0
  4. package/Documentation~/Documentation.md +3 -0
  5. package/Editor/BranchEditor.cs +545 -0
  6. package/Editor/BranchEditor.cs.meta +16 -0
  7. package/Editor/EditorCallbacks.cs +69 -0
  8. package/Editor/EditorCallbacks.cs.meta +11 -0
  9. package/Editor/MTree.Editor.asmdef +18 -0
  10. package/Editor/MTree.Editor.asmdef.meta +7 -0
  11. package/Editor/MenuItem.cs +31 -0
  12. package/Editor/MenuItem.cs.meta +11 -0
  13. package/Editor/MtreeBezierInspector.cs +161 -0
  14. package/Editor/MtreeBezierInspector.cs.meta +11 -0
  15. package/Editor/MtreeEditor.cs +434 -0
  16. package/Editor/MtreeEditor.cs.meta +11 -0
  17. package/Editor/TemplateInspector.cs +66 -0
  18. package/Editor/TemplateInspector.cs.meta +12 -0
  19. package/Editor/ValuesEditor.cs +18 -0
  20. package/Editor/ValuesEditor.cs.meta +11 -0
  21. package/Editor/VertexColorAdjustmentEditor.cs +169 -0
  22. package/Editor/VertexColorAdjustmentEditor.cs.meta +11 -0
  23. package/Editor.meta +8 -0
  24. package/LICENSE +21 -0
  25. package/LICENSE.meta +7 -0
  26. package/README.md +68 -0
  27. package/README.md.meta +7 -0
  28. package/Resources/Mtree/MtreeBillboardCamera.prefab +204 -0
  29. package/Resources/Mtree/MtreeBillboardCamera.prefab.meta +8 -0
  30. package/Resources/Mtree/Sprites/DeleteCrossSprite.png +0 -0
  31. package/Resources/Mtree/Sprites/DeleteCrossSprite.png.meta +116 -0
  32. package/Resources/Mtree/Sprites/TreeFunctionSprite.png +0 -0
  33. package/Resources/Mtree/Sprites/TreeFunctionSprite.png.meta +116 -0
  34. package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd +0 -0
  35. package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd.meta +116 -0
  36. package/Resources/Mtree/Sprites.meta +8 -0
  37. package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab +104 -0
  38. package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab.meta +7 -0
  39. package/Resources/Mtree/Vertex Color Editor.meta +8 -0
  40. package/Resources/Mtree/branches.fbx +0 -0
  41. package/Resources/Mtree/branches.fbx.meta +137 -0
  42. package/Resources/Mtree.meta +8 -0
  43. package/Resources.meta +8 -0
  44. package/Runtime/AO/DensityAO.cs +203 -0
  45. package/Runtime/AO/DensityAO.cs.meta +11 -0
  46. package/Runtime/AO/KDTree.cs +169 -0
  47. package/Runtime/AO/KDTree.cs.meta +11 -0
  48. package/Runtime/AO/WeightedRandom.cs +74 -0
  49. package/Runtime/AO/WeightedRandom.cs.meta +11 -0
  50. package/Runtime/AO.meta +8 -0
  51. package/Runtime/Bezier/Bezier.cs +69 -0
  52. package/Runtime/Bezier/Bezier.cs.meta +11 -0
  53. package/Runtime/Bezier/MtreeBezier.cs +185 -0
  54. package/Runtime/Bezier/MtreeBezier.cs.meta +11 -0
  55. package/Runtime/Bezier.meta +8 -0
  56. package/Runtime/ExampleSceneManager.cs +165 -0
  57. package/Runtime/ExampleSceneManager.cs.meta +11 -0
  58. package/Runtime/LODValues.cs +44 -0
  59. package/Runtime/LODValues.cs.meta +11 -0
  60. package/Runtime/LeafPoint.cs +135 -0
  61. package/Runtime/LeafPoint.cs.meta +11 -0
  62. package/Runtime/MTree.Runtime.asmdef +3 -0
  63. package/Runtime/MTree.Runtime.asmdef.meta +7 -0
  64. package/Runtime/MTree.cs +569 -0
  65. package/Runtime/MTree.cs.meta +11 -0
  66. package/Runtime/MtreeComponent.cs +482 -0
  67. package/Runtime/MtreeComponent.cs.meta +11 -0
  68. package/Runtime/MtreeVariables.cs +11 -0
  69. package/Runtime/MtreeVariables.cs.meta +11 -0
  70. package/Runtime/MtreeWind.cs +94 -0
  71. package/Runtime/MtreeWind.cs.meta +11 -0
  72. package/Runtime/Node.cs +331 -0
  73. package/Runtime/Node.cs.meta +11 -0
  74. package/Runtime/SimplexNoise.cs +166 -0
  75. package/Runtime/SimplexNoise.cs.meta +11 -0
  76. package/Runtime/Splines.cs +379 -0
  77. package/Runtime/Splines.cs.meta +11 -0
  78. package/Runtime/TreeBilboard.cs +290 -0
  79. package/Runtime/TreeBilboard.cs.meta +11 -0
  80. package/Runtime/TreeFunctions/BranchFunction.cs +92 -0
  81. package/Runtime/TreeFunctions/BranchFunction.cs.meta +11 -0
  82. package/Runtime/TreeFunctions/GrowFunction.cs +81 -0
  83. package/Runtime/TreeFunctions/GrowFunction.cs.meta +11 -0
  84. package/Runtime/TreeFunctions/LeafFunction.cs +111 -0
  85. package/Runtime/TreeFunctions/LeafFunction.cs.meta +11 -0
  86. package/Runtime/TreeFunctions/RootsFunction.cs +77 -0
  87. package/Runtime/TreeFunctions/RootsFunction.cs.meta +11 -0
  88. package/Runtime/TreeFunctions/SplitFunction.cs +50 -0
  89. package/Runtime/TreeFunctions/SplitFunction.cs.meta +11 -0
  90. package/Runtime/TreeFunctions/TreeFunctionAsset.cs +105 -0
  91. package/Runtime/TreeFunctions/TreeFunctionAsset.cs.meta +11 -0
  92. package/Runtime/TreeFunctions/TrunkFunction.cs +88 -0
  93. package/Runtime/TreeFunctions/TrunkFunction.cs.meta +11 -0
  94. package/Runtime/TreeFunctions.meta +8 -0
  95. package/Runtime/TreePoint.cs +27 -0
  96. package/Runtime/TreePoint.cs.meta +11 -0
  97. package/Runtime/TreeTemplate.cs +50 -0
  98. package/Runtime/TreeTemplate.cs.meta +12 -0
  99. package/Runtime/Utils.cs +268 -0
  100. package/Runtime/Utils.cs.meta +11 -0
  101. package/Runtime/VSProIntegration.cs +132 -0
  102. package/Runtime/VSProIntegration.cs.meta +11 -0
  103. package/Runtime.meta +8 -0
  104. package/Samples~/ExampleTemplates/Examples/Birch.asset +364 -0
  105. package/Samples~/ExampleTemplates/Examples/Birch.asset.meta +8 -0
  106. package/Samples~/ExampleTemplates/Examples/Bush.asset +385 -0
  107. package/Samples~/ExampleTemplates/Examples/Bush.asset.meta +8 -0
  108. package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset +482 -0
  109. package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset.meta +8 -0
  110. package/Samples~/ExampleTemplates/Examples/FantasyTree.asset +406 -0
  111. package/Samples~/ExampleTemplates/Examples/FantasyTree.asset.meta +8 -0
  112. package/Samples~/ExampleTemplates/Examples/Fern.asset +291 -0
  113. package/Samples~/ExampleTemplates/Examples/Fern.asset.meta +8 -0
  114. package/Samples~/ExampleTemplates/Examples/High Poly.asset +300 -0
  115. package/Samples~/ExampleTemplates/Examples/High Poly.asset.meta +8 -0
  116. package/Samples~/ExampleTemplates/Examples/LightingData.asset +0 -0
  117. package/Samples~/ExampleTemplates/Examples/LightingData.asset.meta +8 -0
  118. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat +196 -0
  119. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat.meta +8 -0
  120. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat +196 -0
  121. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat.meta +8 -0
  122. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat +181 -0
  123. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat.meta +8 -0
  124. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat +201 -0
  125. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat.meta +8 -0
  126. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat +208 -0
  127. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat.meta +8 -0
  128. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat +180 -0
  129. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat.meta +8 -0
  130. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat +206 -0
  131. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat.meta +8 -0
  132. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat +206 -0
  133. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat.meta +8 -0
  134. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat +172 -0
  135. package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat.meta +8 -0
  136. package/Samples~/ExampleTemplates/Examples/Materials/Bark.meta +8 -0
  137. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat +392 -0
  138. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat.meta +8 -0
  139. package/Samples~/ExampleTemplates/Examples/Materials/Example Scene.meta +8 -0
  140. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat +202 -0
  141. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat.meta +8 -0
  142. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat +265 -0
  143. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat.meta +8 -0
  144. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat +267 -0
  145. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat.meta +8 -0
  146. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat +232 -0
  147. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat.meta +8 -0
  148. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat +250 -0
  149. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat.meta +8 -0
  150. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat +247 -0
  151. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat.meta +8 -0
  152. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat +223 -0
  153. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat.meta +8 -0
  154. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat +262 -0
  155. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat.meta +8 -0
  156. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat +281 -0
  157. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat.meta +8 -0
  158. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat +267 -0
  159. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat.meta +8 -0
  160. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat +236 -0
  161. package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat.meta +8 -0
  162. package/Samples~/ExampleTemplates/Examples/Materials/Leafs.meta +8 -0
  163. package/Samples~/ExampleTemplates/Examples/Materials.meta +8 -0
  164. package/Samples~/ExampleTemplates/Examples/Oak.asset +364 -0
  165. package/Samples~/ExampleTemplates/Examples/Oak.asset.meta +8 -0
  166. package/Samples~/ExampleTemplates/Examples/Old Oak.asset +364 -0
  167. package/Samples~/ExampleTemplates/Examples/Old Oak.asset.meta +8 -0
  168. package/Samples~/ExampleTemplates/Examples/Palm.asset +500 -0
  169. package/Samples~/ExampleTemplates/Examples/Palm.asset.meta +8 -0
  170. package/Samples~/ExampleTemplates/Examples/Pine 2.asset +387 -0
  171. package/Samples~/ExampleTemplates/Examples/Pine 2.asset.meta +8 -0
  172. package/Samples~/ExampleTemplates/Examples/Pine.asset +405 -0
  173. package/Samples~/ExampleTemplates/Examples/Pine.asset.meta +8 -0
  174. package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset +478 -0
  175. package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset.meta +8 -0
  176. package/Samples~/ExampleTemplates/Examples/Poplar.asset +309 -0
  177. package/Samples~/ExampleTemplates/Examples/Poplar.asset.meta +8 -0
  178. package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr +0 -0
  179. package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr.meta +117 -0
  180. package/Samples~/ExampleTemplates/Examples/Small Pine.asset +273 -0
  181. package/Samples~/ExampleTemplates/Examples/Small Pine.asset.meta +8 -0
  182. package/Samples~/ExampleTemplates/Examples/Small Tree.asset +364 -0
  183. package/Samples~/ExampleTemplates/Examples/Small Tree.asset.meta +8 -0
  184. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png +0 -0
  185. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png.meta +74 -0
  186. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png +0 -0
  187. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png.meta +96 -0
  188. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png +0 -0
  189. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png.meta +116 -0
  190. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png +0 -0
  191. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png.meta +116 -0
  192. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png +0 -0
  193. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png.meta +132 -0
  194. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png +0 -0
  195. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png.meta +116 -0
  196. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png +0 -0
  197. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png.meta +132 -0
  198. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png +0 -0
  199. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png.meta +132 -0
  200. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png +0 -0
  201. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png.meta +116 -0
  202. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png +0 -0
  203. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png.meta +132 -0
  204. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png +0 -0
  205. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png.meta +116 -0
  206. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png +0 -0
  207. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png.meta +74 -0
  208. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png +0 -0
  209. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png.meta +96 -0
  210. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png +0 -0
  211. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png.meta +74 -0
  212. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp +0 -0
  213. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp.meta +96 -0
  214. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png +0 -0
  215. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png.meta +74 -0
  216. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png +0 -0
  217. package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png.meta +96 -0
  218. package/Samples~/ExampleTemplates/Examples/Textures/Bark.meta +8 -0
  219. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png +0 -0
  220. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png.meta +96 -0
  221. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png +0 -0
  222. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png.meta +96 -0
  223. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png +0 -0
  224. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png.meta +99 -0
  225. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png +0 -0
  226. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png.meta +96 -0
  227. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png +0 -0
  228. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png.meta +99 -0
  229. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png +0 -0
  230. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png.meta +96 -0
  231. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png +0 -0
  232. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png.meta +88 -0
  233. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png +0 -0
  234. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png.meta +96 -0
  235. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png +0 -0
  236. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png.meta +96 -0
  237. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png +0 -0
  238. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png.meta +96 -0
  239. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png +0 -0
  240. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png.meta +96 -0
  241. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png +0 -0
  242. package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png.meta +96 -0
  243. package/Samples~/ExampleTemplates/Examples/Textures/Branch.meta +8 -0
  244. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd +0 -0
  245. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd.meta +76 -0
  246. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png +0 -0
  247. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png.meta +76 -0
  248. package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp.meta +8 -0
  249. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png +0 -0
  250. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png.meta +99 -0
  251. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png +0 -0
  252. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png.meta +88 -0
  253. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png +0 -0
  254. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png.meta +88 -0
  255. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png +0 -0
  256. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png.meta +88 -0
  257. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png +0 -0
  258. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png.meta +99 -0
  259. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png +0 -0
  260. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png.meta +88 -0
  261. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png +0 -0
  262. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png.meta +96 -0
  263. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png +0 -0
  264. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png.meta +96 -0
  265. package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs.meta +8 -0
  266. package/Samples~/ExampleTemplates/Examples/Textures.meta +8 -0
  267. package/Samples~/ExampleTemplates/Examples/Willow.asset +364 -0
  268. package/Samples~/ExampleTemplates/Examples/Willow.asset.meta +8 -0
  269. package/Samples~/ExampleTemplates/Examples.meta +8 -0
  270. package/Samples~/ExampleTemplates/Examples.unity +12660 -0
  271. package/Samples~/ExampleTemplates/Examples.unity.meta +7 -0
  272. package/Samples~/ExampleTemplates.meta +8 -0
  273. package/Shaders/BarkShader.shadergraph +17215 -0
  274. package/Shaders/BarkShader.shadergraph.meta +10 -0
  275. package/Shaders/Editor/BarkEditor.cs +100 -0
  276. package/Shaders/Editor/BarkEditor.cs.meta +11 -0
  277. package/Shaders/Editor/LeafEditor.cs +173 -0
  278. package/Shaders/Editor/LeafEditor.cs.meta +11 -0
  279. package/Shaders/Editor.meta +8 -0
  280. package/Shaders/LeafShader.shadergraph +34803 -0
  281. package/Shaders/LeafShader.shadergraph.meta +10 -0
  282. package/Shaders/MTree.Shaders.asmdef +3 -0
  283. package/Shaders/MTree.Shaders.asmdef.meta +7 -0
  284. package/Shaders/leafFunctions.hlsl +201 -0
  285. package/Shaders/leafFunctions.hlsl.meta +7 -0
  286. package/Shaders/vertexFunc.hlsl +55 -0
  287. package/Shaders/vertexFunc.hlsl.meta +7 -0
  288. package/Shaders.meta +8 -0
  289. package/package.json +36 -0
  290. package/package.json.meta +7 -0
@@ -0,0 +1,203 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using System.Threading;
5
+
6
+ namespace Mtree
7
+ {
8
+ public static class DensityAO
9
+ {
10
+ private static void BakeAo(Color[] colors, Vector3[] verts, Vector3[] normals, int[] triangles, Matrix4x4 transform, float resolution, float distance,string TreeName)
11
+ {
12
+ float[] weights = new float[triangles.Length / 3];
13
+ float totalArea = 0f;
14
+ for (int i = 0; i < triangles.Length; i+=3)
15
+ {
16
+ weights[i/3] = GetTriangleArea(verts[triangles[i]], verts[triangles[i + 1]], verts[triangles[i + 2]]);
17
+ totalArea += weights[i / 3];
18
+ }
19
+ for (int i = 0; i < weights.Length; i++)
20
+ weights[i] /= totalArea;
21
+
22
+ List<Vector3> points = new List<Vector3>();
23
+ WeightedRandom randomGenerator = new WeightedRandom(weights);
24
+ int sampleCount = (int)(totalArea / (resolution * resolution));
25
+ System.Random random = new System.Random();
26
+ for (int i = 0; i < sampleCount; i++)
27
+ {
28
+ int triangleIndex = randomGenerator.GetRandomIndex(random);
29
+ Vector3 point = SamplePointInTriangle(verts[triangles[triangleIndex * 3]], verts[triangles[triangleIndex * 3 + 1]], verts[triangles[triangleIndex * 3 + 2]], random);
30
+ point = transform.MultiplyPoint3x4(point);
31
+ points.Add(point);
32
+ }
33
+ KDTree tree = new KDTree(points.ToArray(),transform.MultiplyPoint3x4(Vector3.zero),TreeName);
34
+
35
+ float[] AoValues = new float[verts.Length];
36
+
37
+ float max = 0;
38
+ for (int i = 0; i < verts.Length; i++)
39
+ {
40
+ Vector3 origin = transform.MultiplyPoint3x4(verts[i]);
41
+ List <Vector3> neighbours = tree.RadiusSearch(origin, distance);
42
+ float cost = 0f;
43
+ Vector3 normal = transform.MultiplyVector(normals[i]);
44
+ foreach (Vector3 point in neighbours)
45
+ {
46
+ float dist = Vector3.Distance(point, origin);
47
+ cost += Mathf.Clamp01(Vector3.Dot(normal, point - origin) / dist + .5f) * Mathf.Exp(-dist);
48
+ }
49
+ max = Mathf.Max(cost, max);
50
+ AoValues[i] = cost;
51
+ }
52
+
53
+ for (int i = 0; i < AoValues.Length; i++)
54
+ AoValues[i] /= max;
55
+
56
+ for (int i = 0; i < colors.Length; i++)
57
+ {
58
+ colors[i].a = Mathf.Pow(1 - AoValues[i], 5f);
59
+ }
60
+
61
+ }
62
+
63
+ public static float GetTriangleArea(Vector3 v1, Vector3 v2, Vector3 v3)
64
+ {
65
+ Vector3 AB = v2 - v1;
66
+ Vector3 AC = v3 - v1;
67
+ return Vector3.Cross(AB, AC).magnitude / 2f;
68
+ }
69
+
70
+ private static Vector3 SamplePointInTriangle(Vector3 v1, Vector3 v2, Vector3 v3, System.Random random)
71
+ {
72
+ float w1 = (float)random.NextDouble();
73
+ float w2 = (float)random.NextDouble();
74
+ return (1 - Mathf.Sqrt(w1)) * v1 + (Mathf.Sqrt(w1) * (1 - w2)) * v2 + (w2 * Mathf.Sqrt(w1)) * v3;
75
+ }
76
+
77
+ public static ThreadHandleEditor BakeAoAsync(MeshFilter meshFilter, GameObject ob, float resolution, float distance)
78
+ {
79
+ Mesh mesh = meshFilter.sharedMesh;
80
+ Color[] colors = mesh.colors;
81
+ Vector3[] verts = mesh.vertices;
82
+ Vector3[] normals = mesh.normals;
83
+ int[] triangles = mesh.triangles;
84
+ string name = ob.name;
85
+
86
+ if (meshFilter == null || ob == null)
87
+ return null;
88
+
89
+ Matrix4x4 transformMatrix = ob.transform.localToWorldMatrix;
90
+ ThreadHandleEditor handle = new ThreadHandleEditor(
91
+ null,
92
+ () => BakeAo(colors, verts, normals, triangles, transformMatrix, resolution, distance, name),
93
+ () => { mesh.colors = colors; if (meshFilter != null) meshFilter.sharedMesh = mesh; });
94
+ handle.Start();
95
+
96
+ return handle;
97
+ }
98
+
99
+ public static void BakeAo(MeshFilter meshFilter, GameObject ob, float resolution, float distance)
100
+ {
101
+ Mesh mesh = meshFilter.sharedMesh;
102
+ Color[] colors = mesh.colors;
103
+ Vector3[] verts = mesh.vertices;
104
+ Vector3[] normals = mesh.normals;
105
+ int[] triangles = mesh.triangles;
106
+ Matrix4x4 transformMatrix = ob.transform.localToWorldMatrix;
107
+ BakeAo(colors, verts, normals, triangles, transformMatrix, resolution, distance,ob.name);
108
+ mesh.colors = colors;
109
+ meshFilter.sharedMesh = mesh;
110
+ }
111
+ }
112
+
113
+ public class ThreadHandleEditor
114
+ {
115
+ private Thread thread;
116
+ private readonly System.Action OnStartCallback;
117
+ private readonly System.Action ThreadedFunction;
118
+ private readonly System.Action OnEndCallback;
119
+ private Coroutine coroutine;
120
+ private bool begun;
121
+ private bool waited;
122
+ bool ended;
123
+ private float time;
124
+
125
+
126
+ public ThreadHandleEditor(System.Action onStartCallback, System.Action threadedFunction, System.Action onEndCallback)
127
+ {
128
+ OnStartCallback = onStartCallback;
129
+ ThreadedFunction = threadedFunction;
130
+ OnEndCallback = onEndCallback;
131
+ }
132
+
133
+ public void Start()
134
+ {
135
+ #if UNITY_EDITOR
136
+ waited = false;
137
+ begun = false;
138
+ ended = false;
139
+ time = Time.realtimeSinceStartup;
140
+ UnityEditor.EditorApplication.update += Run;
141
+ #endif
142
+ }
143
+
144
+ private void Run()
145
+ {
146
+ #if UNITY_EDITOR
147
+
148
+ if (Time.realtimeSinceStartup - time > 1f)
149
+ {
150
+ waited = true;
151
+ }
152
+
153
+ if (waited && !begun)
154
+ {
155
+ begun = true;
156
+ if (OnStartCallback != null)
157
+ OnStartCallback.Invoke();
158
+
159
+ if (ThreadedFunction != null)
160
+ {
161
+ thread = new Thread(new ThreadStart(ThreadedFunction));
162
+ thread.Start();
163
+ }
164
+ time = Time.realtimeSinceStartup;
165
+ }
166
+
167
+ if (!ended && waited && begun && (thread == null || !thread.IsAlive))
168
+ {
169
+ OnEndCallback.Invoke();
170
+ ended = true;
171
+ UnityEditor.EditorApplication.update -= Run;
172
+ }
173
+ #endif
174
+ }
175
+
176
+ public void Abort()
177
+ {
178
+ if(thread != null)
179
+ thread.Abort();
180
+ #if UNITY_EDITOR
181
+ UnityEditor.EditorApplication.update -= Run;
182
+ #endif
183
+ }
184
+
185
+ private IEnumerator RunThread()
186
+ {
187
+ if (OnStartCallback != null)
188
+ OnStartCallback.Invoke();
189
+
190
+ if (ThreadedFunction != null)
191
+ {
192
+ thread = new Thread(new ThreadStart(ThreadedFunction));
193
+ thread.Start();
194
+ }
195
+
196
+ while (thread != null && thread.IsAlive)
197
+ yield return null;
198
+
199
+ if(OnEndCallback != null)
200
+ OnEndCallback.Invoke();
201
+ }
202
+ }
203
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 1fa41f78d2cbcf84fbb1980f584c3ea3
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,169 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+
5
+ namespace Mtree
6
+ {
7
+ using System.Collections;
8
+ using System.Collections.Generic;
9
+ using UnityEngine;
10
+
11
+
12
+ public class KDTreeNode
13
+ {
14
+ public Vector3 position;
15
+ public KDTreeNode left;
16
+ public KDTreeNode right;
17
+
18
+ public KDTreeNode(Vector3 position)
19
+ {
20
+ this.position = position;
21
+ }
22
+
23
+ public void FindClosestRec(Vector3 point, ref float currBestDist, ref Vector3 currBest, int axis)
24
+ {
25
+ float dist = (point - position).sqrMagnitude;
26
+ if (dist < currBestDist)
27
+ {
28
+ currBestDist = dist;
29
+ currBest = position;
30
+ }
31
+ float diff = point[axis] - position[axis];
32
+ bool leftFirst = diff <= 0;
33
+
34
+ axis = (axis + 1) % 3;
35
+ if (leftFirst)
36
+ {
37
+ if (left != null)
38
+ left.FindClosestRec(point, ref currBestDist, ref currBest, axis);
39
+ if (diff * diff < currBestDist && right != null)
40
+ right.FindClosestRec(point, ref currBestDist, ref currBest, axis);
41
+ }
42
+ else
43
+ {
44
+ if (right != null)
45
+ right.FindClosestRec(point, ref currBestDist, ref currBest, axis);
46
+ if (diff * diff < currBestDist && left != null)
47
+ left.FindClosestRec(point, ref currBestDist, ref currBest, axis);
48
+ }
49
+ }
50
+
51
+ public void RadiusSearchRec(Vector3 center, float radiusSquared, ref List<Vector3> neighbours, int axis)
52
+ {
53
+ float dist = Vector3.SqrMagnitude(center - position);
54
+ if (dist < radiusSquared)
55
+ neighbours.Add(position);
56
+ float diff = (position[axis] - center[axis]);
57
+ axis = (axis + 1) % 3;
58
+ bool searchLeft = diff * diff * Mathf.Sign(diff) > -radiusSquared / 4;
59
+ bool searchRight = diff * diff * Mathf.Sign(diff) < radiusSquared / 4;
60
+
61
+ if (searchLeft && left != null)
62
+ left.RadiusSearchRec(center, radiusSquared, ref neighbours, axis);
63
+ if (searchRight && right != null)
64
+ right.RadiusSearchRec(center, radiusSquared, ref neighbours, axis);
65
+ }
66
+
67
+
68
+ public void AddPoint(Vector3 point, int axis)
69
+ {
70
+ bool isLeft = position[axis] > point[axis];
71
+ KDTreeNode child = isLeft ? left : right;
72
+ axis = (axis + 1) % 3;
73
+ if (child == null)
74
+ {
75
+ child = new KDTreeNode(point);
76
+ if (isLeft) left = child;
77
+ else right = child;
78
+ }
79
+ else
80
+ child.AddPoint(point, axis);
81
+
82
+ }
83
+ }
84
+
85
+ public class KDTree
86
+ {
87
+ private KDTreeNode root;
88
+
89
+ public KDTree(Vector3[] points,Vector3 t,string TreeName)
90
+ {
91
+ if (points.Length == 0)
92
+ {
93
+ points = new Vector3[]{t};
94
+ }
95
+
96
+ root = new KDTreeNode(points[0]);
97
+ for (int i = 1; i < points.Length; i++)
98
+ {
99
+ AddPoint(points[i]);
100
+ }
101
+
102
+ //root = BuildFromPointsRec(points, 0, 0, points.Length);
103
+ }
104
+
105
+ public KDTree()
106
+ {
107
+ root = new KDTreeNode(Vector3.zero);
108
+ }
109
+
110
+ public void AddPoint(Vector3 point)
111
+ {
112
+ root.AddPoint(point, 0);
113
+ }
114
+
115
+ private KDTreeNode BuildFromPointsRec(Vector3[] points, int axis, int start, int end)
116
+ {
117
+ Debug.Log(start + " " + end);
118
+
119
+ if (start == end - 1)
120
+ {
121
+ Debug.Log(start);
122
+ return new KDTreeNode(points[start]);
123
+ }
124
+
125
+ //int medianIndex = SelectMedian(points, axis, start, end);
126
+ int medianIndex = Random.Range(start, end - 1);
127
+
128
+ KDTreeNode node = new KDTreeNode(points[medianIndex]);
129
+ axis = (axis + 1) % 3;
130
+ node.left = BuildFromPointsRec(points, axis, start, medianIndex);
131
+ node.right = BuildFromPointsRec(points, axis, medianIndex, end);
132
+
133
+ return node;
134
+ }
135
+
136
+ public Vector3 FindClosest(Vector3 point)
137
+ {
138
+ float currBestDist = Mathf.Infinity;
139
+ Vector3 bestPoint = root.position;
140
+ root.FindClosestRec(point, ref currBestDist, ref bestPoint, 0);
141
+ return bestPoint;
142
+ }
143
+
144
+ public List<Vector3> RadiusSearch(Vector3 center, float radius)
145
+ {
146
+ List<Vector3> neighbours = new List<Vector3>();
147
+ root.RadiusSearchRec(center, radius * radius, ref neighbours, 0);
148
+ return neighbours;
149
+ }
150
+
151
+ private int SelectMedian(Vector3[] points, int axis, int start, int end)
152
+ {
153
+ float[] values = new float[end - start];
154
+ for (int i = start; i < end; i++)
155
+ {
156
+ values[i - start] = points[i][axis];
157
+ }
158
+ int[] indices = new int[values.Length];
159
+ for (int i = 0; i < indices.Length; i++)
160
+ {
161
+ indices[i] = i;
162
+ }
163
+
164
+ System.Array.Sort(values, indices);
165
+ return indices[indices.Length / 2];
166
+ }
167
+ }
168
+
169
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 88bf59ac1969efc4fb3bfd0055636b13
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,74 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using UnityEngine;
5
+
6
+ namespace Mtree
7
+ {
8
+ /// <summary>
9
+ /// Class that allows to randomly select an index with a weigthed probability
10
+ /// </summary>
11
+ public class WeightedRandom
12
+ {
13
+ private float[] probs;
14
+ private int[] alias;
15
+
16
+ public WeightedRandom(float[] weights)
17
+ {
18
+ PrepareWeights(weights);
19
+ }
20
+
21
+ private void PrepareWeights(float[] weights)
22
+ {
23
+ Queue<int> small = new Queue<int>();
24
+ Queue<int> large = new Queue<int>();
25
+ int n = weights.Length;
26
+
27
+ alias = new int[n];
28
+ probs = new float[n];
29
+
30
+ float[] scaledWeights = new float[n];
31
+
32
+ for (int i = 0; i < weights.Length; i++)
33
+ {
34
+ scaledWeights[i] = weights[i] * n;
35
+
36
+ if (scaledWeights[i] >= 1)
37
+ large.Enqueue(i);
38
+ else
39
+ small.Enqueue(i);
40
+ }
41
+
42
+ while (small.Count > 0 && large.Count > 0)
43
+ {
44
+ int l = small.Dequeue();
45
+ int g = large.Dequeue();
46
+ probs[l] = scaledWeights[l];
47
+ alias[l] = g;
48
+ scaledWeights[g] = scaledWeights[g] + scaledWeights[l] - 1;
49
+ if (scaledWeights[g] < 1)
50
+ small.Enqueue(g);
51
+ else
52
+ large.Enqueue(g);
53
+ }
54
+ while (large.Count > 0)
55
+ {
56
+ probs[large.Dequeue()] = 1;
57
+ }
58
+ while (small.Count > 0)
59
+ {
60
+ probs[small.Dequeue()] = 1;
61
+ }
62
+ }
63
+
64
+ public int GetRandomIndex(System.Random random)
65
+ {
66
+ int i = random.Next(0, probs.Length);
67
+ if (random.NextDouble() < probs[i])
68
+ return i;
69
+ else
70
+ return alias[i];
71
+ }
72
+
73
+ }
74
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 0b37e619dfee8ef4ba1728e5146fcff5
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: d9cbea46438bb3941a5f839748aec559
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -0,0 +1,69 @@
1
+ using UnityEngine;
2
+ public enum BezierControlPointMode {
3
+ Free,
4
+ Aligned,
5
+ Mirrored
6
+ }
7
+
8
+ public static class Bezier {
9
+
10
+ public static Vector3 GetPoint (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) {
11
+ t = Mathf.Clamp01(t);
12
+ float OneMinusT = 1f - t;
13
+ return
14
+ OneMinusT * OneMinusT * OneMinusT * p0 +
15
+ 3f * OneMinusT * OneMinusT * t * p1 +
16
+ 3f * OneMinusT * t * t * p2 +
17
+ t * t * t * p3;
18
+ }
19
+
20
+ public static Vector3 GetFirstDerivative (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t) {
21
+ t = Mathf.Clamp01(t);
22
+ float oneMinusT = 1f - t;
23
+ return
24
+ 3f * oneMinusT * oneMinusT * (p1 - p0) +
25
+ 6f * oneMinusT * t * (p2 - p1) +
26
+ 3f * t * t * (p3 - p2);
27
+ }
28
+ public static float GetTotalLenght(Vector3[] points){
29
+ float length = 0;
30
+ for(int i = 0; i<points.Length-3;i += 3){
31
+ if(points.Length>=3) length += BezierSingleLength(new Vector3[]{points[i],points[i+1],points[i+2],points[i+3]});
32
+ }
33
+ return length;
34
+ }
35
+ public static float BezierSingleLength(Vector3[] p){
36
+ var p0 = p[0] - p[1];
37
+ var p1 = p[2] - p[1];
38
+ var p2 = new Vector3();
39
+ var p3 = p[3]-p[2];
40
+
41
+ var l0 = p0.magnitude;
42
+ var l1 = p1.magnitude;
43
+ var l3 = p3.magnitude;
44
+ if(l0 > 0) p0 /= l0;
45
+ if(l1 > 0) p1 /= l1;
46
+ if(l3 > 0) p3 /= l3;
47
+
48
+ p2 = -p1;
49
+ var a = Mathf.Abs(Vector3.Dot(p0,p1)) + Mathf.Abs(Vector3.Dot(p2,p3));
50
+ if(a > 1.98f || l0 + l1 + l3 < (4 - a)*8) return l0+l1+l3;
51
+
52
+ var bl = new Vector3[4];
53
+ var br = new Vector3[4];
54
+
55
+ bl[0] = p[0];
56
+ bl[1] = (p[0]+p[1]) * 0.5f;
57
+
58
+ var mid = (p[1]+p[2]) * 0.5f;
59
+
60
+ bl[2] = (bl[1]+mid) * 0.5f;
61
+ br[3] = p[3];
62
+ br[2] = (p[2]+p[3]) * 0.5f;
63
+ br[1] = (br[2]+mid) * 0.5f;
64
+ br[0] = (br[1]+bl[2]) * 0.5f;
65
+ bl[3] = br[0];
66
+
67
+ return BezierSingleLength(bl) + BezierSingleLength(br);
68
+ }
69
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 48fadb230fcbf4d448f31983ba4e0c35
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: