├── .gitignore ├── Assets ├── Gizmos.meta ├── Gizmos │ ├── PFShape Icon.png │ ├── PFShape Icon.png.meta │ ├── ProceduralFlower Icon.png │ └── ProceduralFlower Icon.png.meta ├── Packages.meta └── Packages │ ├── ProceduralFlower.meta │ └── ProceduralFlower │ ├── Materials.meta │ ├── Materials │ ├── BlueBud.mat │ ├── BlueBud.mat.meta │ ├── BluePetal.mat │ ├── BluePetal.mat.meta │ ├── Combine.mat │ ├── Combine.mat.meta │ ├── Garden.mat │ ├── Garden.mat.meta │ ├── Leaf.mat │ ├── Leaf.mat.meta │ ├── OrangeBud.mat │ ├── OrangeBud.mat.meta │ ├── OrangePetal.mat │ ├── OrangePetal.mat.meta │ ├── PurpleBud.mat │ ├── PurpleBud.mat.meta │ ├── PurplePetal.mat │ ├── PurplePetal.mat.meta │ ├── RedBud.mat │ ├── RedBud.mat.meta │ ├── RedPetal.mat │ ├── RedPetal.mat.meta │ ├── Stem.mat │ ├── Stem.mat.meta │ ├── YellowBud.mat │ ├── YellowBud.mat.meta │ ├── YellowPetal.mat │ └── YellowPetal.mat.meta │ ├── Models.meta │ ├── Models │ ├── Garden.asset │ └── Garden.asset.meta │ ├── Prefabs.meta │ ├── Prefabs │ ├── PFGrowingBlue.prefab │ ├── PFGrowingBlue.prefab.meta │ ├── PFGrowingOrange.prefab │ ├── PFGrowingOrange.prefab.meta │ ├── PFGrowingPurple.prefab │ ├── PFGrowingPurple.prefab.meta │ ├── PFGrowingRed.prefab │ ├── PFGrowingRed.prefab.meta │ ├── PFGrowingYellow.prefab │ └── PFGrowingYellow.prefab.meta │ ├── Scenes.meta │ ├── Scenes │ ├── Demo.unity │ ├── Demo.unity.meta │ ├── Garden.unity │ └── Garden.unity.meta │ ├── Scripts.meta │ ├── Scripts │ ├── Demo.meta │ ├── Demo │ │ ├── PFCombineDemo.cs │ │ ├── PFCombineDemo.cs.meta │ │ ├── PFGarden.cs │ │ ├── PFGarden.cs.meta │ │ ├── PFGrowing.cs │ │ ├── PFGrowing.cs.meta │ │ ├── PFTester.cs │ │ └── PFTester.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── PFShapeInspector.cs │ │ ├── PFShapeInspector.cs.meta │ │ ├── PFShapeWindow.cs │ │ ├── PFShapeWindow.cs.meta │ │ ├── PFTesterInspector.cs │ │ └── PFTesterInspector.cs.meta │ ├── Flowers.meta │ ├── Flowers │ │ ├── Blue.asset │ │ ├── Blue.asset.meta │ │ ├── Example.asset │ │ ├── Example.asset.meta │ │ ├── Orange.asset │ │ ├── Orange.asset.meta │ │ ├── Purple.asset │ │ ├── Purple.asset.meta │ │ ├── Red.asset │ │ ├── Red.asset.meta │ │ ├── Yellow.asset │ │ └── Yellow.asset.meta │ ├── PFCatmullRomSpline.cs │ ├── PFCatmullRomSpline.cs.meta │ ├── PFCombine.cs │ ├── PFCombine.cs.meta │ ├── PFControlPoint.cs │ ├── PFControlPoint.cs.meta │ ├── PFLeaf.cs │ ├── PFLeaf.cs.meta │ ├── PFPart.cs │ ├── PFPart.cs.meta │ ├── PFRandom.cs │ ├── PFRandom.cs.meta │ ├── PFShape.cs │ ├── PFShape.cs.meta │ ├── PFStem.cs │ ├── PFStem.cs.meta │ ├── ProceduralFlower.cs │ ├── ProceduralFlower.cs.meta │ ├── Shapes.meta │ └── Shapes │ │ ├── Bud.asset │ │ ├── Bud.asset.meta │ │ ├── Leaf.asset │ │ ├── Leaf.asset.meta │ │ ├── Leaf2.asset │ │ ├── Leaf2.asset.meta │ │ ├── Petal.asset │ │ └── Petal.asset.meta │ ├── Shaders.meta │ ├── Shaders │ ├── Bud.shader │ ├── Bud.shader.meta │ ├── Combine.shader │ ├── Combine.shader.meta │ ├── Garden.shader │ ├── Garden.shader.meta │ ├── Petal.shader │ ├── Petal.shader.meta │ ├── ProceduralFlower.cginc │ ├── ProceduralFlower.cginc.meta │ ├── Stover.shader │ └── Stover.shader.meta │ ├── Textures.meta │ └── Textures │ ├── Grid.jpg │ ├── Grid.jpg.meta │ ├── Knob.png │ ├── Knob.png.meta │ ├── PFShapeWindow.png │ ├── PFShapeWindow.png.meta │ ├── uvtester.jpg │ └── uvtester.jpg.meta ├── Captures ├── Demo.png ├── Editor.gif ├── Garden.gif ├── Height.gif ├── Inspector.png ├── Leaves.gif └── Petals.gif ├── LICENSE ├── ProceduralFlower.unitypackage └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Pp]rojectSettings/ 6 | Papers/ 7 | 8 | # Autogenerated VS/MD solution and project files 9 | *.csproj 10 | *.unityproj 11 | *.sln 12 | *.suo 13 | *.user 14 | *.userprefs 15 | *.pidb 16 | *.booproj 17 | 18 | # Unity3D Generated File On Crash Reports 19 | sysinfo.txt -------------------------------------------------------------------------------- /Assets/Gizmos.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac7c6831c4db4444cad56215be911512 3 | folderAsset: yes 4 | timeCreated: 1485657227 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Gizmos/PFShape Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Gizmos/PFShape Icon.png -------------------------------------------------------------------------------- /Assets/Gizmos/PFShape Icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a31647f080e67404ab437d800668931c 3 | timeCreated: 1485658947 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: WebGL 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | spriteSheet: 78 | serializedVersion: 2 79 | sprites: [] 80 | outline: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/Gizmos/ProceduralFlower Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Gizmos/ProceduralFlower Icon.png -------------------------------------------------------------------------------- /Assets/Gizmos/ProceduralFlower Icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a39e9fea6ef9d4b6296eac44fc2d3db7 3 | timeCreated: 1485658803 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: WebGL 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | spriteSheet: 78 | serializedVersion: 2 79 | sprites: [] 80 | outline: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/Packages.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb5fd3a86ec8a2b45818e1dd9fa5a524 3 | folderAsset: yes 4 | timeCreated: 1482220984 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea0e2918fdf81894ea360cce1fe8ffb6 3 | folderAsset: yes 4 | timeCreated: 1482220993 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1d1abdd65570ea41978feca897d6010 3 | folderAsset: yes 4 | timeCreated: 1482733999 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/BlueBud.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/BlueBud.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/BlueBud.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 742d4d64b794046909d4d9bfcdd98729 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/BluePetal.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/BluePetal.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/BluePetal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 747c6239b309443eea0882b1dc0a5a1c 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Combine.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/Combine.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Combine.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce5dde919b1d32e448105c75aa1a6800 3 | timeCreated: 1485747001 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Garden.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/Garden.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Garden.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b0fe8c7fbc3b46c882e7b156dc71bbf 3 | timeCreated: 1485687034 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Leaf.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/Leaf.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Leaf.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23eff92748469457daadc9ad60238629 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/OrangeBud.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/OrangeBud.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/OrangeBud.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17314adb600a243d19be41279b24c116 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/OrangePetal.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/OrangePetal.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/OrangePetal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6326232e0aa8a440f9bbc14a778d2592 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/PurpleBud.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/PurpleBud.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/PurpleBud.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f426c21fd5ce486a9be36440b93d5af 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/PurplePetal.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/PurplePetal.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/PurplePetal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1e87b15383f44dd09e0e9680b1a79a1 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/RedBud.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/RedBud.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/RedBud.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce87fea90bdaf4fc29712567d3ac1417 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/RedPetal.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/RedPetal.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/RedPetal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a1556cbfceadd34cb0cb0b97f57c98c 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Stem.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/Stem.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/Stem.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6d027743c4004c87a7a73830432c83e 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/YellowBud.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/YellowBud.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/YellowBud.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd92fd79991e142a98a5c716a44cbee0 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/YellowPetal.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Materials/YellowPetal.mat -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Materials/YellowPetal.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 334aac84e9abd4d919c9fb1cfb3489a0 3 | timeCreated: 1482734005 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f9928056151ed14c94776314c97d5b2 3 | folderAsset: yes 4 | timeCreated: 1482734584 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Models/Garden.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Models/Garden.asset -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Models/Garden.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5495fa1f84f4410ba97a4edb89edf32 3 | timeCreated: 1485687323 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90dee17994e994bb8b20bd07cb2f5557 3 | folderAsset: yes 4 | timeCreated: 1485690581 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingBlue.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Prefabs/PFGrowingBlue.prefab -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingBlue.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84680e69f0dcd4c1594b0621f98aab1a 3 | timeCreated: 1485690586 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingOrange.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Prefabs/PFGrowingOrange.prefab -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingOrange.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4782b09d9ccb346b2aec7fb14f87924a 3 | timeCreated: 1485690586 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingPurple.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Prefabs/PFGrowingPurple.prefab -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingPurple.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc439e05dadeb4ddaa644b778a37473a 3 | timeCreated: 1485690586 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingRed.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Prefabs/PFGrowingRed.prefab -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingRed.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df50d9196bfa44ef3a55d6c023fcfe9a 3 | timeCreated: 1485690586 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingYellow.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Prefabs/PFGrowingYellow.prefab -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Prefabs/PFGrowingYellow.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4075419a0e4944e1e835c65edab2af5c 3 | timeCreated: 1485690586 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6e5fe4e31a1da1409825429e2ad540d 3 | folderAsset: yes 4 | timeCreated: 1482220998 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scenes/Demo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Scenes/Demo.unity -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scenes/Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2908f46c0129f1c42a3ba30d74e62e5e 3 | timeCreated: 1482221010 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scenes/Garden.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Scenes/Garden.unity -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scenes/Garden.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5668d862231143d5b741f7bcd1e5bb7 3 | timeCreated: 1482221010 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 175741fd86aa0b24c9418dcd5a15dae5 3 | folderAsset: yes 4 | timeCreated: 1482220998 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ee9d05d8e1b44bafa5a8cdc7ede953f 3 | folderAsset: yes 4 | timeCreated: 1485655642 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFCombineDemo.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower.Demo { 6 | 7 | [RequireComponent (typeof(MeshFilter))] 8 | public class PFCombineDemo : MonoBehaviour { 9 | 10 | [SerializeField] PFPartType type = PFPartType.None; 11 | [SerializeField] ProceduralFlower flower; 12 | 13 | void Awake () { 14 | var mesh = PFCombine.Combine(flower, type); 15 | GetComponent().sharedMesh = mesh; 16 | } 17 | 18 | } 19 | 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFCombineDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be0595899275d19488d6ca4acd546565 3 | timeCreated: 1485746515 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFGarden.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | namespace mattatz.ProceduralFlower.Demo { 8 | 9 | public class PFGarden : MonoBehaviour { 10 | 11 | [SerializeField] List prefabs; 12 | 13 | const string SHADER_PATH = "Hidden/Internal-Colored"; 14 | 15 | Material lineMaterial = null; 16 | MeshCollider col = null; 17 | Vector3[] vertices; 18 | int[] triangles; 19 | 20 | bool hit; 21 | Vector3 point; 22 | Vector3 normal; 23 | Quaternion rotation; 24 | 25 | void Update () { 26 | var mouse = Input.mousePosition; 27 | var ray = Camera.main.ScreenPointToRay(mouse); 28 | RaycastHit info; 29 | hit = col.Raycast(ray, out info, float.MaxValue); 30 | if(hit) { 31 | point = info.point; 32 | var t = info.triangleIndex * 3; 33 | var a = triangles[t]; 34 | var b = triangles[t + 1]; 35 | var c = triangles[t + 2]; 36 | var va = vertices[a]; 37 | var vb = vertices[b]; 38 | var vc = vertices[c]; 39 | normal = transform.TransformDirection(Vector3.Cross(vb - va, vc - va)); 40 | rotation = Quaternion.LookRotation(normal); 41 | } 42 | 43 | if(Input.GetMouseButtonUp(0) && hit) { 44 | var go = Instantiate(prefabs[Random.Range(0, prefabs.Count)]) as GameObject; 45 | go.transform.position = point; 46 | go.transform.localScale = Vector3.one * Random.Range(0.4f, 0.5f); 47 | go.transform.localRotation = Quaternion.LookRotation(Vector3.forward, normal); // * Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.up); 48 | } 49 | 50 | } 51 | 52 | const int resolution = 16; 53 | const float pi2 = Mathf.PI * 2f; 54 | const float radius = 0.5f; 55 | Color color = new Color(0.6f, 0.75f, 1f); 56 | 57 | void OnRenderObject () { 58 | if(!hit) return; 59 | 60 | CheckInit(); 61 | 62 | lineMaterial.SetPass(0); 63 | lineMaterial.SetInt("_ZTest", (int)CompareFunction.Always); 64 | 65 | GL.PushMatrix(); 66 | GL.Begin(GL.LINES); 67 | GL.Color(color); 68 | 69 | for(int i = 0; i < resolution; i++) { 70 | var cur = (float)i / resolution * pi2; 71 | var next = (float)(i + 1) / resolution * pi2; 72 | var p1 = rotation * new Vector3(Mathf.Cos(cur), Mathf.Sin(cur), 0f); 73 | var p2 = rotation * new Vector3(Mathf.Cos(next), Mathf.Sin(next), 0f); 74 | GL.Vertex(point + p1 * radius); 75 | GL.Vertex(point + p2 * radius); 76 | } 77 | 78 | GL.End(); 79 | GL.PopMatrix(); 80 | } 81 | 82 | void OnEnable () { 83 | col = GetComponent(); 84 | var mesh = GetComponent().sharedMesh; 85 | vertices = mesh.vertices; 86 | triangles = mesh.triangles; 87 | } 88 | 89 | void CheckInit () { 90 | if(lineMaterial == null) { 91 | Shader shader = Shader.Find(SHADER_PATH); 92 | if (shader == null) return; 93 | lineMaterial = new Material(shader); 94 | lineMaterial.hideFlags = HideFlags.HideAndDontSave; 95 | } 96 | } 97 | 98 | } 99 | 100 | } 101 | 102 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFGarden.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d0d4a64e0a8e4ded9bcfd791a0cd236 3 | timeCreated: 1485686741 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFGrowing.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower.Demo { 6 | 7 | public class PFGrowing : MonoBehaviour { 8 | 9 | [SerializeField] ProceduralFlower flower; 10 | 11 | void Start () { 12 | var root = flower.Build(false); 13 | root.transform.SetParent(transform, false); 14 | root.GetComponent().Animate(); 15 | } 16 | 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFGrowing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 087989cbfa0694d1eb79dc4e10d9be8d 3 | timeCreated: 1485683507 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFTester.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower.Demo { 6 | 7 | public class PFTester : MonoBehaviour { 8 | 9 | public ProceduralFlower flower; 10 | 11 | GameObject child; 12 | 13 | void Start () { 14 | Build(); 15 | } 16 | 17 | public void Build () { 18 | Clear(); 19 | child = flower.Build(); 20 | child.transform.SetParent(transform, false); 21 | } 22 | 23 | public void Clear () { 24 | if(child != null) { 25 | if(Application.isPlaying) { 26 | Destroy(child); 27 | } else { 28 | DestroyImmediate(child); 29 | } 30 | } 31 | } 32 | 33 | } 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Demo/PFTester.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30031e6d088ad4e0c924f4b98e4d0d3f 3 | timeCreated: 1485657609 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 292e5f95ed8c24d038b160dfa9da7ba0 3 | folderAsset: yes 4 | timeCreated: 1483583178 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFShapeInspector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace mattatz.ProceduralFlower { 8 | 9 | [CustomEditor (typeof(PFShape))] 10 | public class PFShapeInspector : Editor { 11 | 12 | public override void OnInspectorGUI () { 13 | base.OnInspectorGUI(); 14 | 15 | if(GUILayout.Button("Open Editor")) { 16 | PFShapeWindow.Open(); 17 | } 18 | } 19 | 20 | } 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFShapeInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 980ab6be03be24927a2e629847c1266f 3 | timeCreated: 1485657589 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFShapeWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using UnityEngine; 7 | using UnityEditor; 8 | 9 | namespace mattatz.ProceduralFlower { 10 | 11 | public class PFShapeWindow : EditorWindow { 12 | 13 | enum Mode { 14 | None, 15 | Select 16 | }; 17 | 18 | Texture grid; 19 | Texture knob; 20 | 21 | static Vector2 size = new Vector2(512f, 512f); 22 | const float unit = 16f; 23 | 24 | Mode mode = Mode.None; 25 | int selected = -1; 26 | 27 | List points; 28 | PFShape shape; 29 | 30 | const string PACKAGE_PATH = "Assets/Packages/ProceduralFlower/"; 31 | 32 | [MenuItem("ProceduralFlower/Window")] 33 | public static void Open () { 34 | var window = GetWindow(typeof(SceneView)); 35 | var icon = AssetDatabase.LoadAssetAtPath(PACKAGE_PATH + "Textures/PFShapeWindow.png"); 36 | window.titleContent = new GUIContent("PF", icon); 37 | window.Focus(); 38 | } 39 | 40 | void Update () { 41 | Repaint(); 42 | } 43 | 44 | void CheckInit () { 45 | var obj = Selection.activeObject; 46 | if(obj && obj as PFShape) { 47 | var current = obj as PFShape; 48 | if(current != shape) { 49 | Load(current); 50 | } 51 | shape = current; 52 | } 53 | 54 | if(grid == null) { 55 | grid = AssetDatabase.LoadAssetAtPath(PACKAGE_PATH + "Textures/Grid.jpg"); 56 | } 57 | 58 | if(knob == null) { 59 | knob = AssetDatabase.LoadAssetAtPath(PACKAGE_PATH + "Textures/Knob.png"); 60 | } 61 | 62 | if(points == null) { 63 | points = new List(); 64 | } 65 | } 66 | 67 | Vector2 Translate (Vector2 p) { 68 | return new Vector2(p.x + size.x * 0.5f, p.y); 69 | } 70 | 71 | void Load (PFShape shp) { 72 | var controls = shp.controls; 73 | points = controls.Select(c => Convert(c)).ToList(); 74 | } 75 | 76 | void Apply () { 77 | shape.controls = GetControls(points); 78 | } 79 | 80 | void DrawHeader() { 81 | var style = new GUIStyle(); 82 | style.fontSize = 15; 83 | if(shape) { 84 | GUI.Label(new Rect(5f, 5f, 80f, 25f), shape.name + ".asset", style); 85 | } else { 86 | GUI.Label(new Rect(5f, 5f, 80f, 25f), "Select Shape asset", style); 87 | } 88 | 89 | if(shape && GUI.Button(new Rect(5f, 30f, 80f, 25f), "Apply")) { 90 | Apply(); 91 | } 92 | 93 | if(GUI.Button(new Rect(5f, 60f, 80f, 25f), "Clear All")) { 94 | points.Clear(); 95 | } 96 | } 97 | 98 | void DrawShape (List mirror, int count, int resolution = 5) { 99 | 100 | // left side 101 | var points = new List(); 102 | for(int i = 0; i <= count; i++) { 103 | var edge = PFCatmullRomSpline.GetCatmullRomPositions( 104 | resolution, 105 | PFShape.GetLoopPoint(mirror, i - 1), 106 | PFShape.GetLoopPoint(mirror, i), 107 | PFShape.GetLoopPoint(mirror, i + 1), 108 | PFShape.GetLoopPoint(mirror, i + 2) 109 | ); 110 | if(i != 0) edge.RemoveAt(0); 111 | points.AddRange(edge); 112 | } 113 | 114 | for(int i = 0, n = points.Count - 1; i < n; i++) { 115 | var from = points[i]; 116 | var to = points[i + 1]; 117 | Handles.DrawLine(Translate(from), Translate(to)); 118 | } 119 | 120 | for(int i = 0, n = points.Count - 1; i < n; i++) { 121 | var from = points[i]; 122 | var to = points[i + 1]; 123 | Handles.DrawLine(Translate(new Vector2(-from.x, from.y)), Translate(new Vector2(-to.x, to.y))); 124 | } 125 | 126 | } 127 | 128 | Vector2 Convert (PFControlPoint c) { 129 | return new Vector2(0.5f - c.width, c.height); 130 | } 131 | 132 | PFControlPoint Convert (Vector2 p) { 133 | return new PFControlPoint(0.5f - p.x, p.y); 134 | } 135 | 136 | List GetControls (List points) { 137 | return points.Select(p => { 138 | return Convert(p); 139 | }).ToList(); 140 | } 141 | 142 | int Pick (Vector2 position) { 143 | float distance = unit / size.x; 144 | return points.FindIndex(p => { 145 | return Vector2.Distance(p, position) <= distance; 146 | }); 147 | } 148 | 149 | bool Contains (Vector2 position) { 150 | return 0.05f < position.x && position.x < 0.5f && 0.05f < position.y && position.y < 0.95f; 151 | } 152 | 153 | void Sort () { 154 | points.Sort((p0, p1) => { 155 | return p0.y.CompareTo(p1.y); 156 | }); 157 | } 158 | 159 | void CatchEvent () { 160 | var mp = Event.current.mousePosition; 161 | var position = new Vector2(mp.x / size.x, mp.y / size.y); 162 | 163 | switch(mode) { 164 | 165 | case Mode.None: 166 | switch(Event.current.type) { 167 | 168 | case EventType.mouseDown: 169 | selected = Pick(position); 170 | if(selected >= 0) { 171 | mode = Mode.Select; 172 | } 173 | break; 174 | 175 | case EventType.mouseUp: 176 | if(Contains(position)) { 177 | points.Add(position); 178 | Sort(); 179 | } 180 | break; 181 | 182 | case EventType.keyUp: 183 | if(selected >= 0 && Input.GetKeyUp(KeyCode.Delete)) { 184 | points.RemoveAt(selected); 185 | } 186 | break; 187 | } 188 | break; 189 | 190 | case Mode.Select: 191 | switch(Event.current.type) { 192 | case EventType.mouseDrag: 193 | if(selected >= 0 && Contains(position)) { 194 | points[selected] = position; 195 | } 196 | break; 197 | case EventType.mouseUp: 198 | Sort(); 199 | mode = Mode.None; 200 | break; 201 | } 202 | 203 | break; 204 | } 205 | } 206 | 207 | void OnGUI () { 208 | CheckInit(); 209 | 210 | size.x = size.y = Mathf.Min(Screen.width, Screen.height); 211 | GUI.DrawTexture(new Rect(0f, 0f, size.x, size.y), grid); 212 | DrawHeader(); 213 | CatchEvent(); 214 | 215 | for(int i = 0, n = points.Count; i < n; i++) { 216 | if(i == selected) { 217 | GUI.color = new Color(0.6f, 0.75f, 1f); 218 | } else { 219 | GUI.color = Color.white; 220 | } 221 | var p = points[i]; 222 | GUI.DrawTexture(new Rect(Vector2.Scale(p, size) - new Vector2(unit, unit) * 0.5f, new Vector2(unit, unit)), knob); 223 | } 224 | GUI.color = Color.white; 225 | 226 | // GUI.Box(new Rect(new Vector2((size.x - unit) * 0.5f, 0f), new Vector2(unit, unit)), "top"); 227 | // GUI.Box(new Rect(new Vector2((size.x - unit) * 0.5f, size.y - unit), new Vector2(unit, unit)), "bottom"); 228 | 229 | if(points.Count >= 2) { 230 | var mirror = PFShape.Mirror(GetControls(points), size.x, size.y); 231 | Handles.color = Color.black; 232 | DrawShape(mirror, points.Count); 233 | } 234 | 235 | } 236 | 237 | } 238 | 239 | } 240 | 241 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFShapeWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c171f6d590db4523bb4789bfa74f516 3 | timeCreated: 1485657577 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFTesterInspector.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace mattatz.ProceduralFlower.Demo { 8 | 9 | [CustomEditor (typeof(PFTester))] 10 | public class PFTesterInspector : Editor { 11 | 12 | public override void OnInspectorGUI () { 13 | base.OnInspectorGUI(); 14 | 15 | var tester = target as PFTester; 16 | if(tester.flower == null) { 17 | return; 18 | } 19 | 20 | EditorGUI.BeginChangeCheck(); 21 | 22 | DisplayFlowerGUI(tester.flower); 23 | 24 | if(EditorGUI.EndChangeCheck()) { 25 | // Undo.RecordObject(flower, "Flower"); 26 | if(Application.isPlaying) { 27 | tester.Build(); 28 | } 29 | } 30 | 31 | } 32 | 33 | void DisplayFlowerGUI (ProceduralFlower flower) { 34 | flower.c = EditorGUILayout.Slider("Petal distance from center", flower.c, 0.001f, 0.05f); 35 | flower.n = EditorGUILayout.IntSlider("# of petals", flower.n, 4, 200); 36 | flower.m = EditorGUILayout.IntSlider("# of buds", flower.m, 0, flower.n); 37 | flower.scale = EditorGUILayout.Slider("Scale", flower.scale, 0.1f, 0.6f); 38 | flower.min = EditorGUILayout.Slider("Min", flower.min, 0.0f, 1f); 39 | flower.angle = EditorGUILayout.Slider("Angle", flower.angle, 30f, 100f); 40 | flower.angleScale = EditorGUILayout.Slider("Angle Scale", flower.angleScale, 0.1f, 1.5f); 41 | flower.offset = EditorGUILayout.Slider("Offset", flower.offset, 0f, 1f); 42 | flower.height = EditorGUILayout.Slider("Height", flower.height, 1f, 10f); 43 | flower.leafCount = EditorGUILayout.IntSlider("# of leafs", flower.leafCount, 0, 10); 44 | flower.leafScaleRange.x = EditorGUILayout.Slider("Leaf scale range min", flower.leafScaleRange.x, 0.1f, 0.9f); 45 | flower.leafScaleRange.y = EditorGUILayout.Slider("Leaf scale range max", flower.leafScaleRange.y, flower.leafScaleRange.x, 0.95f); 46 | flower.leafSegmentRange.x = EditorGUILayout.Slider("Leaf segment range min", flower.leafSegmentRange.x, 0.1f, 0.9f); 47 | flower.leafSegmentRange.y = EditorGUILayout.Slider("Leaf segment range max", flower.leafSegmentRange.y, flower.leafSegmentRange.x, 0.95f); 48 | } 49 | 50 | } 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Editor/PFTesterInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1671af6f37ddb4e3bb8149ba72dadc23 3 | timeCreated: 1485657622 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53c5150ff904e4962933e5ef9642bf3e 3 | folderAsset: yes 4 | timeCreated: 1485656238 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Blue.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: e5e89a2728f6312499f8fd801e9f5112, type: 3} 12 | m_Name: Blue 13 | m_EditorClassIdentifier: 14 | budData: 15 | shape: {fileID: 11400000, guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c, type: 2} 16 | material: {fileID: 2100000, guid: 742d4d64b794046909d4d9bfcdd98729, type: 2} 17 | mesh: {fileID: 0} 18 | shadowCastingMode: 2 19 | receiveShadows: 1 20 | petalData: 21 | shape: {fileID: 11400000, guid: a546c42e8041a417498ec6a02732572c, type: 2} 22 | material: {fileID: 2100000, guid: 747c6239b309443eea0882b1dc0a5a1c, type: 2} 23 | mesh: {fileID: 0} 24 | shadowCastingMode: 2 25 | receiveShadows: 1 26 | leafData: 27 | shape: {fileID: 11400000, guid: 35af5a156253e4104a693c2c6fcea8f1, type: 2} 28 | material: {fileID: 2100000, guid: 23eff92748469457daadc9ad60238629, type: 2} 29 | mesh: {fileID: 0} 30 | shadowCastingMode: 1 31 | receiveShadows: 1 32 | stemData: 33 | material: {fileID: 2100000, guid: d6d027743c4004c87a7a73830432c83e, type: 2} 34 | wresolution: 10 35 | hresolution: 8 36 | radius: 0.012 37 | bend: 0.15 38 | shadowCastingMode: 1 39 | receiveShadows: 1 40 | c: 0.0105 41 | n: 70 42 | m: 8 43 | scale: 0.328 44 | min: 0.1 45 | angle: 87.3 46 | angleScale: 0.91 47 | offset: 0 48 | height: 2.5 49 | leafCount: 6 50 | leafScaleRange: {x: 0.2, y: 0.823} 51 | leafSegmentRange: {x: 0.18, y: 0.92} 52 | seed: 0 53 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Blue.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4533a7fa8a91f4269a5ebf7d073fbe34 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Example.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Scripts/Flowers/Example.asset -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Example.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cca47ea6c7a4446eabbecc4cc96035df 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Orange.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: e5e89a2728f6312499f8fd801e9f5112, type: 3} 12 | m_Name: Orange 13 | m_EditorClassIdentifier: 14 | budData: 15 | shape: {fileID: 11400000, guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c, type: 2} 16 | material: {fileID: 2100000, guid: 17314adb600a243d19be41279b24c116, type: 2} 17 | mesh: {fileID: 0} 18 | shadowCastingMode: 2 19 | receiveShadows: 1 20 | petalData: 21 | shape: {fileID: 11400000, guid: a546c42e8041a417498ec6a02732572c, type: 2} 22 | material: {fileID: 2100000, guid: 6326232e0aa8a440f9bbc14a778d2592, type: 2} 23 | mesh: {fileID: 0} 24 | shadowCastingMode: 2 25 | receiveShadows: 1 26 | leafData: 27 | shape: {fileID: 11400000, guid: 35af5a156253e4104a693c2c6fcea8f1, type: 2} 28 | material: {fileID: 2100000, guid: 23eff92748469457daadc9ad60238629, type: 2} 29 | mesh: {fileID: 0} 30 | shadowCastingMode: 1 31 | receiveShadows: 1 32 | stemData: 33 | material: {fileID: 2100000, guid: d6d027743c4004c87a7a73830432c83e, type: 2} 34 | wresolution: 10 35 | hresolution: 8 36 | radius: 0.012 37 | bend: 0.15 38 | shadowCastingMode: 1 39 | receiveShadows: 1 40 | c: 0.0105 41 | n: 70 42 | m: 8 43 | scale: 0.328 44 | min: 0.1 45 | angle: 87.3 46 | angleScale: 0.91 47 | offset: 0 48 | height: 2.5 49 | leafCount: 6 50 | leafScaleRange: {x: 0.2, y: 0.823} 51 | leafSegmentRange: {x: 0.18, y: 0.92} 52 | seed: 0 53 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Orange.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ec3acfb5bf86d4cd4be2653329b5eb0a 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Purple.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: e5e89a2728f6312499f8fd801e9f5112, type: 3} 12 | m_Name: Purple 13 | m_EditorClassIdentifier: 14 | budData: 15 | shape: {fileID: 11400000, guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c, type: 2} 16 | material: {fileID: 2100000, guid: 7f426c21fd5ce486a9be36440b93d5af, type: 2} 17 | mesh: {fileID: 0} 18 | shadowCastingMode: 2 19 | receiveShadows: 1 20 | petalData: 21 | shape: {fileID: 11400000, guid: a546c42e8041a417498ec6a02732572c, type: 2} 22 | material: {fileID: 2100000, guid: c1e87b15383f44dd09e0e9680b1a79a1, type: 2} 23 | mesh: {fileID: 0} 24 | shadowCastingMode: 2 25 | receiveShadows: 1 26 | leafData: 27 | shape: {fileID: 11400000, guid: 35af5a156253e4104a693c2c6fcea8f1, type: 2} 28 | material: {fileID: 2100000, guid: 23eff92748469457daadc9ad60238629, type: 2} 29 | mesh: {fileID: 0} 30 | shadowCastingMode: 1 31 | receiveShadows: 1 32 | stemData: 33 | material: {fileID: 2100000, guid: d6d027743c4004c87a7a73830432c83e, type: 2} 34 | wresolution: 10 35 | hresolution: 8 36 | radius: 0.012 37 | bend: 0.15 38 | shadowCastingMode: 1 39 | receiveShadows: 1 40 | c: 0.0105 41 | n: 70 42 | m: 8 43 | scale: 0.328 44 | min: 0.1 45 | angle: 87.3 46 | angleScale: 0.91 47 | offset: 0 48 | height: 2.5 49 | leafCount: 6 50 | leafScaleRange: {x: 0.2, y: 0.823} 51 | leafSegmentRange: {x: 0.18, y: 0.92} 52 | seed: 0 53 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Purple.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 009313a1218c64466928c8dafcbdd9e9 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Red.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: e5e89a2728f6312499f8fd801e9f5112, type: 3} 12 | m_Name: Red 13 | m_EditorClassIdentifier: 14 | budData: 15 | shape: {fileID: 11400000, guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c, type: 2} 16 | material: {fileID: 2100000, guid: ce87fea90bdaf4fc29712567d3ac1417, type: 2} 17 | mesh: {fileID: 0} 18 | shadowCastingMode: 2 19 | receiveShadows: 1 20 | petalData: 21 | shape: {fileID: 11400000, guid: a546c42e8041a417498ec6a02732572c, type: 2} 22 | material: {fileID: 2100000, guid: 5a1556cbfceadd34cb0cb0b97f57c98c, type: 2} 23 | mesh: {fileID: 0} 24 | shadowCastingMode: 2 25 | receiveShadows: 1 26 | leafData: 27 | shape: {fileID: 11400000, guid: 35af5a156253e4104a693c2c6fcea8f1, type: 2} 28 | material: {fileID: 2100000, guid: 23eff92748469457daadc9ad60238629, type: 2} 29 | mesh: {fileID: 0} 30 | shadowCastingMode: 1 31 | receiveShadows: 1 32 | stemData: 33 | material: {fileID: 2100000, guid: d6d027743c4004c87a7a73830432c83e, type: 2} 34 | wresolution: 10 35 | hresolution: 8 36 | radius: 0.012 37 | bend: 0.15 38 | shadowCastingMode: 1 39 | receiveShadows: 1 40 | c: 0.0105 41 | n: 70 42 | m: 12 43 | scale: 0.328 44 | min: 0.1 45 | angle: 87.3 46 | angleScale: 0.91 47 | offset: 0 48 | height: 2.5 49 | leafCount: 6 50 | leafScaleRange: {x: 0.2, y: 0.823} 51 | leafSegmentRange: {x: 0.18, y: 0.92} 52 | seed: 0 53 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Red.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75cc58ac7e2a44a08ae7fae102f9bd33 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Yellow.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: e5e89a2728f6312499f8fd801e9f5112, type: 3} 12 | m_Name: Yellow 13 | m_EditorClassIdentifier: 14 | budData: 15 | shape: {fileID: 11400000, guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c, type: 2} 16 | material: {fileID: 2100000, guid: fd92fd79991e142a98a5c716a44cbee0, type: 2} 17 | mesh: {fileID: 0} 18 | shadowCastingMode: 2 19 | receiveShadows: 1 20 | petalData: 21 | shape: {fileID: 11400000, guid: a546c42e8041a417498ec6a02732572c, type: 2} 22 | material: {fileID: 2100000, guid: 334aac84e9abd4d919c9fb1cfb3489a0, type: 2} 23 | mesh: {fileID: 0} 24 | shadowCastingMode: 2 25 | receiveShadows: 1 26 | leafData: 27 | shape: {fileID: 11400000, guid: 35af5a156253e4104a693c2c6fcea8f1, type: 2} 28 | material: {fileID: 2100000, guid: 23eff92748469457daadc9ad60238629, type: 2} 29 | mesh: {fileID: 0} 30 | shadowCastingMode: 1 31 | receiveShadows: 1 32 | stemData: 33 | material: {fileID: 2100000, guid: d6d027743c4004c87a7a73830432c83e, type: 2} 34 | wresolution: 10 35 | hresolution: 8 36 | radius: 0.012 37 | bend: 0.15 38 | shadowCastingMode: 1 39 | receiveShadows: 1 40 | c: 0.0105 41 | n: 70 42 | m: 8 43 | scale: 0.328 44 | min: 0.1 45 | angle: 87.3 46 | angleScale: 0.91 47 | offset: 0 48 | height: 2.5 49 | leafCount: 6 50 | leafScaleRange: {x: 0.2, y: 0.823} 51 | leafSegmentRange: {x: 0.18, y: 0.92} 52 | seed: 0 53 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Flowers/Yellow.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 681a9f70afc404f4a91c044bdc22e103 3 | timeCreated: 1485656247 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFCatmullRomSpline.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | using UnityEngine; 5 | 6 | namespace mattatz.ProceduralFlower { 7 | 8 | public class PFCatmullRomSpline { 9 | 10 | public static int Loop(int index, int length) { 11 | if (index < 0) { 12 | index = length - 1; 13 | } 14 | 15 | if (index > length) { 16 | index = 1; 17 | } else if (index > length - 1) { 18 | index = 0; 19 | } 20 | 21 | return index; 22 | } 23 | 24 | public static List GetCatmullRomPositions(int count, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3) { 25 | var points = new List(); 26 | 27 | float inv = 1f / (count - 1); 28 | for (int i = 0; i < count; i++) { 29 | var p = GetCatmullRomPosition(i * inv, p0, p1, p2, p3); 30 | points.Add(p); 31 | } 32 | 33 | return points; 34 | } 35 | 36 | // Returns a position between 4 Vector3 with Catmull-Rom spline algorithm 37 | //http://www.iquilezles.org/www/articles/minispline/minispline.htm 38 | public static Vector3 GetCatmullRomPosition(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3) { 39 | //The coefficients of the cubic polynomial (except the 0.5f * which I added later for performance) 40 | Vector3 a = 2f * p1; 41 | Vector3 b = p2 - p0; 42 | Vector3 c = 2f * p0 - 5f * p1 + 4f * p2 - p3; 43 | Vector3 d = -p0 + 3f * p1 - 3f * p2 + p3; 44 | 45 | //The cubic polynomial: a + b * t + c * t^2 + d * t^3 46 | return 0.5f * (a + (b * t) + (c * t * t) + (d * t * t * t)); 47 | } 48 | } 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFCatmullRomSpline.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b993f9ca18c9e4e43bb8046cfecec61e 3 | timeCreated: 1482731027 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFCombine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using UnityEngine; 7 | 8 | namespace mattatz.ProceduralFlower { 9 | 10 | public class PFCombine { 11 | 12 | public static Mesh Combine (ProceduralFlower flower, PFPartType type = PFPartType.None) { 13 | var root = flower.Build(); 14 | var filters = new List(); 15 | Traverse(root.GetComponent(), filters); 16 | 17 | if(type != PFPartType.None) { 18 | filters = filters.FindAll(filter => filter.GetComponent().Type == type).ToList(); 19 | } 20 | 21 | var combine = new CombineInstance[filters.Count]; 22 | for(int i = 0, n = filters.Count; i < n; i++) { 23 | combine[i].mesh = filters[i].sharedMesh; 24 | combine[i].transform = filters[i].transform.localToWorldMatrix; 25 | } 26 | 27 | GameObject.Destroy(root); 28 | 29 | var mesh = new Mesh(); 30 | mesh.CombineMeshes(combine); 31 | return mesh; 32 | } 33 | 34 | static void Traverse (PFPart root, List filters) { 35 | var filter = root.GetComponent(); 36 | if (filter != null) filters.Add(filter); 37 | 38 | root.children.ForEach(child => { 39 | Traverse(child.part, filters); 40 | }); 41 | } 42 | 43 | } 44 | 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFCombine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1ae724724f98074fbd5010e77d7535c 3 | timeCreated: 1485745987 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFControlPoint.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower { 6 | 7 | [System.Serializable] 8 | public class PFControlPoint { 9 | public float width; 10 | public float height; 11 | 12 | public PFControlPoint (float width, float height) { 13 | this.width = Mathf.Clamp01(width); 14 | this.height = Mathf.Clamp01(height); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFControlPoint.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40aab132292cd46d886393faecb36b1d 3 | timeCreated: 1485657431 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFLeaf.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | using UnityEngine; 6 | 7 | namespace mattatz.ProceduralFlower { 8 | 9 | [ExecuteInEditMode] 10 | public class PFLeaf : MonoBehaviour { 11 | 12 | [SerializeField] PFShape shape; 13 | 14 | void Start() { 15 | GetComponent().mesh = shape.Build(); 16 | } 17 | 18 | } 19 | 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFLeaf.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ff83b612420e4f62a41ac3cbb3b5304 3 | timeCreated: 1485657431 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFPart.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower { 6 | 7 | [System.Serializable] 8 | public enum PFPartType { 9 | None, 10 | Petal, 11 | Stover 12 | }; 13 | 14 | public class PFPart : MonoBehaviour { 15 | 16 | const string PROPERTY_COLOR = "_Color2"; 17 | const string PROPERTY_BEND = "_Bend"; 18 | const string PROPERTY_T = "_T"; 19 | 20 | public PFPartType Type { 21 | get { 22 | return type; 23 | } 24 | } 25 | 26 | MeshRenderer rnd { 27 | get { 28 | if(_renderer == null) { 29 | _renderer = GetComponent(); 30 | } 31 | return _renderer; 32 | } 33 | } 34 | 35 | MaterialPropertyBlock block { 36 | get { 37 | if(_block == null) { 38 | _block = new MaterialPropertyBlock(); 39 | rnd.GetPropertyBlock(_block); 40 | } 41 | return _block; 42 | } 43 | } 44 | 45 | MaterialPropertyBlock _block; 46 | MeshRenderer _renderer; 47 | public List children = new List(); 48 | 49 | public readonly float EPSILON = 0.1f; 50 | [SerializeField] PFPartType type = PFPartType.None; 51 | float multiplySpeed = 1f; 52 | float speed = 1f; 53 | 54 | bool animating = false; 55 | float ticker = 0f; 56 | 57 | void Update () { 58 | if(animating) { 59 | ticker += Time.deltaTime * multiplySpeed * speed; 60 | Fade(ticker); 61 | children.ForEach(anim => anim.Animate(speed, ticker)); 62 | if(ticker > 1f + EPSILON) { 63 | animating = false; 64 | } 65 | } 66 | } 67 | 68 | public void SetType (PFPartType tp) { 69 | type = tp; 70 | } 71 | 72 | public void Colorize (Color color) { 73 | if(type != PFPartType.None) { 74 | block.SetColor(PROPERTY_COLOR, color); 75 | rnd.SetPropertyBlock(block); 76 | } 77 | } 78 | 79 | public void Bend (float bend) { 80 | if(type != PFPartType.None) { 81 | block.SetFloat(PROPERTY_BEND, bend); 82 | rnd.SetPropertyBlock(block); 83 | } 84 | } 85 | 86 | public void Fade (float t) { 87 | if(type != PFPartType.None) { 88 | block.SetFloat(PROPERTY_T, t); 89 | rnd.SetPropertyBlock(block); 90 | } 91 | } 92 | 93 | public void SetSpeed (float m) { 94 | multiplySpeed = m; 95 | } 96 | 97 | public void Add (PFPart part, float ratio) { 98 | children.Add(new PFSegment(part, ratio)); 99 | } 100 | 101 | public void Animate (float s = 1f) { 102 | speed = s; 103 | animating = true; 104 | ticker = 0f; 105 | } 106 | 107 | [System.Serializable] 108 | public class PFSegment { 109 | public readonly PFPart part; 110 | public readonly float ratio; 111 | 112 | bool animating = false; 113 | 114 | public PFSegment (PFPart p, float r) { 115 | part = p; 116 | ratio = r; 117 | } 118 | 119 | public void Animate (float speed, float r) { 120 | if(!animating && r <= ratio) { 121 | part.Animate(speed); 122 | } 123 | } 124 | 125 | } 126 | 127 | } 128 | 129 | } 130 | 131 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFPart.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a464c5aa776742a2944327ff7d15205 3 | timeCreated: 1485683621 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFRandom.cs: -------------------------------------------------------------------------------- 1 | using Random = System.Random; 2 | 3 | using UnityEngine; 4 | 5 | namespace mattatz.ProceduralFlower { 6 | 7 | public class PFRandom { 8 | 9 | Random rnd; 10 | 11 | public PFRandom(int seed) { 12 | rnd = new Random(seed); 13 | } 14 | 15 | public float Sample01() { 16 | return (float)rnd.NextDouble(); 17 | } 18 | 19 | public int SampleRange(int a, int b) { 20 | var t = Sample01(); 21 | return Mathf.FloorToInt(Mathf.Lerp(a, b, t)); 22 | } 23 | 24 | public float SampleRange(float a, float b) { 25 | var t = Sample01(); 26 | return Mathf.Lerp(a, b, t); 27 | } 28 | 29 | public Vector2 SampleUnitCircle () { 30 | var x = (Sample01() - 0.5f) * 2f; 31 | var y = (Sample01() - 0.5f) * 2f; 32 | return new Vector2(x, y); 33 | } 34 | 35 | public Vector3 SampleUnitSphere () { 36 | var x = (Sample01() - 0.5f) * 2f; 37 | var y = (Sample01() - 0.5f) * 2f; 38 | var z = (Sample01() - 0.5f) * 2f; 39 | return new Vector3(x, y, z); 40 | } 41 | 42 | } 43 | 44 | } 45 | 46 | 47 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFRandom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75458afb71035419a860d2bebab4b732 3 | timeCreated: 1485657431 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFShape.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | using UnityEngine; 6 | 7 | namespace mattatz.ProceduralFlower { 8 | 9 | [CreateAssetMenu(menuName = "ProceduralFlower/Shape")] 10 | public class PFShape : ScriptableObject { 11 | 12 | public List controls; 13 | 14 | [SerializeField] float size = 1f; 15 | [SerializeField] int numberOfVerticesOnOneSide = 20; 16 | [SerializeField] int resolution = 2; 17 | [SerializeField] float noiseDepth = 0.25f; 18 | [SerializeField] Vector2 noiseScale = Vector2.zero; 19 | 20 | public Mesh Build () { 21 | return Build(size, controls, numberOfVerticesOnOneSide, resolution, noiseDepth, noiseScale); 22 | } 23 | 24 | public static List Mirror (List controls, float height, float width) { 25 | var bottom = new Vector3(0f, 0f, 0f); 26 | var top = new Vector3(0f, height, 0f); 27 | 28 | var points = new List(); 29 | points.Add(bottom); 30 | points.AddRange(controls.Select(p => new Vector3(p.width * width, p.height * height, 0f))); 31 | points.Add(top); 32 | 33 | var reverse = controls.ToList(); 34 | reverse.Reverse(); 35 | points.AddRange(reverse.Select(p => new Vector3(-p.width * width, p.height * height, 0f))); 36 | 37 | return points; 38 | } 39 | 40 | public static Mesh Build (float size, List controls, int numberOfVerticesOnOneSide = 20, int resolution = 2, float noiseDepth = 0.25f, Vector2 noiseScale = default(Vector2), Vector2 noiseOffset = default(Vector2)) { 41 | var mesh = new Mesh(); 42 | 43 | resolution = Mathf.Max(1, resolution); 44 | 45 | if(controls.Count < 1) { 46 | throw new UnityException("control points size is not enough"); 47 | } 48 | 49 | int controlSize = controls.Count; 50 | 51 | var counts = GetCounts(controls, numberOfVerticesOnOneSide); 52 | int countOnEdge = counts.Aggregate((acc, next) => { 53 | return acc + next; 54 | }); 55 | 56 | var bottom = new Vector3(0f, 0f, 0f); 57 | var top = new Vector3(0f, size, 0f); 58 | 59 | var points = new List(); 60 | points.Add(bottom); 61 | points.AddRange(controls.Select(p => new Vector3(p.width * size, p.height * size, 0f))); 62 | points.Add(top); 63 | 64 | var reverse = controls.ToList(); 65 | reverse.Reverse(); 66 | points.AddRange(reverse.Select(p => new Vector3(-p.width * size, p.height * size, 0f))); 67 | 68 | var vertices = new List(); 69 | var uv = new List(); 70 | 71 | // left side 72 | for(int i = 0; i < resolution; i++) { 73 | var r = (float)(resolution - i) / resolution; 74 | for(int c = 0; c <= controlSize; c++) { 75 | var edge = PFCatmullRomSpline.GetCatmullRomPositions( 76 | counts[c], 77 | GetEdge(GetLoopPoint(points, c - 1), r), 78 | GetEdge(GetLoopPoint(points, c), r), 79 | GetEdge(GetLoopPoint(points, c + 1), r), 80 | GetEdge(GetLoopPoint(points, c + 2), r) 81 | ); 82 | vertices.AddRange(edge); 83 | uv.AddRange(edge.Select(v => { 84 | return new Vector2(v.x / size, v.y / size); 85 | })); 86 | } 87 | } 88 | 89 | // midrib 90 | for(int c = 0; c <= controlSize; c++) { 91 | var edge = PFCatmullRomSpline.GetCatmullRomPositions( 92 | counts[c], 93 | GetEdge(GetLoopPoint(points, c - 1), 0f), 94 | GetEdge(GetLoopPoint(points, c), 0f), 95 | GetEdge(GetLoopPoint(points, c + 1), 0f), 96 | GetEdge(GetLoopPoint(points, c + 2), 0f) 97 | ); 98 | vertices.AddRange(edge); 99 | uv.AddRange(edge.Select(v => { 100 | return new Vector2(0f, v.y / size); 101 | })); 102 | } 103 | 104 | // right side 105 | for(int i = 0; i < resolution; i++) { 106 | var r = -(float)(i + 1) / resolution; 107 | for(int c = 0; c <= controlSize; c++) { 108 | var edge = PFCatmullRomSpline.GetCatmullRomPositions( 109 | counts[c], 110 | GetEdge(GetLoopPoint(points, c - 1), r), 111 | GetEdge(GetLoopPoint(points, c), r), 112 | GetEdge(GetLoopPoint(points, c + 1), r), 113 | GetEdge(GetLoopPoint(points, c + 2), r) 114 | ); 115 | vertices.AddRange(edge); 116 | uv.AddRange(edge.Select(v => { 117 | return new Vector2(v.x / size, v.y / size); 118 | })); 119 | } 120 | } 121 | 122 | var triangles = new List(); 123 | 124 | // left side faces 125 | for(int i = 0, n = resolution; i < n; i++) { 126 | var offset = i * countOnEdge; 127 | for(int j = 0; j < countOnEdge - 1; j++) { 128 | var a = j + offset; 129 | var b = a + 1; 130 | var c = a + countOnEdge; 131 | var d = b + countOnEdge; 132 | triangles.Add(a); triangles.Add(b); triangles.Add(c); 133 | triangles.Add(b); triangles.Add(d); triangles.Add(c); 134 | } 135 | } 136 | 137 | // right side faces 138 | for(int i = 0, n = resolution; i < n; i++) { 139 | var offset = (i + resolution) * countOnEdge; 140 | for(int j = 0; j < countOnEdge - 1; j++) { 141 | var a = j + offset; 142 | var b = a + 1; 143 | var c = a + countOnEdge; 144 | var d = b + countOnEdge; 145 | triangles.Add(a); triangles.Add(d); triangles.Add(c); 146 | triangles.Add(b); triangles.Add(d); triangles.Add(a); 147 | } 148 | } 149 | 150 | var noffset = noiseOffset + new Vector2(size, size); 151 | mesh.vertices = vertices.Select(v => { 152 | return new Vector3(v.x, v.y, v.y * noiseDepth * Depth(v, noffset, noiseScale)); 153 | }).ToArray(); 154 | mesh.uv = uv.ToArray(); 155 | mesh.triangles = triangles.ToArray(); 156 | mesh.RecalculateBounds(); 157 | mesh.RecalculateNormals(); 158 | 159 | return mesh; 160 | } 161 | 162 | static int[] GetCounts (List controls, int count) { 163 | var controlSize = controls.Count; 164 | 165 | var points = controls.Select(c => new Vector2(c.width, c.height)).ToList(); 166 | 167 | var acc = 0f; 168 | var lengthes = new float[controlSize + 1]; 169 | for(int i = 0, n = points.Count; i <= n; i++) { 170 | var l = 0f; 171 | if(i == 0) { 172 | l = points[0].magnitude; 173 | } else if(i < n) { 174 | l = (points[i] - points[i - 1]).magnitude; 175 | } else { 176 | l = (new Vector2(0f, 1f) - points[i - 1]).magnitude; 177 | } 178 | acc += l; 179 | lengthes[i] = l; 180 | } 181 | 182 | return lengthes.Select(l => Mathf.FloorToInt((l / acc) * count)).ToArray(); 183 | } 184 | 185 | static Vector2 GetEdge (Vector2 p, float ratio) { 186 | return new Vector2(p.x * ratio, p.y); 187 | } 188 | 189 | public static Vector2 GetLoopPoint (List points, int index) { 190 | if(index < 0) { 191 | return GetLoopPoint(points, points.Count + index); 192 | } else if(index >= points.Count) { 193 | return GetLoopPoint(points, index - points.Count); 194 | } 195 | return points[index]; 196 | } 197 | 198 | static float Depth (Vector3 v, Vector2 noiseOffset, Vector2 noiseScale) { 199 | return Mathf.PerlinNoise((v.x + noiseOffset.x) * noiseScale.x, (v.y + noiseOffset.y) * noiseScale.y) - 0.5f; 200 | } 201 | 202 | 203 | } 204 | 205 | } 206 | 207 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFShape.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4aecb51ef6264d37abdf1c60c6b502f 3 | timeCreated: 1485657431 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFStem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | using UnityEngine; 7 | using Random = UnityEngine.Random; 8 | 9 | namespace mattatz.ProceduralFlower { 10 | 11 | public class Point { 12 | public Vector3 position; 13 | public Quaternion rotation; 14 | public Point (Vector3 p, Quaternion r) { 15 | position = p; 16 | rotation = r; 17 | } 18 | } 19 | 20 | public class PFStem { 21 | 22 | public Point Tip { get { return tip; } } 23 | public List Segments { get { return segments; } } 24 | 25 | public int wresolution = 10; 26 | public int hresolution = 4; 27 | public float radius = 0.05f; 28 | 29 | Point tip; 30 | List segments; 31 | 32 | public PFStem () {} 33 | 34 | public PFStem (int wresol, int hresol, float r) { 35 | wresolution = wresol; 36 | hresolution = hresol; 37 | radius = r; 38 | } 39 | 40 | public Mesh Build (List controls) { 41 | return Build(controls, wresolution, hresolution, radius, (float r) => 1f); 42 | } 43 | 44 | public Mesh Build (List controls, Func f) { 45 | return Build(controls, wresolution, hresolution, radius, f); 46 | } 47 | 48 | Mesh Build (List controls, int wresolution, int hresolution, float radius, Func f) { 49 | 50 | controls = controls.ToList(); 51 | if(controls.Count < 4) { 52 | throw new UnityException("control size is not enough"); 53 | } 54 | 55 | Vector3 first = controls[0], second = controls[1]; 56 | Vector3 blast = controls[controls.Count - 2], last = controls[controls.Count - 1]; 57 | 58 | controls.Insert(0, first + (first - second).normalized * 0.25f); 59 | controls.Add(last + (last - blast).normalized * 0.25f); 60 | 61 | var cores = new List(); 62 | for(int i = 1, n = controls.Count - 2; i < n; i++) { 63 | var tmp = PFCatmullRomSpline.GetCatmullRomPositions(hresolution, controls[i - 1], controls[i], controls[i + 1], controls[i + 2]); 64 | if(i != 1) { 65 | tmp.RemoveAt(0); 66 | } 67 | cores.AddRange(tmp); 68 | } 69 | 70 | var vertices = new List(); 71 | var uv = new List(); 72 | var triangles = new List(); 73 | 74 | var mesh = new Mesh(); 75 | 76 | var circle = new List(); 77 | for(int i = 0; i < wresolution; i++) { 78 | var r = ((float)i / wresolution) * (Mathf.PI * 2f); 79 | var cos = Mathf.Cos(r) * radius; 80 | var sin = Mathf.Sin(r) * radius; 81 | circle.Add(new Vector3(cos, sin, 0f)); 82 | } 83 | 84 | vertices.Add(cores.First()); 85 | Vector3 right = Vector3.right; 86 | bool inverse = false; 87 | 88 | segments = new List(); 89 | 90 | for(int i = 0, n = cores.Count; i < n; i++) { 91 | var core = cores[i]; 92 | var v = (float)i / (n - 1); 93 | 94 | if(i == 0) { 95 | // first segment 96 | for(int j = 0; j < wresolution; j++) { 97 | triangles.Add(0); triangles.Add((j + 1) % wresolution + 1); triangles.Add(j + 1); 98 | } 99 | 100 | var next = cores[i + 1]; 101 | var dir = (next - core).normalized; 102 | right = (Quaternion.LookRotation(dir) * Vector3.right).normalized; 103 | 104 | uv.Add(new Vector2(0.5f, 0f)); 105 | } 106 | 107 | var offset = i * wresolution + 1; 108 | 109 | if(i < n - 1) { 110 | var next = cores[i + 1]; 111 | var dir = (next - core).normalized; 112 | var cr = (Quaternion.LookRotation(dir) * Vector3.right).normalized; 113 | if(Vector3.Dot(right, cr) < 0f) inverse = !inverse; 114 | 115 | var rotation = AddCircle(vertices, core, circle, f(v), dir, inverse); 116 | segments.Add(new Point(core, rotation)); 117 | 118 | right = cr; 119 | 120 | for(int j = 0; j < wresolution; j++) { 121 | var a = offset + j; 122 | var b = offset + (j + 1) % wresolution; 123 | var c = a + wresolution; 124 | var d = b + wresolution; 125 | triangles.Add(a); triangles.Add(b); triangles.Add(c); 126 | triangles.Add(c); triangles.Add(b); triangles.Add(d); 127 | 128 | var u = (float)j / (wresolution - 1); 129 | uv.Add(new Vector2(u, v)); 130 | } 131 | 132 | } else { 133 | // last segment 134 | var prev = cores[i - 1]; 135 | var dir = (core - prev).normalized; 136 | var cr = (Quaternion.LookRotation(dir) * Vector3.right).normalized; 137 | if(Vector3.Dot(right, cr) < 0f) inverse = !inverse; 138 | 139 | var rotation = AddCircle(vertices, core, circle, f(v), dir, inverse); 140 | tip = new Point(core, rotation); 141 | 142 | vertices.Add(cores.Last()); 143 | uv.Add(new Vector2(0.5f, 1f)); 144 | int m = vertices.Count - 1; 145 | 146 | for(int j = 0; j < wresolution; j++) { 147 | triangles.Add(m); 148 | triangles.Add(offset + j); 149 | triangles.Add(offset + ((j + 1) % wresolution)); 150 | 151 | var u = (float)j / (wresolution - 1); 152 | uv.Add(new Vector2(u, v)); 153 | } 154 | } 155 | 156 | } 157 | 158 | mesh.vertices = vertices.ToArray(); 159 | mesh.uv = uv.ToArray(); 160 | mesh.triangles = triangles.ToArray(); 161 | 162 | mesh.RecalculateBounds(); 163 | mesh.RecalculateNormals(); 164 | 165 | return mesh; 166 | } 167 | 168 | static Quaternion AddCircle (List vertices, Vector3 core, List circle, float radius, Vector3 dir, bool inverse) { 169 | Quaternion q; 170 | if(inverse) { 171 | q = Quaternion.AngleAxis(180f, dir) * Quaternion.LookRotation(dir); 172 | circle.ForEach(c => { 173 | vertices.Add(core + q * (c * radius)); 174 | }); 175 | } else { 176 | q = Quaternion.LookRotation(dir); 177 | circle.ForEach(c => { 178 | vertices.Add(core + q * (c * radius)); 179 | }); 180 | } 181 | return q; 182 | } 183 | 184 | } 185 | 186 | } 187 | 188 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/PFStem.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8eaacfb54828542a1ab454014ab34b54 3 | timeCreated: 1485657431 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/ProceduralFlower.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering; 3 | using Random = UnityEngine.Random; 4 | 5 | using System; 6 | using System.Linq; 7 | using System.Collections; 8 | using System.Collections.Generic; 9 | 10 | namespace mattatz.ProceduralFlower { 11 | 12 | [CreateAssetMenu(menuName = "ProceduralFlower/Flower")] 13 | public class ProceduralFlower : ScriptableObject { 14 | 15 | [SerializeField] ShapeData budData; 16 | [SerializeField] ShapeData petalData; 17 | [SerializeField] ShapeData leafData; 18 | [SerializeField] StemData stemData; 19 | 20 | #region Flower Settings 21 | 22 | // [SerializeField, Range(137.4f, 137.6f)] float alpha = 137.5f; 23 | [HideInInspector] public float c = 0.01f; 24 | [HideInInspector] public int n = 70; 25 | [HideInInspector] public int m = 8; 26 | [HideInInspector] public float scale = 0.328f; 27 | [HideInInspector] public float min = 0.1f; 28 | [HideInInspector] public float angle = 87f; 29 | [HideInInspector] public float angleScale = 0.92f; 30 | [HideInInspector] public float offset = 0f; 31 | 32 | #endregion 33 | 34 | [HideInInspector] public float height = 2f; 35 | [HideInInspector] public int leafCount = 6; 36 | [HideInInspector] public Vector2 leafScaleRange = new Vector2(0.2f, 0.825f); 37 | [HideInInspector] public Vector2 leafSegmentRange = new Vector2(0.2f, 0.92f); 38 | 39 | #region Random 40 | 41 | [SerializeField] int seed = 0; 42 | PFRandom rand; 43 | 44 | #endregion 45 | 46 | public GameObject Build (bool visible = true) { 47 | rand = new PFRandom(seed); 48 | 49 | budData.Init(); 50 | petalData.Init(); 51 | leafData.Init(); 52 | stemData.Init(); 53 | 54 | var root = CreateStem("Root", stemData.stem, stemData.shadowCastingMode, stemData.receiveShadows, (float r) => 1f, height, stemData.bend, visible); 55 | var stemPart = root.GetComponent(); 56 | 57 | var segments = stemData.stem.Segments; 58 | var offset = leafSegmentRange.x * segments.Count; 59 | var len = (leafSegmentRange.y - leafSegmentRange.x) * segments.Count; 60 | var size = 1f; 61 | 62 | for (int i = 0; i < leafCount; i++) { 63 | var r = (float)(i + 1) / (leafCount + 1); 64 | int index = Mathf.Min(Mathf.FloorToInt(len * r + offset), segments.Count - 2); 65 | var from = segments[index]; 66 | var to = segments[index + 1]; 67 | var dir = (to.position - from.position).normalized; 68 | var leaf = CreateLeaf(segments[index], dir, (i % 4) * 90f + rand.SampleRange(-20f, 20f), visible); 69 | leaf.transform.SetParent(root.transform); 70 | 71 | // lower leaf becomes bigger than upper one. 72 | size = rand.SampleRange(size, 1f - (r * 0.5f)); 73 | leaf.transform.localScale *= Mathf.Lerp(leafScaleRange.x, leafScaleRange.y, size); 74 | 75 | var leafPart = leaf.GetComponent(); 76 | stemPart.Add(leafPart, r); 77 | } 78 | 79 | var flower = CreateFlower(visible); 80 | flower.transform.SetParent(root.transform); 81 | flower.transform.localPosition = stemData.stem.Tip.position; 82 | flower.transform.localRotation *= stemData.stem.Tip.rotation * Quaternion.FromToRotation(Vector3.back, Vector3.up); 83 | 84 | stemPart.Add(flower.GetComponent(), 1f); 85 | 86 | return root; 87 | } 88 | 89 | GameObject CreateFlower (bool visible) { 90 | var floret = new Florets(); 91 | 92 | var bud = CreateShape("Bud", PFPartType.Petal, budData, visible); 93 | var petal = CreateShape("Petal", PFPartType.Petal, petalData, visible); 94 | 95 | var flower = new GameObject("Flower"); 96 | var root = flower.AddComponent(); 97 | root.SetType(PFPartType.None); 98 | 99 | var inv = 1f / n; 100 | for(int i = 0; i < n; i++) { 101 | var r = i * inv; 102 | 103 | var p = floret.Get(i + 1, c); 104 | 105 | GameObject go; 106 | 107 | if(i < m) { 108 | go = Instantiate(bud); 109 | go.transform.localScale = Vector3.one * (1f + Mathf.Max(min, p.magnitude)) * scale * 0.75f; 110 | } else { 111 | go = Instantiate(petal); 112 | go.transform.localScale = Vector3.one * (1f + Mathf.Max(min, p.magnitude)) * scale; 113 | } 114 | 115 | var part = go.GetComponent(); 116 | part.Colorize(new Color(rand.SampleRange(0.5f, 1f), rand.SampleRange(0.5f, 1f), rand.SampleRange(0.5f, 1f))); 117 | part.Bend(1f - r); 118 | part.Fade(visible ? 1f + part.EPSILON : 0f); 119 | 120 | go.transform.SetParent(flower.transform, false); 121 | 122 | go.transform.localPosition = p + Vector3.down * r * offset; 123 | go.transform.localRotation = Quaternion.LookRotation(Vector3.up, p.normalized) * Quaternion.AngleAxis((1f - r * angleScale) * angle, Vector3.right); 124 | 125 | root.Add(go.GetComponent(), r); 126 | } 127 | 128 | if(Application.isPlaying) { 129 | Destroy(bud); 130 | Destroy(petal); 131 | } else { 132 | DestroyImmediate(bud); 133 | DestroyImmediate(petal); 134 | } 135 | 136 | return flower; 137 | } 138 | 139 | GameObject CreateBase (string name, PFPartType type, Mesh mesh, Material material, ShadowCastingMode shadowCastingMode, bool receiveShadows, bool visible) { 140 | var go = new GameObject(name); 141 | go.AddComponent().mesh = mesh; 142 | 143 | var rnd = go.AddComponent(); 144 | rnd.sharedMaterial = material; 145 | rnd.shadowCastingMode = shadowCastingMode; 146 | rnd.receiveShadows = receiveShadows; 147 | 148 | var part = go.AddComponent(); 149 | part.SetType(type); 150 | part.Fade(visible ? 1f + part.EPSILON : 0f); 151 | 152 | return go; 153 | } 154 | 155 | GameObject CreateShape(string name, PFPartType type, ShapeData data, bool visible) { 156 | return CreateBase(name, type, data.mesh, data.material, data.shadowCastingMode, data.receiveShadows, visible); 157 | } 158 | 159 | GameObject CreateStem(string name, PFStem stem, ShadowCastingMode shadowCastingMode, bool receiveShadows, Func f, float height, float bend, bool visible) { 160 | var controls = GetControls(4, height, bend); 161 | var mesh = stem.Build(controls, f); 162 | return CreateBase(name, PFPartType.Stover, mesh, stemData.material, stemData.shadowCastingMode, stemData.receiveShadows, visible); 163 | } 164 | 165 | GameObject CreateLeaf (Point segment, Vector3 dir, float angle, bool visible) { 166 | var stem = new PFStem(10, 2, 0.01f); 167 | var root = CreateStem("Stem", stem, leafData.shadowCastingMode, leafData.receiveShadows, (r) => Mathf.Max(1f - r, 0.2f), 0.05f, 0.0f, visible); 168 | root.transform.localPosition = segment.position; 169 | root.transform.localRotation *= Quaternion.FromToRotation(Vector3.forward, dir) * Quaternion.AngleAxis(angle, Vector3.forward); 170 | 171 | var leaf = CreateShape("Leaf", PFPartType.Stover, leafData, visible); 172 | leaf.transform.SetParent(root.transform, false); 173 | leaf.transform.localPosition = stem.Tip.position; 174 | leaf.transform.localRotation *= Quaternion.AngleAxis(rand.SampleRange(0f, 30f), Vector3.up); 175 | 176 | var part = root.GetComponent(); 177 | part.SetSpeed(5f); 178 | part.Add(leaf.GetComponent(), 1f); 179 | 180 | return root; 181 | } 182 | 183 | List GetControls (int count, float height, float radius) { 184 | var controls = new List(); 185 | count = Mathf.Max(4, count); 186 | for(int i = 0; i < count; i++) { 187 | var r = (float)i / (count - 1); 188 | var circle = rand.SampleUnitCircle() * radius; 189 | controls.Add(new Vector3(circle.x, r * height, circle.y)); 190 | } 191 | return controls; 192 | } 193 | 194 | } 195 | 196 | class Florets { 197 | const float ANGLE = 137.5f * Mathf.Deg2Rad; 198 | 199 | // Vogel's formula : Generate patterns of florets 200 | // n is the ordering number of a floret, counting outward from the center. 201 | // phi is the angle between a reference direction and the position vector of the nth floret in a polar coordinate system originating at the center of the capitulum. 202 | // r is the distance between the center of the capitulum and the center of the nth floret, given a constant scaling parameter c. 203 | public Vector3 Get (int n, float c, float alpha = 137.5f) { 204 | // var phi = n * ANGLE; 205 | var phi = n * alpha * Mathf.Deg2Rad; 206 | var r = c * Mathf.Sqrt(n); 207 | return new Vector3(Mathf.Cos(phi) * r, 0f, Mathf.Sin(phi) * r); 208 | } 209 | } 210 | 211 | #region Define Data classes 212 | 213 | [System.Serializable] 214 | class ShapeData { 215 | [SerializeField] PFShape shape; 216 | public Material material = null; 217 | [HideInInspector] public Mesh mesh; 218 | public ShadowCastingMode shadowCastingMode = ShadowCastingMode.On; 219 | public bool receiveShadows = true; 220 | 221 | public void Init () { 222 | mesh = shape.Build(); 223 | if(material == null) { 224 | Debug.LogWarning("ShapeData material is null"); 225 | } 226 | } 227 | } 228 | 229 | [System.Serializable] 230 | class StemData { 231 | [HideInInspector] public PFStem stem; 232 | 233 | public Material material = null; 234 | [SerializeField] int wresolution = 10; 235 | [SerializeField] int hresolution = 8; 236 | [SerializeField] float radius = 0.012f; 237 | public float bend = 0.05f; 238 | public ShadowCastingMode shadowCastingMode = ShadowCastingMode.On; 239 | public bool receiveShadows = true; 240 | 241 | public void Init () { 242 | stem = new PFStem(wresolution, hresolution, radius); 243 | if(material == null) { 244 | Debug.LogWarning("StemData material is null"); 245 | } 246 | } 247 | } 248 | 249 | #endregion 250 | 251 | } 252 | 253 | 254 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/ProceduralFlower.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5e89a2728f6312499f8fd801e9f5112 3 | timeCreated: 1482221019 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa3c764e745234262a95cfcede7755d6 3 | folderAsset: yes 4 | timeCreated: 1485499389 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Bud.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: f4aecb51ef6264d37abdf1c60c6b502f, type: 3} 12 | m_Name: Bud 13 | m_EditorClassIdentifier: 14 | controls: 15 | - width: 0.0859375 16 | height: 0.125 17 | - width: 0.17578125 18 | height: 0.5644531 19 | - width: 0.15820312 20 | height: 0.82421875 21 | size: 1 22 | numberOfVerticesOnOneSide: 20 23 | resolution: 3 24 | noiseDepth: 0.2 25 | noiseScale: {x: 2, y: 3} 26 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Bud.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c5b58ca6d4ce4fcba2fa8a2f497911c 3 | timeCreated: 1483583582 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Leaf.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: f4aecb51ef6264d37abdf1c60c6b502f, type: 3} 12 | m_Name: Leaf 13 | m_EditorClassIdentifier: 14 | controls: 15 | - width: 0.26171875 16 | height: 0.39648438 17 | - width: 0.068359375 18 | height: 0.88671875 19 | size: 1 20 | numberOfVerticesOnOneSide: 30 21 | resolution: 4 22 | noiseDepth: 0.2 23 | noiseScale: {x: 2, y: 3} 24 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Leaf.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35af5a156253e4104a693c2c6fcea8f1 3 | timeCreated: 1483583582 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Leaf2.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: f4aecb51ef6264d37abdf1c60c6b502f, type: 3} 12 | m_Name: Leaf2 13 | m_EditorClassIdentifier: 14 | controls: 15 | - width: 0.140625 16 | height: 0.1640625 17 | - width: 0.2421875 18 | height: 0.38085938 19 | - width: 0.21289062 20 | height: 0.5917969 21 | - width: 0.05859375 22 | height: 0.8808594 23 | size: 1 24 | numberOfVerticesOnOneSide: 30 25 | resolution: 4 26 | noiseDepth: 0.25 27 | noiseScale: {x: 3, y: 1} 28 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Leaf2.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6060ff2e35ece4d6e9676ccb07cdc39b 3 | timeCreated: 1483583582 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Petal.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_GameObject: {fileID: 0} 9 | m_Enabled: 1 10 | m_EditorHideFlags: 0 11 | m_Script: {fileID: 11500000, guid: f4aecb51ef6264d37abdf1c60c6b502f, type: 3} 12 | m_Name: Petal 13 | m_EditorClassIdentifier: 14 | controls: 15 | - width: 0.22328246 16 | height: 0.17175573 17 | - width: 0.3721374 18 | height: 0.76717556 19 | size: 1 20 | numberOfVerticesOnOneSide: 20 21 | resolution: 3 22 | noiseDepth: 0.2 23 | noiseScale: {x: 3, y: 2} 24 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Scripts/Shapes/Petal.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a546c42e8041a417498ec6a02732572c 3 | timeCreated: 1483583582 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f6627abf6e8df0499d1044660dcfbb1 3 | folderAsset: yes 4 | timeCreated: 1482220998 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Bud.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/ProceduralFlower/Bud" 2 | { 3 | Properties { 4 | _Color ("Color", Color) = (1, 1, 1, 1) 5 | _Color2 ("Color (2nd)", Color) = (1, 1, 1, 1) 6 | _Bend ("Bend", Range(0.0, 1.0)) = 0.0 7 | _T ("T", Range(0.0, 1.0)) = 1.0 8 | _Intensity ("Lighting intensity", Range(0.0, 1.0)) = 1.0 9 | } 10 | 11 | CGINCLUDE 12 | 13 | #pragma multi_compile_fwdbase 14 | #include "UnityCG.cginc" 15 | #include "AutoLight.cginc" 16 | 17 | ENDCG 18 | 19 | SubShader { 20 | 21 | Pass { 22 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 23 | Lighting On ZWrite On Cull Back 24 | LOD 100 25 | CGPROGRAM 26 | #define CULL_BACK 1 27 | #include "ProceduralFlower.cginc" 28 | #pragma vertex vert_bud 29 | #pragma fragment frag_common 30 | ENDCG 31 | } 32 | 33 | Pass { 34 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 35 | Lighting On ZWrite On Cull Front 36 | LOD 100 37 | CGPROGRAM 38 | #define CULL_FRONT 1 39 | #include "ProceduralFlower.cginc" 40 | #pragma vertex vert_bud 41 | #pragma fragment frag_common 42 | ENDCG 43 | } 44 | 45 | Pass { 46 | Name "ShadowCaster" 47 | Tags { "LightMode" = "ShadowCaster" } 48 | ZWrite On ZTest LEqual Cull Off 49 | 50 | CGPROGRAM 51 | #include "ProceduralFlower.cginc" 52 | #pragma multi_compile_shadowcaster 53 | #pragma vertex vert_shadow_bud 54 | #pragma fragment frag_shadow_common 55 | ENDCG 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Bud.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c2a496b8d8d64b749ea21a3fa04812b 3 | timeCreated: 1485694914 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Combine.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/ProceduralFlower/Demo/Combine" { 2 | Properties { 3 | _Color ("Color", Color) = (1,1,1,1) 4 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 5 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 6 | _Metallic ("Metallic", Range(0,1)) = 0.0 7 | } 8 | SubShader { 9 | Tags { "RenderType"="Opaque" } 10 | Cull Off 11 | LOD 200 12 | 13 | CGPROGRAM 14 | #pragma surface surf Standard fullforwardshadows 15 | #pragma target 3.0 16 | 17 | sampler2D _MainTex; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | }; 22 | 23 | half _Glossiness; 24 | half _Metallic; 25 | fixed4 _Color; 26 | 27 | void surf (Input IN, inout SurfaceOutputStandard o) { 28 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 29 | o.Albedo = c.rgb; 30 | o.Metallic = _Metallic; 31 | o.Smoothness = _Glossiness; 32 | o.Alpha = c.a; 33 | } 34 | ENDCG 35 | } 36 | FallBack "Diffuse" 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Combine.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eff50f71c94255244a95c4a8d2caefbb 3 | timeCreated: 1485747013 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Garden.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/ProceduralFlower/Demo/Garden" { 2 | 3 | Properties { 4 | _Color ("Color", Color) = (1,1,1,1) 5 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 6 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 7 | _Metallic ("Metallic", Range(0,1)) = 0.0 8 | } 9 | 10 | SubShader { 11 | Tags { "RenderType"="Opaque" } 12 | LOD 200 13 | 14 | CGPROGRAM 15 | #pragma surface surf Standard fullforwardshadows 16 | 17 | #pragma target 3.0 18 | 19 | sampler2D _MainTex; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | }; 24 | 25 | half _Glossiness; 26 | half _Metallic; 27 | fixed4 _Color; 28 | 29 | void surf (Input IN, inout SurfaceOutputStandard o) { 30 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 31 | o.Albedo = c.rgb; 32 | o.Metallic = _Metallic; 33 | o.Smoothness = _Glossiness; 34 | o.Alpha = c.a; 35 | } 36 | ENDCG 37 | } 38 | FallBack "Diffuse" 39 | } 40 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Garden.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed5c5f8d8de904500aa3f60f012787d3 3 | timeCreated: 1485687055 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Petal.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/ProceduralFlower/Petal" 2 | { 3 | Properties { 4 | _Color ("Color", Color) = (1, 1, 1, 1) 5 | _Color2 ("Color (2nd)", Color) = (1, 1, 1, 1) 6 | _Bend ("Bend", Range(0.0, 1.0)) = 0.0 7 | _T ("T", Range(0.0, 1.0)) = 1.0 8 | _Intensity ("Lighting intensity", Range(0.0, 1.0)) = 1.0 9 | } 10 | 11 | CGINCLUDE 12 | 13 | #pragma multi_compile_fwdbase 14 | #include "UnityCG.cginc" 15 | #include "AutoLight.cginc" 16 | 17 | ENDCG 18 | 19 | SubShader { 20 | 21 | Pass { 22 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 23 | Lighting On ZWrite On Cull Back 24 | LOD 100 25 | CGPROGRAM 26 | #define CULL_BACK 1 27 | #include "ProceduralFlower.cginc" 28 | #pragma vertex vert_petal 29 | #pragma fragment frag_common 30 | ENDCG 31 | } 32 | 33 | Pass { 34 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 35 | Lighting On ZWrite On Cull Front 36 | LOD 100 37 | CGPROGRAM 38 | #define CULL_FRONT 1 39 | #include "ProceduralFlower.cginc" 40 | #pragma vertex vert_petal 41 | #pragma fragment frag_common 42 | ENDCG 43 | } 44 | 45 | Pass { 46 | Name "ShadowCaster" 47 | Tags { "LightMode" = "ShadowCaster" } 48 | ZWrite On ZTest LEqual Cull Off 49 | 50 | CGPROGRAM 51 | #include "ProceduralFlower.cginc" 52 | #pragma multi_compile_shadowcaster 53 | #pragma vertex vert_shadow_petal 54 | #pragma fragment frag_shadow_common 55 | ENDCG 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Petal.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 836ef6bf4690d46fb94fe51a36a29627 3 | timeCreated: 1485694914 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/ProceduralFlower.cginc: -------------------------------------------------------------------------------- 1 | #ifndef _PROCEDURAL_FLOWER_COMMON_ 2 | #define _PROCEDURAL_FLOWER_COMMON_ 3 | 4 | #define PF_HALF_PI 1.570795 5 | #define PF_PI 3.14159 6 | 7 | half4 _Color, _Color2; 8 | float _Bend, _T, _Intensity; 9 | 10 | uniform float4 _LightColor0; 11 | 12 | float calculate_bend_amount (float3 v) { 13 | return pow(abs(v.x), 2.0) * _Bend; 14 | } 15 | 16 | float3 bend_petal (float3 v) { 17 | float bend = calculate_bend_amount(v); 18 | v.z += bend; 19 | return v; 20 | } 21 | 22 | float3 bend_bud (float3 v) { 23 | float bend = calculate_bend_amount(v); 24 | v.z += bend - (sin(v.y * PF_PI) * 0.15 * _Bend); 25 | return v; 26 | } 27 | 28 | void fade (float2 uv) { 29 | clip(_T - uv.y - 0.075); 30 | } 31 | 32 | struct appdata { 33 | float4 vertex : POSITION; 34 | float2 uv : TEXCOORD0; 35 | float3 normal : NORMAL; 36 | }; 37 | 38 | struct v2f { 39 | float4 pos : SV_POSITION; 40 | float3 normal : NORMAL; 41 | float3 lightDir : TEXCOORD0; 42 | float3 viewDir : TEXCOORD1; 43 | float2 uv : TEXCOORD2; 44 | LIGHTING_COORDS(3, 4) 45 | }; 46 | 47 | struct v2f_shadow { 48 | V2F_SHADOW_CASTER; 49 | float2 uv : TEXCOORD0; 50 | }; 51 | 52 | v2f vert_common (appdata v) { 53 | v2f OUT; 54 | OUT.pos = mul(UNITY_MATRIX_MVP, v.vertex); 55 | OUT.uv = v.uv; 56 | OUT.lightDir = ObjSpaceLightDir(v.vertex); 57 | OUT.viewDir = ObjSpaceViewDir(v.vertex); 58 | 59 | #ifdef CULL_BACK 60 | OUT.normal = v.normal; 61 | #elif CULL_FRONT 62 | OUT.normal = -v.normal; 63 | #else 64 | // OUT.normal = v.normal; 65 | OUT.normal = float3(0, 0, 0); 66 | #endif 67 | 68 | TRANSFER_VERTEX_TO_FRAGMENT(OUT); 69 | TRANSFER_SHADOW(OUT); 70 | return OUT; 71 | } 72 | 73 | v2f_shadow vert_shadow_common (appdata v) { 74 | v2f_shadow OUT; 75 | 76 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(OUT) 77 | OUT.uv = v.uv; 78 | return OUT; 79 | } 80 | 81 | v2f vert_petal (appdata v) { 82 | v.vertex.xyz = bend_petal(v.vertex); 83 | return vert_common(v); 84 | } 85 | 86 | v2f_shadow vert_shadow_petal (appdata v) { 87 | v.vertex.xyz = bend_petal(v.vertex); 88 | return vert_shadow_common(v); 89 | } 90 | 91 | v2f vert_bud (appdata v) { 92 | v.vertex.xyz = bend_bud(v.vertex); 93 | return vert_common(v); 94 | } 95 | 96 | v2f_shadow vert_shadow_bud (appdata v) { 97 | v.vertex.xyz = bend_bud(v.vertex); 98 | return vert_shadow_common(v); 99 | } 100 | 101 | float4 frag_common (v2f IN) : SV_Target { 102 | fade(IN.uv); 103 | 104 | fixed atten = LIGHT_ATTENUATION(IN); 105 | fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT; 106 | half3 halfDir = normalize(IN.lightDir) + normalize(IN.viewDir); 107 | fixed diff = max(1.0 - _Intensity, dot(normalize(halfDir), normalize(IN.normal))); 108 | fixed4 c = _Color * _Color2; 109 | c.rgb = (c * _LightColor0 * atten * diff) + ambient; 110 | return c; 111 | } 112 | 113 | float4 frag_shadow_common (v2f_shadow IN) : COLOR { 114 | fade(IN.uv); 115 | 116 | SHADOW_CASTER_FRAGMENT(IN) 117 | } 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/ProceduralFlower.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 278037039e756410484fa1f94d5b9119 3 | timeCreated: 1485660855 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Stover.shader: -------------------------------------------------------------------------------- 1 | Shader "mattatz/ProceduralFlower/Stover" 2 | { 3 | Properties { 4 | _Color ("Color", Color) = (1, 1, 1, 1) 5 | _Color2 ("Color (2nd)", Color) = (1, 1, 1, 1) 6 | _Bend ("Bend", Range(0.0, 1.0)) = 0.0 7 | _T ("T", Range(0.0, 1.0)) = 1.0 8 | _Intensity ("Lighting intensity", Range(0.0, 1.0)) = 1.0 9 | } 10 | 11 | CGINCLUDE 12 | 13 | #pragma multi_compile_fwdbase 14 | #include "UnityCG.cginc" 15 | #include "AutoLight.cginc" 16 | 17 | ENDCG 18 | 19 | SubShader { 20 | 21 | Pass { 22 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 23 | Lighting On ZWrite On Cull Back 24 | LOD 100 25 | CGPROGRAM 26 | #define CULL_BACK 1 27 | #include "ProceduralFlower.cginc" 28 | #pragma vertex vert_common 29 | #pragma fragment frag_common 30 | ENDCG 31 | } 32 | 33 | Pass { 34 | Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase" } 35 | Lighting On ZWrite On Cull Front 36 | LOD 100 37 | CGPROGRAM 38 | #define CULL_FRONT 1 39 | #include "ProceduralFlower.cginc" 40 | #pragma vertex vert_common 41 | #pragma fragment frag_common 42 | ENDCG 43 | } 44 | 45 | Pass { 46 | Name "ShadowCaster" 47 | Tags { "LightMode" = "ShadowCaster" } 48 | ZWrite On ZTest LEqual Cull Off 49 | 50 | CGPROGRAM 51 | #include "ProceduralFlower.cginc" 52 | #pragma multi_compile_shadowcaster 53 | #pragma vertex vert_shadow_common 54 | #pragma fragment frag_shadow_common 55 | ENDCG 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Shaders/Stover.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 618cf48fd25734c43a1525637579a331 3 | timeCreated: 1485694914 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 373e0f3595ed52e48aa04f91d314de1a 3 | folderAsset: yes 4 | timeCreated: 1482734021 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/Grid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Textures/Grid.jpg -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/Grid.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b485b76376de54941b09ed6987a6b6fa 3 | timeCreated: 1483610690 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/Knob.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Textures/Knob.png -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/Knob.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf659cc34b0814d0ab720d6d87bd3434 3 | timeCreated: 1483610835 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: WebGL 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | spriteSheet: 78 | serializedVersion: 2 79 | sprites: [] 80 | outline: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/PFShapeWindow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Textures/PFShapeWindow.png -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/PFShapeWindow.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 61fe07f2cdb95410aba4ca9ce7015df5 3 | timeCreated: 1485659332 4 | licenseType: Free 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | - buildTarget: Standalone 62 | maxTextureSize: 2048 63 | textureFormat: -1 64 | textureCompression: 1 65 | compressionQuality: 50 66 | crunchedCompression: 0 67 | allowsAlphaSplitting: 0 68 | overridden: 0 69 | - buildTarget: WebGL 70 | maxTextureSize: 2048 71 | textureFormat: -1 72 | textureCompression: 1 73 | compressionQuality: 50 74 | crunchedCompression: 0 75 | allowsAlphaSplitting: 0 76 | overridden: 0 77 | spriteSheet: 78 | serializedVersion: 2 79 | sprites: [] 80 | outline: [] 81 | spritePackingTag: 82 | userData: 83 | assetBundleName: 84 | assetBundleVariant: 85 | -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/uvtester.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Assets/Packages/ProceduralFlower/Textures/uvtester.jpg -------------------------------------------------------------------------------- /Assets/Packages/ProceduralFlower/Textures/uvtester.jpg.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aea31cef8201f64458524089c1de92ab 3 | timeCreated: 1482734036 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: -1 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Captures/Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Demo.png -------------------------------------------------------------------------------- /Captures/Editor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Editor.gif -------------------------------------------------------------------------------- /Captures/Garden.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Garden.gif -------------------------------------------------------------------------------- /Captures/Height.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Height.gif -------------------------------------------------------------------------------- /Captures/Inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Inspector.png -------------------------------------------------------------------------------- /Captures/Leaves.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Leaves.gif -------------------------------------------------------------------------------- /Captures/Petals.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/Captures/Petals.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 mattatz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProceduralFlower.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattatz/unity-procedural-flower/543eff6a788bfa1606c978fd7e337f90984eb1e0/ProceduralFlower.unitypackage -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | unity-procedural-flower 2 | ===================== 3 | 4 | Procedural flower generator for Unity. 5 | 6 | ![Demo](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Demo.png) 7 | 8 | ## Example 9 | 10 | ### PFTester in Demo.scene 11 | 12 | ![Petals](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Petals.gif) 13 | 14 | ![Height](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Height.gif) 15 | 16 | ![Leaves](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Leaves.gif) 17 | 18 | ### Garden.scene 19 | 20 | ProceduralFlower can animate. 21 | 22 | ![Garden](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Garden.gif) 23 | 24 | ## Usage 25 | 26 | ### PFShape 27 | 28 | ProceduralFlower needs 3 PFShape(ScriptableObject) for petal and leaf shapes. 29 | 30 | PFShape has control points and you can design its outline by the editor. 31 | 32 | ![Editor](https://raw.githubusercontent.com/mattatz/unity-procedural-flower/master/Captures/Editor.gif) 33 | 34 | ### PFCombine 35 | 36 | PFCombine enables to combine meshes of ProceduralFlower into one mesh. 37 | 38 | ```cs 39 | 40 | public ProceduralFlower flower; 41 | void Start () { 42 | var mesh = PFCombine.Combine(flower); 43 | GetComponent().sharedMesh = mesh; 44 | } 45 | 46 | ``` 47 | 48 | ## Sources 49 | 50 | - The Algorithmic Beauty of Plants - http://algorithmicbotany.org/papers/#abop 51 | --------------------------------------------------------------------------------