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.
- package/.github/workflows/npm.yml +19 -0
- package/CHANGELOG.md +17 -0
- package/CHANGELOG.md.meta +7 -0
- package/Documentation~/Documentation.md +3 -0
- package/Editor/BranchEditor.cs +545 -0
- package/Editor/BranchEditor.cs.meta +16 -0
- package/Editor/EditorCallbacks.cs +69 -0
- package/Editor/EditorCallbacks.cs.meta +11 -0
- package/Editor/MTree.Editor.asmdef +18 -0
- package/Editor/MTree.Editor.asmdef.meta +7 -0
- package/Editor/MenuItem.cs +31 -0
- package/Editor/MenuItem.cs.meta +11 -0
- package/Editor/MtreeBezierInspector.cs +161 -0
- package/Editor/MtreeBezierInspector.cs.meta +11 -0
- package/Editor/MtreeEditor.cs +434 -0
- package/Editor/MtreeEditor.cs.meta +11 -0
- package/Editor/TemplateInspector.cs +66 -0
- package/Editor/TemplateInspector.cs.meta +12 -0
- package/Editor/ValuesEditor.cs +18 -0
- package/Editor/ValuesEditor.cs.meta +11 -0
- package/Editor/VertexColorAdjustmentEditor.cs +169 -0
- package/Editor/VertexColorAdjustmentEditor.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE +21 -0
- package/LICENSE.meta +7 -0
- package/README.md +68 -0
- package/README.md.meta +7 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab +204 -0
- package/Resources/Mtree/MtreeBillboardCamera.prefab.meta +8 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png +0 -0
- package/Resources/Mtree/Sprites/DeleteCrossSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSprite.png.meta +116 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd +0 -0
- package/Resources/Mtree/Sprites/TreeFunctionSpriteSelected.psd.meta +116 -0
- package/Resources/Mtree/Sprites.meta +8 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab +104 -0
- package/Resources/Mtree/Vertex Color Editor/Mtree Vertex Color GameObject.prefab.meta +7 -0
- package/Resources/Mtree/Vertex Color Editor.meta +8 -0
- package/Resources/Mtree/branches.fbx +0 -0
- package/Resources/Mtree/branches.fbx.meta +137 -0
- package/Resources/Mtree.meta +8 -0
- package/Resources.meta +8 -0
- package/Runtime/AO/DensityAO.cs +203 -0
- package/Runtime/AO/DensityAO.cs.meta +11 -0
- package/Runtime/AO/KDTree.cs +169 -0
- package/Runtime/AO/KDTree.cs.meta +11 -0
- package/Runtime/AO/WeightedRandom.cs +74 -0
- package/Runtime/AO/WeightedRandom.cs.meta +11 -0
- package/Runtime/AO.meta +8 -0
- package/Runtime/Bezier/Bezier.cs +69 -0
- package/Runtime/Bezier/Bezier.cs.meta +11 -0
- package/Runtime/Bezier/MtreeBezier.cs +185 -0
- package/Runtime/Bezier/MtreeBezier.cs.meta +11 -0
- package/Runtime/Bezier.meta +8 -0
- package/Runtime/ExampleSceneManager.cs +165 -0
- package/Runtime/ExampleSceneManager.cs.meta +11 -0
- package/Runtime/LODValues.cs +44 -0
- package/Runtime/LODValues.cs.meta +11 -0
- package/Runtime/LeafPoint.cs +135 -0
- package/Runtime/LeafPoint.cs.meta +11 -0
- package/Runtime/MTree.Runtime.asmdef +3 -0
- package/Runtime/MTree.Runtime.asmdef.meta +7 -0
- package/Runtime/MTree.cs +569 -0
- package/Runtime/MTree.cs.meta +11 -0
- package/Runtime/MtreeComponent.cs +482 -0
- package/Runtime/MtreeComponent.cs.meta +11 -0
- package/Runtime/MtreeVariables.cs +11 -0
- package/Runtime/MtreeVariables.cs.meta +11 -0
- package/Runtime/MtreeWind.cs +94 -0
- package/Runtime/MtreeWind.cs.meta +11 -0
- package/Runtime/Node.cs +331 -0
- package/Runtime/Node.cs.meta +11 -0
- package/Runtime/SimplexNoise.cs +166 -0
- package/Runtime/SimplexNoise.cs.meta +11 -0
- package/Runtime/Splines.cs +379 -0
- package/Runtime/Splines.cs.meta +11 -0
- package/Runtime/TreeBilboard.cs +290 -0
- package/Runtime/TreeBilboard.cs.meta +11 -0
- package/Runtime/TreeFunctions/BranchFunction.cs +92 -0
- package/Runtime/TreeFunctions/BranchFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/GrowFunction.cs +81 -0
- package/Runtime/TreeFunctions/GrowFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/LeafFunction.cs +111 -0
- package/Runtime/TreeFunctions/LeafFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/RootsFunction.cs +77 -0
- package/Runtime/TreeFunctions/RootsFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/SplitFunction.cs +50 -0
- package/Runtime/TreeFunctions/SplitFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs +105 -0
- package/Runtime/TreeFunctions/TreeFunctionAsset.cs.meta +11 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs +88 -0
- package/Runtime/TreeFunctions/TrunkFunction.cs.meta +11 -0
- package/Runtime/TreeFunctions.meta +8 -0
- package/Runtime/TreePoint.cs +27 -0
- package/Runtime/TreePoint.cs.meta +11 -0
- package/Runtime/TreeTemplate.cs +50 -0
- package/Runtime/TreeTemplate.cs.meta +12 -0
- package/Runtime/Utils.cs +268 -0
- package/Runtime/Utils.cs.meta +11 -0
- package/Runtime/VSProIntegration.cs +132 -0
- package/Runtime/VSProIntegration.cs.meta +11 -0
- package/Runtime.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Birch.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset +385 -0
- package/Samples~/ExampleTemplates/Examples/Bush.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset +482 -0
- package/Samples~/ExampleTemplates/Examples/Eastern Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset +406 -0
- package/Samples~/ExampleTemplates/Examples/FantasyTree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset +291 -0
- package/Samples~/ExampleTemplates/Examples/Fern.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset +300 -0
- package/Samples~/ExampleTemplates/Examples/High Poly.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset +0 -0
- package/Samples~/ExampleTemplates/Examples/LightingData.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat +196 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Birch.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat +181 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat +201 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat +208 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Oak.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat +180 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat +206 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Ponderossa.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat +172 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark/Bark Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat +392 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene/Floor.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Example Scene.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat +202 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Fern.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat +265 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs HighPoly.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Needles.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat +232 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palm.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat +250 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Palmate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat +247 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat +223 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Poplar.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat +262 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate Outline.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat +281 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Serrate.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat +267 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Stone Pine.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat +236 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs/Leafs Willow.mat.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials/Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Materials.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Old Oak.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset +500 -0
- package/Samples~/ExampleTemplates/Examples/Palm.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset +387 -0
- package/Samples~/ExampleTemplates/Examples/Pine 2.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset +405 -0
- package/Samples~/ExampleTemplates/Examples/Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset +478 -0
- package/Samples~/ExampleTemplates/Examples/Ponderossa Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset +309 -0
- package/Samples~/ExampleTemplates/Examples/Poplar.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr +0 -0
- package/Samples~/ExampleTemplates/Examples/ReflectionProbe-0.exr.meta +117 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset +273 -0
- package/Samples~/ExampleTemplates/Examples/Small Pine.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Small Tree.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Birch_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_C.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Damaged_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_1_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_2_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_3_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_C.png.meta +132 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Decidious_4_N.png.meta +116 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Oak_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Palm_N.bmp.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_C.png.meta +74 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark/Bark_Pine_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Bark.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch Serrate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Needles_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Palmate_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_1_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Pine_2_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch/Branch_Poplar_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Branch.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_PSD.psd.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp/Ramp_Toon.png.meta +76 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Color Ramp.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Fern_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_C.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Palm_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_C.png.meta +99 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Leaf_Willow_N.png.meta +88 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_C.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png +0 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs/Single_Serrated_N.png.meta +96 -0
- package/Samples~/ExampleTemplates/Examples/Textures/Single Leafs.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Textures.meta +8 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset +364 -0
- package/Samples~/ExampleTemplates/Examples/Willow.asset.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.meta +8 -0
- package/Samples~/ExampleTemplates/Examples.unity +12660 -0
- package/Samples~/ExampleTemplates/Examples.unity.meta +7 -0
- package/Samples~/ExampleTemplates.meta +8 -0
- package/Shaders/BarkShader.shadergraph +17215 -0
- package/Shaders/BarkShader.shadergraph.meta +10 -0
- package/Shaders/Editor/BarkEditor.cs +100 -0
- package/Shaders/Editor/BarkEditor.cs.meta +11 -0
- package/Shaders/Editor/LeafEditor.cs +173 -0
- package/Shaders/Editor/LeafEditor.cs.meta +11 -0
- package/Shaders/Editor.meta +8 -0
- package/Shaders/LeafShader.shadergraph +34803 -0
- package/Shaders/LeafShader.shadergraph.meta +10 -0
- package/Shaders/MTree.Shaders.asmdef +3 -0
- package/Shaders/MTree.Shaders.asmdef.meta +7 -0
- package/Shaders/leafFunctions.hlsl +201 -0
- package/Shaders/leafFunctions.hlsl.meta +7 -0
- package/Shaders/vertexFunc.hlsl +55 -0
- package/Shaders/vertexFunc.hlsl.meta +7 -0
- package/Shaders.meta +8 -0
- package/package.json +36 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v1
|
|
12
|
+
- uses: actions/setup-node@v1
|
|
13
|
+
with:
|
|
14
|
+
node-version: 12
|
|
15
|
+
registry-url: https://registry.npmjs.org/
|
|
16
|
+
- run: yarn install
|
|
17
|
+
- run: npm publish --access public
|
|
18
|
+
env:
|
|
19
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## \[1.0.1] - 2025-11-20
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- "HDRP" and "Built-In" added to "Active Targets".
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## \[1.0.0] - 2025-11-20
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Initial open source release of package.
|
|
17
|
+
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
#if UNITY_2018_3_OR_NEWER
|
|
7
|
+
using UnityEngine.Rendering;
|
|
8
|
+
using UnityEngine.Experimental.Rendering;
|
|
9
|
+
#endif
|
|
10
|
+
public enum EnumTextureSize
|
|
11
|
+
{
|
|
12
|
+
_512, _1024, _2048, _4096
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace Mtree
|
|
16
|
+
{
|
|
17
|
+
public class BranchEditor : EditorWindow
|
|
18
|
+
{
|
|
19
|
+
|
|
20
|
+
#region Exposed variables
|
|
21
|
+
public Texture2D leafTexture, normalLeafTexture;
|
|
22
|
+
public Texture2D barkTexture, normalBarkTexture;
|
|
23
|
+
bool switchShader = false;
|
|
24
|
+
int NormalMode = 0;
|
|
25
|
+
Vector3 NormalRotation = new Vector3(0, 0, 0);
|
|
26
|
+
Color barkColor = Color.white;
|
|
27
|
+
int branchNumber = 5;
|
|
28
|
+
float stemLength = 1.5f;
|
|
29
|
+
float length = 0.5f;
|
|
30
|
+
float radius = .01f;
|
|
31
|
+
float angle = .4f;
|
|
32
|
+
float randomness = .2f;
|
|
33
|
+
float splitProba = .05f;
|
|
34
|
+
int textureSize = 1024;
|
|
35
|
+
EnumTextureSize texSize = EnumTextureSize._1024;
|
|
36
|
+
int leafNumber = 30;
|
|
37
|
+
float leafCovering = .7f;
|
|
38
|
+
float leafLength = 1f;
|
|
39
|
+
float leafSize = .7f;
|
|
40
|
+
float leafAngle = 45f;
|
|
41
|
+
float cutOff = .5f;
|
|
42
|
+
Vector3 hsv = new Vector3(0, 1, 1);
|
|
43
|
+
float leafColorVariation = .1f;
|
|
44
|
+
float fakeShading = .3f;
|
|
45
|
+
bool deadLeafs,deadLeafsRendering;
|
|
46
|
+
int leafRotation = 0;
|
|
47
|
+
|
|
48
|
+
#endregion
|
|
49
|
+
|
|
50
|
+
#region Editor variables
|
|
51
|
+
GameObject branchObject;
|
|
52
|
+
GameObject colliderObject;
|
|
53
|
+
GameObject cameraObject;
|
|
54
|
+
Camera cam;
|
|
55
|
+
Texture2D texture;
|
|
56
|
+
Mesh leafMesh;
|
|
57
|
+
int seed = 21;
|
|
58
|
+
bool showColorOptions = true;
|
|
59
|
+
Vector2 scrollPos;
|
|
60
|
+
#endregion
|
|
61
|
+
|
|
62
|
+
#region Editor cosmetic variables
|
|
63
|
+
Color backgroundColor = new Color(.25f, .255f, .26f);
|
|
64
|
+
Color inspectorColor = new Color(.8f, .8f, .8f, .8f);
|
|
65
|
+
int parametersWidth = 250;
|
|
66
|
+
int texturePadding = 10;
|
|
67
|
+
#endregion
|
|
68
|
+
|
|
69
|
+
#if UNITY_2018_3_OR_NEWER
|
|
70
|
+
#region Pipeline Switch
|
|
71
|
+
static RenderPipelineAsset renderPipelineAsset;
|
|
72
|
+
#endregion
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
[MenuItem("Window/Mtree/Open Branch Editor...")]
|
|
79
|
+
static void Start()
|
|
80
|
+
{
|
|
81
|
+
BranchEditor editor = GetWindow(typeof(BranchEditor)) as BranchEditor;
|
|
82
|
+
editor.Init();
|
|
83
|
+
editor.Show();
|
|
84
|
+
#if UNITY_2018_3_OR_NEWER
|
|
85
|
+
renderPipelineAsset = GraphicsSettings.defaultRenderPipeline;
|
|
86
|
+
GraphicsSettings.defaultRenderPipeline = null;
|
|
87
|
+
#endif
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void Init()
|
|
91
|
+
{
|
|
92
|
+
seed = Random.Range(0, 100);
|
|
93
|
+
UpdateBranch();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
void OnGUI()
|
|
98
|
+
{
|
|
99
|
+
GUI.color = backgroundColor;
|
|
100
|
+
GUI.DrawTexture(new Rect(0, 0, position.width, position.height), EditorGUIUtility.whiteTexture);
|
|
101
|
+
|
|
102
|
+
if (texture != null)
|
|
103
|
+
{
|
|
104
|
+
float sizeReduction = Mathf.Min((position.width - parametersWidth - texturePadding * 2) / texture.width, (position.height - texturePadding * 2) / texture.height);
|
|
105
|
+
float posX = ((position.width - parametersWidth) - texture.width * sizeReduction) / 2;
|
|
106
|
+
float posY = position.height - texturePadding - texture.height * sizeReduction;
|
|
107
|
+
GUI.color = backgroundColor * .8f;
|
|
108
|
+
GUI.DrawTexture(new Rect(posX, posY, texture.width * sizeReduction, texture.height * sizeReduction), EditorGUIUtility.whiteTexture);
|
|
109
|
+
GUI.color = Color.white;
|
|
110
|
+
GUI.DrawTexture(new Rect(posX, posY, texture.width * sizeReduction, texture.height * sizeReduction), texture);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
BeginWindows();
|
|
115
|
+
GUI.color = inspectorColor;
|
|
116
|
+
Rect parametersRect = new Rect(position.width - parametersWidth,15, parametersWidth, position.height-15);
|
|
117
|
+
#if UNITY_2018_3_OR_NEWER
|
|
118
|
+
Rect pipelinesRect = new Rect(position.width - parametersWidth,0, parametersWidth, position.height);
|
|
119
|
+
var gs = new GUIStyle();
|
|
120
|
+
gs.fontStyle = FontStyle.Italic;
|
|
121
|
+
gs.normal.textColor = Color.red;
|
|
122
|
+
gs.alignment = TextAnchor.UpperCenter;
|
|
123
|
+
if(renderPipelineAsset != null){
|
|
124
|
+
GUI.Label(pipelinesRect,"Active SRP: "+ renderPipelineAsset.name,gs);
|
|
125
|
+
}else{
|
|
126
|
+
gs.normal.textColor = Color.green;
|
|
127
|
+
GUI.Label(pipelinesRect,"Active SRP: Legacy Pipeline",gs);
|
|
128
|
+
}
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
GUI.Window(0, parametersRect, DrawInspector, "Parameters");
|
|
132
|
+
GUI.BringWindowToFront(0);
|
|
133
|
+
EndWindows();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private void OnDestroy()
|
|
137
|
+
{
|
|
138
|
+
DestoyObjects();
|
|
139
|
+
|
|
140
|
+
#if UNITY_2018_3_OR_NEWER
|
|
141
|
+
GraphicsSettings.defaultRenderPipeline = renderPipelineAsset;
|
|
142
|
+
renderPipelineAsset = null;
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
void DrawInspector(int id)
|
|
149
|
+
{
|
|
150
|
+
scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
|
|
151
|
+
GUILayout.Label("Branch Settings", EditorStyles.boldLabel);
|
|
152
|
+
EditorGUI.BeginChangeCheck();
|
|
153
|
+
EditorGUIUtility.labelWidth = 80;
|
|
154
|
+
if (GUILayout.Button("Randomize"))
|
|
155
|
+
seed = Random.Range(int.MinValue, int.MaxValue);
|
|
156
|
+
barkTexture = EditorGUILayout.ObjectField("Bark Texture", barkTexture, typeof(Texture2D), false) as Texture2D;
|
|
157
|
+
normalBarkTexture = EditorGUILayout.ObjectField("Bark Normal", normalBarkTexture, typeof(Texture2D), false) as Texture2D;
|
|
158
|
+
barkColor = EditorGUILayout.ColorField("Bark Color", barkColor);
|
|
159
|
+
fakeShading = EditorGUILayout.Slider("Fake Shading Intensity", fakeShading, 0f, 1f);
|
|
160
|
+
stemLength = EditorGUILayout.FloatField("Stem Length", stemLength);
|
|
161
|
+
stemLength = Mathf.Max(stemLength, 0.01f);
|
|
162
|
+
length = EditorGUILayout.FloatField("Branch Length", length);
|
|
163
|
+
length = Mathf.Max(length, 0.01f);
|
|
164
|
+
radius = EditorGUILayout.Slider("Radius", radius, .001f, .1f);
|
|
165
|
+
angle = EditorGUILayout.Slider("Split angle", angle, 0f, 1f);
|
|
166
|
+
randomness = EditorGUILayout.FloatField("Randomness", randomness);
|
|
167
|
+
branchNumber = EditorGUILayout.IntSlider("Branch Count", branchNumber, 0, 50);
|
|
168
|
+
splitProba = EditorGUILayout.Slider("Split Proba", splitProba, 0f, .2f);
|
|
169
|
+
|
|
170
|
+
EditorGUILayout.Space();
|
|
171
|
+
EditorGUILayout.Space();
|
|
172
|
+
|
|
173
|
+
GUILayout.Label("Leaf Settings", EditorStyles.boldLabel);
|
|
174
|
+
leafTexture = EditorGUILayout.ObjectField("Leaf Texture", leafTexture, typeof(Texture2D), false) as Texture2D;
|
|
175
|
+
normalLeafTexture = EditorGUILayout.ObjectField("Leaf Normal", normalLeafTexture, typeof(Texture2D), false) as Texture2D;
|
|
176
|
+
//leafRotation = EditorGUILayout.Slider("Texture Rotation", leafRotation, -180, 180);
|
|
177
|
+
|
|
178
|
+
GUILayout.Label("Texture alignment");
|
|
179
|
+
leafRotation = GUILayout.SelectionGrid(leafRotation, new string[] { "Y", "X", "-Y", "-X" }, 4);
|
|
180
|
+
showColorOptions = EditorGUILayout.Foldout(showColorOptions, "Shader Parameters");
|
|
181
|
+
if (showColorOptions)
|
|
182
|
+
{
|
|
183
|
+
cutOff = EditorGUILayout.Slider("Cut Off", cutOff, 0f, 1f);
|
|
184
|
+
leafColorVariation = EditorGUILayout.Slider("Color Variation", leafColorVariation, 0f, 1f);
|
|
185
|
+
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
|
186
|
+
hsv.x = EditorGUILayout.Slider("Hue", hsv.x, 0f, 1f);
|
|
187
|
+
hsv.y = EditorGUILayout.Slider("Saturation", hsv.y, 0f, 2f);
|
|
188
|
+
hsv.z = EditorGUILayout.Slider("Value", hsv.z, 0f, 2f);
|
|
189
|
+
EditorGUILayout.EndVertical();
|
|
190
|
+
}
|
|
191
|
+
leafNumber = EditorGUILayout.IntField("Leaf Count", leafNumber);
|
|
192
|
+
leafNumber = Mathf.Max(0, leafNumber);
|
|
193
|
+
leafCovering = EditorGUILayout.Slider("Leaf Covering", leafCovering, 0f, 1f);
|
|
194
|
+
leafLength = EditorGUILayout.FloatField("Leaf Length", leafLength);
|
|
195
|
+
leafLength = Mathf.Max(0, leafLength);
|
|
196
|
+
leafSize = EditorGUILayout.FloatField("Leaf Size", leafSize);
|
|
197
|
+
leafSize = Mathf.Max(0, leafSize);
|
|
198
|
+
leafAngle = EditorGUILayout.Slider("Leaf Angle", leafAngle, 0f, 90f);
|
|
199
|
+
EditorGUILayout.BeginVertical("box");
|
|
200
|
+
EditorGUILayout.LabelField("Normal Map Mode", Guistyle("b", 10));
|
|
201
|
+
|
|
202
|
+
if (normalBarkTexture != null && normalLeafTexture != null)
|
|
203
|
+
{
|
|
204
|
+
NormalMode = GUILayout.Toolbar(NormalMode, new string[] { "Default", "Enhanced" });
|
|
205
|
+
}
|
|
206
|
+
else
|
|
207
|
+
{
|
|
208
|
+
NormalMode = GUILayout.Toolbar(NormalMode, new string[] { "Default" });
|
|
209
|
+
NormalMode = 0;
|
|
210
|
+
}
|
|
211
|
+
NormalRotation = EditorGUILayout.Vector3Field("Normal Rotation", NormalRotation);
|
|
212
|
+
|
|
213
|
+
string s_swtichShader = "";
|
|
214
|
+
if (switchShader)
|
|
215
|
+
{
|
|
216
|
+
s_swtichShader = "Show Textures";
|
|
217
|
+
}
|
|
218
|
+
else
|
|
219
|
+
{
|
|
220
|
+
s_swtichShader = "Show Normals";
|
|
221
|
+
}
|
|
222
|
+
if (GUILayout.Button(s_swtichShader))
|
|
223
|
+
{
|
|
224
|
+
switchShader = !switchShader;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
EditorGUILayout.Space();
|
|
228
|
+
texSize = (EnumTextureSize)EditorGUILayout.EnumPopup("Texture Size:", texSize);
|
|
229
|
+
EditorGUILayout.EndVertical();
|
|
230
|
+
if (EditorGUI.EndChangeCheck())
|
|
231
|
+
{
|
|
232
|
+
CheckTextureType();
|
|
233
|
+
UpdateBranch(switchShader);
|
|
234
|
+
}
|
|
235
|
+
EditorGUILayout.BeginVertical("Box");
|
|
236
|
+
EditorGUILayout.LabelField("Texture Output",Guistyle("b"));
|
|
237
|
+
deadLeafs = GUILayout.Toggle(deadLeafs, new GUIContent("Dead Leafs"));
|
|
238
|
+
EditorGUILayout.EndVertical();
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if (GUILayout.Button("Save Texture"))
|
|
242
|
+
{
|
|
243
|
+
AssetDatabase.StartAssetEditing();
|
|
244
|
+
ExportTextures();
|
|
245
|
+
AssetDatabase.StopAssetEditing();
|
|
246
|
+
//SaveTexture();
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
EditorGUILayout.EndScrollView();
|
|
251
|
+
}
|
|
252
|
+
/// <summary>
|
|
253
|
+
/// Fontstyle: "n" = Normal | "i" = Italic | "b" = Bold | "bi" = Bold and Italic
|
|
254
|
+
/// </summary>
|
|
255
|
+
GUIStyle Guistyle(string style = "n", int size = 12)
|
|
256
|
+
{
|
|
257
|
+
var gs = new GUIStyle();
|
|
258
|
+
switch (style)
|
|
259
|
+
{
|
|
260
|
+
case "n":
|
|
261
|
+
gs.fontStyle = FontStyle.Normal;
|
|
262
|
+
break;
|
|
263
|
+
case "i":
|
|
264
|
+
gs.fontStyle = FontStyle.Italic;
|
|
265
|
+
break;
|
|
266
|
+
case "b":
|
|
267
|
+
gs.fontStyle = FontStyle.Bold;
|
|
268
|
+
break;
|
|
269
|
+
case "bi":
|
|
270
|
+
gs.fontStyle = FontStyle.BoldAndItalic;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
gs.fontSize = size;
|
|
274
|
+
return gs;
|
|
275
|
+
}
|
|
276
|
+
void UpdateBranch(bool normalShader = false)
|
|
277
|
+
{
|
|
278
|
+
switch (texSize)
|
|
279
|
+
{
|
|
280
|
+
case EnumTextureSize._512:
|
|
281
|
+
textureSize = 512;
|
|
282
|
+
break;
|
|
283
|
+
case EnumTextureSize._1024:
|
|
284
|
+
textureSize = 1024;
|
|
285
|
+
break;
|
|
286
|
+
case EnumTextureSize._2048:
|
|
287
|
+
textureSize = 2048;
|
|
288
|
+
break;
|
|
289
|
+
case EnumTextureSize._4096:
|
|
290
|
+
textureSize = 4096;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (branchObject == null)
|
|
295
|
+
CreateBranchObject(normalShader);
|
|
296
|
+
if(!deadLeafsRendering)
|
|
297
|
+
CreateLeafMesh();
|
|
298
|
+
MTree branch = new MTree(branchObject.transform);
|
|
299
|
+
TrunkFunction trunkFunction = ScriptableObject.CreateInstance<TrunkFunction>();
|
|
300
|
+
trunkFunction.Init(null);
|
|
301
|
+
|
|
302
|
+
float resolution = 20;
|
|
303
|
+
|
|
304
|
+
Random.InitState(seed);
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
branch.AddTrunk(Vector3.up, Vector3.forward, stemLength, AnimationCurve.Linear(0, 1, 1, .3f), radius, resolution, randomness / 3, 0, AnimationCurve.Linear(0, 1, 0, 0), 0, .01f, 1, 0);
|
|
308
|
+
branch.TwigSplit(branchNumber, angle*90f, .9f, 0f);
|
|
309
|
+
branch.Grow(length, AnimationCurve.Linear(0, 1, 1, 1), resolution, splitProba, AnimationCurve.Linear(0, 1, 1, 1), angle, 2, 1, 1, randomness, AnimationCurve.Linear(0, 1, 1, .4f), .9f, 0f, 0f, 1f, 0.00001f, obstacleAvoidance:false);
|
|
310
|
+
if(!deadLeafsRendering)
|
|
311
|
+
branch.AddLeafs(leafCovering, leafNumber, new Mesh[] { leafMesh }, leafSize, false, 0, 0, 1, leafAngle, false, 0, 0, 0, 0);
|
|
312
|
+
Mesh mesh = CreateBranchMesh(branch, trunkFunction);
|
|
313
|
+
|
|
314
|
+
branchObject.GetComponent<MeshFilter>().mesh = mesh;
|
|
315
|
+
|
|
316
|
+
if (cameraObject == null)
|
|
317
|
+
CreateCameraObject();
|
|
318
|
+
RenderCamera();
|
|
319
|
+
|
|
320
|
+
DestoyObjects();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
void CreateBranchObject(bool normalShader)
|
|
325
|
+
{
|
|
326
|
+
branchObject = new GameObject("Branch Editor");
|
|
327
|
+
branchObject.transform.position = Vector3.down * 200;
|
|
328
|
+
branchObject.AddComponent<MeshFilter>();
|
|
329
|
+
MeshRenderer rend = branchObject.AddComponent<MeshRenderer>();
|
|
330
|
+
Material barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Bark"));
|
|
331
|
+
Material leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Leafs"));
|
|
332
|
+
|
|
333
|
+
if (normalShader)
|
|
334
|
+
{
|
|
335
|
+
if (NormalMode == 0)
|
|
336
|
+
{
|
|
337
|
+
barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Normal"));
|
|
338
|
+
leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Normal"));
|
|
339
|
+
}
|
|
340
|
+
if (NormalMode == 1)
|
|
341
|
+
{
|
|
342
|
+
barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_EnhancedNormal"));
|
|
343
|
+
leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_EnhancedNormal"));
|
|
344
|
+
barkMaterial.SetVector("_Rotation", NormalRotation + new Vector3(90, 0, 0));
|
|
345
|
+
leafMaterial.SetVector("_Rotation", NormalRotation + new Vector3(90, 0, 0));
|
|
346
|
+
}
|
|
347
|
+
barkMaterial.SetTexture("_BumpMap", normalBarkTexture);
|
|
348
|
+
leafMaterial.SetTexture("_BumpMap", normalLeafTexture);
|
|
349
|
+
}
|
|
350
|
+
else
|
|
351
|
+
{
|
|
352
|
+
barkMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Bark"));
|
|
353
|
+
leafMaterial = new Material(Shader.Find("Hidden/BranchEditor/BranchEditor_Leafs")); barkMaterial.SetTexture("_MainTex", barkTexture);
|
|
354
|
+
barkMaterial.SetFloat("_FakeShading", fakeShading);
|
|
355
|
+
barkMaterial.SetColor("_Color", barkColor);
|
|
356
|
+
leafMaterial.SetFloat("_HueShift", hsv.x);
|
|
357
|
+
leafMaterial.SetFloat("_Saturation", hsv.y);
|
|
358
|
+
leafMaterial.SetFloat("_Value", hsv.z);
|
|
359
|
+
leafMaterial.SetFloat("_ColorVariation", leafColorVariation);
|
|
360
|
+
}
|
|
361
|
+
leafMaterial.SetTexture("_MainTex", leafTexture);
|
|
362
|
+
leafMaterial.SetFloat("_Cutoff", cutOff);
|
|
363
|
+
rend.sharedMaterials = new Material[] { barkMaterial, leafMaterial };
|
|
364
|
+
|
|
365
|
+
colliderObject = new GameObject("collider");
|
|
366
|
+
colliderObject.transform.position = branchObject.transform.position + Vector3.back;
|
|
367
|
+
BoxCollider col = colliderObject.AddComponent<BoxCollider>();
|
|
368
|
+
col.size = new Vector3(5, 5, .01f);
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
void CreateCameraObject()
|
|
374
|
+
{
|
|
375
|
+
cameraObject = Instantiate(Resources.Load("Mtree/MtreeBillboardCamera") as GameObject);
|
|
376
|
+
cameraObject.transform.position = branchObject.transform.position;
|
|
377
|
+
cameraObject.transform.rotation = Quaternion.Euler(90, 0, 0);
|
|
378
|
+
|
|
379
|
+
cam = cameraObject.GetComponent<Camera>();
|
|
380
|
+
cam.orthographic = true;
|
|
381
|
+
|
|
382
|
+
Bounds bb = branchObject.GetComponent<Renderer>().bounds;
|
|
383
|
+
Vector3 position = bb.center;
|
|
384
|
+
position.x = branchObject.transform.position.x; ;
|
|
385
|
+
float width = Mathf.Abs(position.x - bb.center.x) + bb.extents.x;
|
|
386
|
+
cam.transform.position = position;
|
|
387
|
+
cam.nearClipPlane = -bb.extents.y;
|
|
388
|
+
cam.farClipPlane = bb.extents.y;
|
|
389
|
+
cam.orthographicSize = bb.extents.z;
|
|
390
|
+
cam.aspect = width / bb.extents.z;
|
|
391
|
+
Color color = backgroundColor;
|
|
392
|
+
color.a = 0f;
|
|
393
|
+
cam.backgroundColor = color;
|
|
394
|
+
cam.clearFlags = CameraClearFlags.SolidColor;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
void RenderCamera()
|
|
399
|
+
{
|
|
400
|
+
RenderTexture currentRT = RenderTexture.active;
|
|
401
|
+
int sizeY = textureSize;
|
|
402
|
+
int sizeX = (int)(textureSize * cam.aspect);
|
|
403
|
+
RenderTexture camText = new RenderTexture(sizeX, sizeY, 16, RenderTextureFormat.ARGB32);
|
|
404
|
+
cam.targetTexture = camText;
|
|
405
|
+
RenderTexture.active = cam.targetTexture;
|
|
406
|
+
cam.Render();
|
|
407
|
+
Texture2D image = new Texture2D(cam.targetTexture.width, cam.targetTexture.height, TextureFormat.RGBA32, false);
|
|
408
|
+
image.name = "Branch";
|
|
409
|
+
image.ReadPixels(new Rect(0, 0, cam.targetTexture.width, cam.targetTexture.height), 0, 0);
|
|
410
|
+
image.Apply();
|
|
411
|
+
RenderTexture.active = currentRT;
|
|
412
|
+
texture = image;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
Mesh CreateBranchMesh(MTree branch, TrunkFunction trunkFunction)
|
|
417
|
+
{
|
|
418
|
+
Mesh mesh = new Mesh();
|
|
419
|
+
branch.GenerateMeshData(trunkFunction, 0, 1, 1, 1);
|
|
420
|
+
mesh.vertices = branch.verts;
|
|
421
|
+
mesh.normals = branch.normals;
|
|
422
|
+
mesh.uv = branch.uvs;
|
|
423
|
+
Color[] colors = branch.colors;
|
|
424
|
+
mesh.triangles = branch.triangles;
|
|
425
|
+
if (branch.leafTriangles.Length > 0)
|
|
426
|
+
{
|
|
427
|
+
mesh.subMeshCount = 2;
|
|
428
|
+
mesh.SetTriangles(branch.leafTriangles, 1);
|
|
429
|
+
}
|
|
430
|
+
mesh.colors = colors;
|
|
431
|
+
return mesh;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
void DestoyObjects()
|
|
436
|
+
{
|
|
437
|
+
if (branchObject != null)
|
|
438
|
+
DestroyImmediate(branchObject);
|
|
439
|
+
if (cameraObject != null)
|
|
440
|
+
DestroyImmediate(cameraObject);
|
|
441
|
+
if (colliderObject != null)
|
|
442
|
+
DestroyImmediate(colliderObject);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
void CreateLeafMesh()
|
|
447
|
+
{
|
|
448
|
+
Vector3[] verts = new Vector3[4] { Vector3.left / 2, Vector3.left / 2 + Vector3.forward * leafLength, Vector3.right / 2 + Vector3.forward * leafLength, Vector3.right / 2 };
|
|
449
|
+
Quaternion rot = Quaternion.Euler(0, leafRotation * 90, 0);
|
|
450
|
+
Matrix4x4 trans = Matrix4x4.Translate(new Vector3(0, 0, -leafLength / 2));
|
|
451
|
+
Matrix4x4 transInv = trans.inverse;
|
|
452
|
+
|
|
453
|
+
for (int i = 0; i < verts.Length; i++)
|
|
454
|
+
{
|
|
455
|
+
verts[i] = trans.MultiplyPoint(verts[i]);
|
|
456
|
+
verts[i] = rot * verts[i];
|
|
457
|
+
verts[i] = transInv.MultiplyPoint(verts[i]);
|
|
458
|
+
}
|
|
459
|
+
Vector3[] normals = new Vector3[4] { Vector3.up, Vector3.up, Vector3.up, Vector3.up };
|
|
460
|
+
Vector2[] uvs = new Vector2[4] { Vector2.zero, Vector2.up, Vector2.up + Vector2.right, Vector2.right };
|
|
461
|
+
int[] triangles = new int[6] { 0, 1, 3, 1, 2, 3 };
|
|
462
|
+
|
|
463
|
+
leafMesh = new Mesh();
|
|
464
|
+
leafMesh.vertices = verts;
|
|
465
|
+
leafMesh.normals = normals;
|
|
466
|
+
leafMesh.uv = uvs;
|
|
467
|
+
leafMesh.triangles = triangles;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
void ExportTextures()
|
|
472
|
+
{
|
|
473
|
+
|
|
474
|
+
UpdateBranch();
|
|
475
|
+
string path = SaveTexture();
|
|
476
|
+
string name = Path.GetFileNameWithoutExtension(path);
|
|
477
|
+
var nameDB = name;
|
|
478
|
+
name += "_Normal.png";
|
|
479
|
+
path = path.Replace(Path.GetFileName(path), name);
|
|
480
|
+
UpdateBranch(true);
|
|
481
|
+
SaveTexture(path);
|
|
482
|
+
if (deadLeafs)
|
|
483
|
+
{
|
|
484
|
+
deadLeafsRendering = true;
|
|
485
|
+
name = nameDB + "_DeadLeafs.png";
|
|
486
|
+
path = path.Replace(Path.GetFileName(path), name);
|
|
487
|
+
UpdateBranch();
|
|
488
|
+
SaveTexture(path);
|
|
489
|
+
|
|
490
|
+
deadLeafsRendering = true;
|
|
491
|
+
name = nameDB + "_DeadLeafs_Normal.png";
|
|
492
|
+
path = path.Replace(Path.GetFileName(path), name);
|
|
493
|
+
UpdateBranch(true);
|
|
494
|
+
SaveTexture(path);
|
|
495
|
+
deadLeafsRendering = false;
|
|
496
|
+
}
|
|
497
|
+
UpdateBranch();
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
void CheckTextureType()
|
|
501
|
+
{
|
|
502
|
+
// var b_path = AssetDatabase.GetAssetPath(normalBarkTexture);
|
|
503
|
+
// var l_path = AssetDatabase.GetAssetPath(normalLeafTexture);
|
|
504
|
+
// TextureImporter b_t = (TextureImporter)TextureImporter.GetAtPath(b_path);
|
|
505
|
+
// TextureImporter l_t = (TextureImporter)TextureImporter.GetAtPath(b_path);
|
|
506
|
+
// if(b_t.textureType != TextureImporterType.NormalMap){
|
|
507
|
+
// b_t.textureType = TextureImporterType.NormalMap;
|
|
508
|
+
// b_t.SaveAndReimport();
|
|
509
|
+
// }
|
|
510
|
+
// if(l_t.textureType != TextureImporterType.NormalMap){
|
|
511
|
+
// l_t.textureType = TextureImporterType.NormalMap;
|
|
512
|
+
// l_t.SaveAndReimport();
|
|
513
|
+
// }
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
string SaveTexture(string path = null)
|
|
517
|
+
{
|
|
518
|
+
if (path == null)
|
|
519
|
+
{
|
|
520
|
+
path = EditorUtility.SaveFilePanelInProject("Save png", texture.name + ".png", "png", "Please enter a file name to save the texture to");
|
|
521
|
+
}
|
|
522
|
+
if (path.Length != 0)
|
|
523
|
+
{
|
|
524
|
+
Utils.DilateTexture(texture, 100);
|
|
525
|
+
byte[] bytes = texture.EncodeToPNG();
|
|
526
|
+
File.WriteAllBytes(path, bytes);
|
|
527
|
+
AssetDatabase.Refresh();
|
|
528
|
+
}
|
|
529
|
+
return path;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
private void RemoveBackground(ref Color[] colors)
|
|
533
|
+
{
|
|
534
|
+
Color backgroundColor = new Color(0.025f, 0.07f, 0.19f);
|
|
535
|
+
for (int i = 0; i < colors.Length; i++)
|
|
536
|
+
{
|
|
537
|
+
Color c = colors[i];
|
|
538
|
+
if (Mathf.Abs(c.r - backgroundColor.r) + Mathf.Abs(c.g - backgroundColor.g) + Mathf.Abs(c.b - backgroundColor.b) < .05)
|
|
539
|
+
{
|
|
540
|
+
colors[i] = new Color(0, 0, 0, 0);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: cde4d011ef4c2cd4ea1a5e4ae0a0bd74
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences:
|
|
7
|
+
- m_PersistentViewDataDictionary: {instanceID: 0}
|
|
8
|
+
- leafTexture: {fileID: 2800000, guid: fa92e022faac9774fa119daa58d30e1e, type: 3}
|
|
9
|
+
- normalLeafTexture: {fileID: 2800000, guid: 484e5ae7bf0555b4d984e8c7cf893017, type: 3}
|
|
10
|
+
- barkTexture: {fileID: 2800000, guid: cbfeb2867c4dc9949806880460cd8903, type: 3}
|
|
11
|
+
- normalBarkTexture: {fileID: 2800000, guid: b3a8b02284c008548941ccb056fa869a, type: 3}
|
|
12
|
+
executionOrder: 0
|
|
13
|
+
icon: {instanceID: 0}
|
|
14
|
+
userData:
|
|
15
|
+
assetBundleName:
|
|
16
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
using System.Collections;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using System.IO;
|
|
6
|
+
|
|
7
|
+
#if UNITY_2018_3_OR_NEWER
|
|
8
|
+
using UnityEditor.Experimental.SceneManagement;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
namespace Mtree
|
|
12
|
+
{
|
|
13
|
+
|
|
14
|
+
[InitializeOnLoad]
|
|
15
|
+
public class EditorCallbacks
|
|
16
|
+
{
|
|
17
|
+
static EditorCallbacks()
|
|
18
|
+
{
|
|
19
|
+
PrefabUtility.prefabInstanceUpdated += OnCreatePrefab;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static void OnCreatePrefab(GameObject instance)
|
|
23
|
+
{
|
|
24
|
+
if (instance.GetComponent<MtreeComponent>() == null)
|
|
25
|
+
return;
|
|
26
|
+
|
|
27
|
+
#if UNITY_2018_3_OR_NEWER
|
|
28
|
+
string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(instance);
|
|
29
|
+
#else
|
|
30
|
+
string prefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(instance));
|
|
31
|
+
#endif
|
|
32
|
+
MtreeComponent[] trees = (MtreeComponent[])GameObject.FindObjectsOfType(typeof(MtreeComponent));
|
|
33
|
+
MtreeComponent originTree = null;
|
|
34
|
+
foreach (MtreeComponent tree in trees)
|
|
35
|
+
{
|
|
36
|
+
#if UNITY_2018_3_OR_NEWER
|
|
37
|
+
bool isInstance = PrefabUtility.GetPrefabInstanceStatus(tree) == PrefabInstanceStatus.Connected;
|
|
38
|
+
string parentPrefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(tree));
|
|
39
|
+
#else
|
|
40
|
+
bool isInstance = PrefabUtility.GetPrefabType(tree) == PrefabType.PrefabInstance;
|
|
41
|
+
string parentPrefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(tree));
|
|
42
|
+
#endif
|
|
43
|
+
if (isInstance && parentPrefabPath == prefabPath)
|
|
44
|
+
{
|
|
45
|
+
#if UNITY_2018_3_OR_NEWER
|
|
46
|
+
PrefabUtility.UnpackPrefabInstance(tree.gameObject, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
|
|
47
|
+
#else
|
|
48
|
+
PrefabUtility.DisconnectPrefabInstance(tree);
|
|
49
|
+
#endif
|
|
50
|
+
originTree = tree;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#if UNITY_2018_3_OR_NEWER // Unity 2017 crashes when deleting prefab at this stage. This part is therefore also done in the MtreeComponent editor
|
|
56
|
+
AssetDatabase.DeleteAsset(prefabPath);
|
|
57
|
+
AssetDatabase.Refresh();
|
|
58
|
+
#endif
|
|
59
|
+
|
|
60
|
+
if (originTree == null)
|
|
61
|
+
return;
|
|
62
|
+
|
|
63
|
+
string templatePath = AssetDatabase.GenerateUniqueAssetPath(Path.GetDirectoryName(prefabPath) + "/" + originTree.name + ".asset");
|
|
64
|
+
TreeTemplate template = TreeTemplate.CreateFromFunctions(originTree.treeFunctionsAssets, templatePath);
|
|
65
|
+
originTree.template = template;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|