├── .gitattributes ├── .gitignore ├── HDRPGrass ├── Assets │ ├── Grass.meta │ ├── Grass │ │ ├── Compute.meta │ │ ├── Compute │ │ │ ├── GeneratedMeshes.meta │ │ │ ├── GeneratedMeshes │ │ │ │ ├── LODGrass.prefab │ │ │ │ ├── LODGrass.prefab.meta │ │ │ │ ├── Procedural_generatedGrass.asset │ │ │ │ ├── Procedural_generatedGrass.asset.meta │ │ │ │ ├── Procedural_generatedGrass_3000.asset │ │ │ │ ├── Procedural_generatedGrass_3000.asset.meta │ │ │ │ ├── Procedural_generatedGrass_900.asset │ │ │ │ ├── Procedural_generatedGrass_900.asset.meta │ │ │ │ ├── Procedural_generatedGrass_9000.asset │ │ │ │ └── Procedural_generatedGrass_9000.asset.meta │ │ │ ├── Materials.meta │ │ │ ├── Materials │ │ │ │ ├── ComputeGrassMesh.mat │ │ │ │ ├── ComputeGrassMesh.mat.meta │ │ │ │ ├── ComputeGrassProcedural.mat │ │ │ │ └── ComputeGrassProcedural.mat.meta │ │ │ ├── ProceduralGrassRenderer.cs │ │ │ ├── ProceduralGrassRenderer.cs.meta │ │ │ ├── Shaders.meta │ │ │ └── Shaders │ │ │ │ ├── Grass_Compute_CommonStructs.hlsl │ │ │ │ ├── Grass_Compute_CommonStructs.hlsl.meta │ │ │ │ ├── Grass_Compute_ComputeShader.compute │ │ │ │ ├── Grass_Compute_ComputeShader.compute.meta │ │ │ │ ├── Grass_Compute_ComputeStructs.hlsl │ │ │ │ ├── Grass_Compute_ComputeStructs.hlsl.meta │ │ │ │ ├── Grass_Compute_Fragment.hlsl │ │ │ │ ├── Grass_Compute_Fragment.hlsl.meta │ │ │ │ ├── Grass_Compute_Properties.hlsl │ │ │ │ ├── Grass_Compute_Properties.hlsl.meta │ │ │ │ ├── Grass_Compute_Shader.shader │ │ │ │ ├── Grass_Compute_Shader.shader.meta │ │ │ │ ├── Grass_Compute_TransformFunctions.hlsl │ │ │ │ ├── Grass_Compute_TransformFunctions.hlsl.meta │ │ │ │ ├── Grass_Compute_Vertex.hlsl │ │ │ │ ├── Grass_Compute_Vertex.hlsl.meta │ │ │ │ ├── Grass_Compute_VertexMesh.hlsl │ │ │ │ ├── Grass_Compute_VertexMesh.hlsl.meta │ │ │ │ ├── Grass_Compute_VertexProcedural.hlsl │ │ │ │ └── Grass_Compute_VertexProcedural.hlsl.meta │ │ ├── GrassDisplacementSphere.cs │ │ ├── GrassDisplacementSphere.cs.meta │ │ ├── Grass_Common.hlsl │ │ ├── Grass_Common.hlsl.meta │ │ ├── Grass_CommonStructs.hlsl │ │ ├── Grass_CommonStructs.hlsl.meta │ │ ├── Grass_Common_GBuffer.hlsl │ │ ├── Grass_Common_GBuffer.hlsl.meta │ │ ├── Mover.cs │ │ ├── Mover.cs.meta │ │ ├── Scenes.meta │ │ ├── Scenes │ │ │ ├── Grass_Compute_TestScene.unity │ │ │ ├── Grass_Compute_TestScene.unity.meta │ │ │ ├── Grass_TesselationGeometry_Scene.unity │ │ │ └── Grass_TesselationGeometry_Scene.unity.meta │ │ ├── TesselationGeometry.meta │ │ ├── TesselationGeometry │ │ │ ├── GrassShader.png │ │ │ ├── GrassShader.png.meta │ │ │ ├── Materials.meta │ │ │ ├── Materials │ │ │ │ ├── AlienGrass.mat │ │ │ │ ├── AlienGrass.mat.meta │ │ │ │ ├── CartoonyGrass.mat │ │ │ │ ├── CartoonyGrass.mat.meta │ │ │ │ ├── Ground.meta │ │ │ │ ├── Ground │ │ │ │ │ ├── NormalGround.mat │ │ │ │ │ ├── NormalGround.mat.meta │ │ │ │ │ ├── RedGround.mat │ │ │ │ │ ├── RedGround.mat.meta │ │ │ │ │ ├── Soil.mat │ │ │ │ │ └── Soil.mat.meta │ │ │ │ ├── LawnGrass.mat │ │ │ │ ├── LawnGrass.mat.meta │ │ │ │ ├── WildGrass.mat │ │ │ │ └── WildGrass.mat.meta │ │ │ ├── Scripts.meta │ │ │ ├── Scripts │ │ │ │ ├── Editor.meta │ │ │ │ └── Editor │ │ │ │ │ ├── ColourOptionUIBlock.cs │ │ │ │ │ ├── ColourOptionUIBlock.cs.meta │ │ │ │ │ ├── GrassAdvancedUIBlock.cs │ │ │ │ │ ├── GrassAdvancedUIBlock.cs.meta │ │ │ │ │ ├── GrassDebugUIBlock.cs │ │ │ │ │ ├── GrassDebugUIBlock.cs.meta │ │ │ │ │ ├── GrassDistributionUIBlock.cs │ │ │ │ │ ├── GrassDistributionUIBlock.cs.meta │ │ │ │ │ ├── GrassGUI.cs │ │ │ │ │ ├── GrassGUI.cs.meta │ │ │ │ │ ├── GrassShapeUIBlock.cs │ │ │ │ │ ├── GrassShapeUIBlock.cs.meta │ │ │ │ │ ├── GrassWindUIBlock.cs │ │ │ │ │ ├── GrassWindUIBlock.cs.meta │ │ │ │ │ ├── HDRPCopiedStuff.meta │ │ │ │ │ └── HDRPCopiedStuff │ │ │ │ │ ├── HDStringConstants.cs │ │ │ │ │ ├── HDStringConstants.cs.meta │ │ │ │ │ ├── MaterialEditorExtension.cs │ │ │ │ │ ├── MaterialEditorExtension.cs.meta │ │ │ │ │ ├── MaterialHeaderScope.cs │ │ │ │ │ ├── MaterialHeaderScope.cs.meta │ │ │ │ │ ├── MaterialUIBlock.cs │ │ │ │ │ ├── MaterialUIBlock.cs.meta │ │ │ │ │ ├── MaterialUIBlockList.cs │ │ │ │ │ └── MaterialUIBlockList.cs.meta │ │ │ ├── Shaders.meta │ │ │ └── Shaders │ │ │ │ ├── Grass_TesselationGeometry_Common.hlsl │ │ │ │ ├── Grass_TesselationGeometry_Common.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_Fragment.hlsl │ │ │ │ ├── Grass_TesselationGeometry_Fragment.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_FragmentForward.hlsl │ │ │ │ ├── Grass_TesselationGeometry_FragmentForward.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_Geometry.hlsl │ │ │ │ ├── Grass_TesselationGeometry_Geometry.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_GeometryPassthrough.hlsl │ │ │ │ ├── Grass_TesselationGeometry_GeometryPassthrough.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_Properties.hlsl │ │ │ │ ├── Grass_TesselationGeometry_Properties.hlsl.meta │ │ │ │ ├── Grass_TesselationGeometry_Shader.shader │ │ │ │ ├── Grass_TesselationGeometry_Shader.shader.meta │ │ │ │ ├── Grass_TesselationGeometry_Tesselation.hlsl │ │ │ │ └── Grass_TesselationGeometry_Tesselation.hlsl.meta │ │ ├── Textures.meta │ │ └── Textures │ │ │ ├── AlienGrass_FieldTex1.png │ │ │ ├── AlienGrass_FieldTex1.png.meta │ │ │ ├── AlienGrass_FieldTex2.png │ │ │ ├── AlienGrass_FieldTex2.png.meta │ │ │ ├── GrassWind.png │ │ │ ├── GrassWind.png.meta │ │ │ ├── Lawn.png │ │ │ ├── Lawn.png.meta │ │ │ ├── Soil.png │ │ │ ├── Soil.png.meta │ │ │ ├── WildGrass_BladeTex.png │ │ │ └── WildGrass_BladeTex.png.meta │ ├── HDRP.meta │ └── HDRP │ │ ├── HDRenderPipelineAsset.asset │ │ ├── HDRenderPipelineAsset.asset.meta │ │ ├── Sky and Fog Settings Profile.asset │ │ └── Sky and Fog Settings Profile.asset.meta ├── Packages │ ├── manifest.json │ └── packages-lock.json ├── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── HDRPProjectSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Packages │ │ └── com.unity.polybrush │ │ │ └── Settings.json │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ ├── VFXManager.asset │ └── XRSettings.asset └── fmod_editor.log └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Unity 2 | *.cginc text 3 | *.cs diff=csharp text 4 | *.shader text 5 | # Unity YAML 6 | *.mat merge=unityyamlmerge eol=lf 7 | *.anim merge=unityyamlmerge eol=lf 8 | *.unity filter=lfs diff=lfs merge=lfs -text 9 | *.prefab merge=unityyamlmerge eol=lf 10 | *.physicMaterial2D merge=unityyamlmerge eol=lf 11 | *.physicMaterial merge=unityyamlmerge eol=lf 12 | *.asset filter=lfs diff=lfs merge=lfs -text 13 | *.meta merge=unityyamlmerge eol=lf 14 | *.controller merge=unityyamlmerge eol=lf 15 | # Unity LFS 16 | *.cubemap filter=lfs diff=lfs merge=lfs -text 17 | *.unitypackage filter=lfs diff=lfs merge=lfs -text 18 | #FMOD LFS 19 | ## Banks 20 | /FMOD_Project/Build/**/*.bank filter=lfs diff=lfs merge=lfs -text 21 | ## 3D models 22 | *.3dm filter=lfs diff=lfs merge=lfs -text 23 | *.3ds filter=lfs diff=lfs merge=lfs -text 24 | *.blend filter=lfs diff=lfs merge=lfs -text 25 | *.c4d filter=lfs diff=lfs merge=lfs -text 26 | *.collada filter=lfs diff=lfs merge=lfs -text 27 | *.dae filter=lfs diff=lfs merge=lfs -text 28 | *.dxf filter=lfs diff=lfs merge=lfs -text 29 | *.fbx filter=lfs diff=lfs merge=lfs -text 30 | *.jas filter=lfs diff=lfs merge=lfs -text 31 | *.lws filter=lfs diff=lfs merge=lfs -text 32 | *.lxo filter=lfs diff=lfs merge=lfs -text 33 | *.ma filter=lfs diff=lfs merge=lfs -text 34 | *.max filter=lfs diff=lfs merge=lfs -text 35 | *.mb filter=lfs diff=lfs merge=lfs -text 36 | *.obj filter=lfs diff=lfs merge=lfs -text 37 | *.ply filter=lfs diff=lfs merge=lfs -text 38 | *.skp filter=lfs diff=lfs merge=lfs -text 39 | *.stl filter=lfs diff=lfs merge=lfs -text 40 | *.ztl filter=lfs diff=lfs merge=lfs -text 41 | ## Audio 42 | *.aif filter=lfs diff=lfs merge=lfs -text 43 | *.aiff filter=lfs diff=lfs merge=lfs -text 44 | *.it filter=lfs diff=lfs merge=lfs -text 45 | *.mod filter=lfs diff=lfs merge=lfs -text 46 | *.mp3 filter=lfs diff=lfs merge=lfs -text 47 | *.ogg filter=lfs diff=lfs merge=lfs -text 48 | *.s3m filter=lfs diff=lfs merge=lfs -text 49 | *.wav filter=lfs diff=lfs merge=lfs -text 50 | *.xm filter=lfs diff=lfs merge=lfs -text 51 | # Video 52 | *.asf filter=lfs diff=lfs merge=lfs -text 53 | *.avi filter=lfs diff=lfs merge=lfs -text 54 | *.flv filter=lfs diff=lfs merge=lfs -text 55 | *.mov filter=lfs diff=lfs merge=lfs -text 56 | *.mp4 filter=lfs diff=lfs merge=lfs -text 57 | *.mpeg filter=lfs diff=lfs merge=lfs -text 58 | *.mpg filter=lfs diff=lfs merge=lfs -text 59 | *.ogv filter=lfs diff=lfs merge=lfs -text 60 | *.wmv filter=lfs diff=lfs merge=lfs -text 61 | ## Images 62 | *.bmp filter=lfs diff=lfs merge=lfs -text 63 | *.exr filter=lfs diff=lfs merge=lfs -text 64 | *.gif filter=lfs diff=lfs merge=lfs -text 65 | *.hdr filter=lfs diff=lfs merge=lfs -text 66 | *.iff filter=lfs diff=lfs merge=lfs -text 67 | *.jpeg filter=lfs diff=lfs merge=lfs -text 68 | *.jpg filter=lfs diff=lfs merge=lfs -text 69 | *.pict filter=lfs diff=lfs merge=lfs -text 70 | *.png filter=lfs diff=lfs merge=lfs -text 71 | *.psd filter=lfs diff=lfs merge=lfs -text 72 | *.tga filter=lfs diff=lfs merge=lfs -text 73 | *.tif filter=lfs diff=lfs merge=lfs -text 74 | *.tiff filter=lfs diff=lfs merge=lfs -text 75 | # Compressed Archive 76 | *.7z filter=lfs diff=lfs merge=lfs -text 77 | *.bz2 filter=lfs diff=lfs merge=lfs -text 78 | *.gz filter=lfs diff=lfs merge=lfs -text 79 | *.rar filter=lfs diff=lfs merge=lfs -text 80 | *.tar filter=lfs diff=lfs merge=lfs -text 81 | *.zip filter=lfs diff=lfs merge=lfs -text 82 | # Compiled Dynamic Library 83 | *.dll filter=lfs diff=lfs merge=lfs -text 84 | *.pdb filter=lfs diff=lfs merge=lfs -text 85 | *.so filter=lfs diff=lfs merge=lfs -text 86 | ## Fonts 87 | *.otf filter=lfs diff=lfs merge=lfs -text 88 | *.ttf filter=lfs diff=lfs merge=lfs -text 89 | # Executable/Installer 90 | *.apk filter=lfs diff=lfs merge=lfs -text 91 | *.exe filter=lfs diff=lfs merge=lfs -text 92 | # Documents 93 | *.pdf filter=lfs diff=lfs merge=lfs -text 94 | ## Collapse Unity-generated files on GitHub 95 | *.asset linguist-generated 96 | *.mat linguist-generated 97 | *.meta linguist-generated 98 | *.prefab linguist-generated 99 | *.unity linguist-generated 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### 2 | # Unity folders and files 3 | ### 4 | HDRPGrass/[Aa]ssets/AssetStoreTools* 5 | HDRPGrass/[Bb]uild/ 6 | HDRPGrass/[Ll]ibrary/ 7 | HDRPGrass/[Ll]ogs 8 | HDRPGrass/.vs 9 | HDRPGrass/[Ll]ocal[Cc]ache/ 10 | HDRPGrass/[Oo]bj/ 11 | HDRPGrass/[Tt]emp/ 12 | HDRPGrass/[Uu]nityGenerated/ 13 | # file on crash reports 14 | sysinfo.txt 15 | # Unity3D generated meta files 16 | *.pidb.meta 17 | 18 | ### 19 | # Unity specific files 20 | ### 21 | HDRPGrass/[Pp]roject[Ss]ettings/[Pp]ackages/com.unity.probuilder/Settings.json 22 | 23 | ### 24 | # VS/MD solution and project files 25 | ### 26 | [Ee]xportedObj/ 27 | *.booproj 28 | *.csproj 29 | *.sln 30 | *.suo 31 | *.svd 32 | *.unityproj 33 | *.user 34 | *.userprefs 35 | *.pidb 36 | .DS_Store 37 | 38 | ### 39 | # OS generated 40 | ### 41 | .DS_Store 42 | .DS_Store? 43 | ._* 44 | .Spotlight-V100 45 | .Trashes 46 | Icon? 47 | ehthumbs.db 48 | Thumbs.db 49 | 50 | # Ignore the auto-generated AOT compatibility dll. 51 | HDRPGrass/[Aa]ssets/Plugins/Sirenix/Assemblies/AOT/* 52 | 53 | # Ignore all unpacked demos. 54 | HDRPGrass/[Aa]ssets/Plugins/Sirenix/Demos/* 55 | 56 | # But keep the demo packages themselves. 57 | HDRPGrass/[Aa]ssets/Plugins/Sirenix/Demos/*.unitypackage 58 | 59 | # autogenerated ignores 60 | Ignore 61 | /HDRPGrass/Assets/Ignore.meta 62 | /HDRPGrass/Logs 63 | /HDRPGrass/Logs.meta 64 | /HDRPGrass/.vs 65 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b11839ef449b05a439fa220c153e89ed 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 290fd0c71acf7714f9f6f47ac2029eae 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb03642e81993fc4490684190fecbcfb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/LODGrass.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23a49bb030b25c048a4a3806006d4b0e 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:28c60fc701a49362fe0cc0b341757782c3dab20ff84767a3d0eac9c56202697f 3 | size 1335185 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00f3c7fc933a15b4680e9dfebcdd9b22 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_3000.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f1c84c15ec47cdd3ce6300348bf2496b527c6e17d02665faa4f23c736c78431a 3 | size 447200 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_3000.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12461048ec35c3b45bb13b81b3c794d6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_900.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:da836a15c3d125f7e692717c808d692d936bb53821d408bff43665f6a5c93fea 3 | size 136377 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_900.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bcd1a8194f71d24fa33a082ab15fc41 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_9000.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:92ab27676f8b56c7cc012acc3c5899562dcc826d4b3a4f4e4689a459b97d3f47 3 | size 1335198 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/GeneratedMeshes/Procedural_generatedGrass_9000.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8aed26e3b5b41748ac267b8e2047ba0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3650a3843756d04b8574b27ea3112ba 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Materials/ComputeGrassMesh.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17426a8d928fbdf4b8cb380571d04fe2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Materials/ComputeGrassProcedural.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b953baad48f2cff4e86291963464c222 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/ProceduralGrassRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00ef4e4a38726b340be8ab5023693b27 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - m_meshFilter: {instanceID: 0} 8 | - m_grassStatic: {fileID: 7200000, guid: 7e25eb7ffbaffaf4cbf07769a909b750, type: 3} 9 | - m_grassMaterial: {fileID: 2100000, guid: b953baad48f2cff4e86291963464c222, type: 2} 10 | - m_grassMaterialMeshes: {fileID: 2100000, guid: 17426a8d928fbdf4b8cb380571d04fe2, 11 | type: 2} 12 | executionOrder: 0 13 | icon: {instanceID: 0} 14 | userData: 15 | assetBundleName: 16 | assetBundleVariant: 17 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8d6cc41b927f4244be300f5fb959a38 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_CommonStructs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GRASS_COMPUTE_COMMONSTRUCTS 2 | #define GRASS_COMPUTE_COMMONSTRUCTS 3 | 4 | // information about a specific grass vertex 5 | struct GrassBladeVertex 6 | { 7 | float3 positionOS; 8 | float2 uv; 9 | }; 10 | 11 | // contains data for each blade of grass' local space. 12 | struct GrassBladeSpaceData 13 | { 14 | float3 positionOS; 15 | float3 normalOS; 16 | float3 tangentOS; 17 | float3 bitangentOS; 18 | float2 uv; 19 | 20 | float3x3 GetTangentToLocal() 21 | { 22 | return float3x3 23 | ( 24 | tangentOS.x, bitangentOS.x, normalOS.x, 25 | tangentOS.y, bitangentOS.y, normalOS.y, 26 | tangentOS.z, bitangentOS.z, normalOS.z 27 | ); 28 | } 29 | }; 30 | 31 | // this struct contains information about one entire blade of grass, ready 32 | // to be sent for rendering 33 | struct GrassBladeTriangle 34 | { 35 | GrassBladeVertex points[3]; 36 | GrassBladeSpaceData space; 37 | }; 38 | 39 | #endif // GRASS_COMPUTE_COMMONSTRUCTS -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_CommonStructs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51c001b6c4a64bf439ccc92337e8b048 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_ComputeShader.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e25eb7ffbaffaf4cbf07769a909b750 3 | ComputeShaderImporter: 4 | externalObjects: {} 5 | currentAPIMask: 4 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_ComputeStructs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GRASS_COMPUTE_COMPUTESTRUCTS 2 | #define GRASS_COMPUTE_COMPUTESTRUCTS 3 | 4 | #include "Grass_Compute_CommonStructs.hlsl" 5 | 6 | // contains information about the original mesh, which just provides vertex data 7 | struct SourceMeshVertexData 8 | { 9 | float3 positionOS; 10 | float3 normalOS; 11 | float3 tangentOS; 12 | float4 color; 13 | float2 uv; 14 | }; 15 | 16 | GrassBladeTriangle GenerateTriangleData(float3 vertex0, float3 vertex1, float3 vertex2, float2 uv0, float2 uv1, float2 uv2, GrassBladeSpaceData space) 17 | { 18 | GrassBladeVertex point0; 19 | point0.positionOS = vertex0; 20 | point0.uv = uv0; 21 | 22 | GrassBladeVertex point1; 23 | point1.positionOS = vertex1; 24 | point1.uv = uv1; 25 | 26 | GrassBladeVertex point2; 27 | point2.positionOS = vertex2; 28 | point2.uv = uv2; 29 | 30 | GrassBladeTriangle result; 31 | result.points[0] = point0; 32 | result.points[1] = point1; 33 | result.points[2] = point2; 34 | 35 | result.space = space; 36 | 37 | return result; 38 | } 39 | 40 | // information about the shape of the grass blades, only one is passed in per compute shader 41 | struct GrassBladeProperties 42 | { 43 | float width; 44 | float widthVariance; 45 | float height; 46 | float heightVariance; 47 | float rotationRangeX; 48 | float rotationRangeY; 49 | float tipOffsetZ; 50 | float curvature; 51 | }; 52 | 53 | struct IndirectArgs 54 | { 55 | uint verticesPerInstance; 56 | uint instances; 57 | uint startVertexIndex; 58 | uint startInstanceIndex; 59 | }; 60 | 61 | #endif // GRASS_COMPUTE_COMPUTESTRUCTS -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_ComputeStructs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8438016f437644641bda546143402d12 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Fragment.hlsl: -------------------------------------------------------------------------------- 1 | //#include "GrassShaderStructs.hlsl" 2 | #include "../../Grass_Common_GBuffer.hlsl" 3 | 4 | void GrassFragment(PackedVaryingsToPS packedInput, 5 | OUTPUT_GBUFFER( outGBuffer) 6 | #ifdef _DEPTHOFFSET_ON 7 | , out float outputDepth : SV_Depth 8 | #endif 9 | ) 10 | { 11 | // force this to 'none' so unity doesnt try to do any normal flipping 12 | _DoubleSidedConstants = float4(1, 1, 1, 1); 13 | 14 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput); 15 | FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); 16 | 17 | // input.positionSS is SV_Position 18 | PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS); 19 | 20 | #ifdef VARYINGS_NEED_POSITION_WS 21 | float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); 22 | #else 23 | // Unused 24 | float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 25 | #endif 26 | 27 | SurfaceData surfaceData; 28 | BuiltinData builtinData; 29 | GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); 30 | 31 | float3 color = lerp(_GrassBottomColour, _GrassTopColour, input.texCoord0.y); 32 | surfaceData.baseColor = color; 33 | 34 | builtinData.opacity = 0; 35 | 36 | /*GRASS_*/ENCODE_INTO_GBUFFER(surfaceData, builtinData, posInput.positionSS, outGBuffer); 37 | 38 | #ifdef _DEPTHOFFSET_ON 39 | outputDepth = posInput.deviceDepth; 40 | #endif 41 | } 42 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Fragment.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ca058bcec0df074ba96e3a38f6ec0f9 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Properties.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbdc684975c54f84198f54cb1206060a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Shader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18f6b99c1a7975842b9636f23735424e 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_TransformFunctions.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GRASS_COMPUTE_TRANSFORMFUNCTIONS 2 | #define GRASS_COMPUTE_TRANSFORMFUNCTIONS 3 | 4 | // note: this exists because when using drawprocedural, lots of necessary stuff isnt set up properly, such as local to world matrices etc. 5 | // so i set them manually and then use these replacement functions, which have separate defines for whether im drawing procedurally or via a mesh renderer 6 | // most of them are basically copied from unity's shader library 7 | 8 | #include "Grass_Compute_Properties.hlsl" 9 | 10 | // float4x4 _ObjectToWorld; 11 | // float4x4 _WorldToObject; 12 | // float3 _GrassWorldSpaceCameraPos 13 | 14 | // returns a matrix which scales relative to a given point. 15 | // source: https://studylib.net/doc/5892312/scaling-relative-to-a-fixed-point-using-matrix-using-the 16 | float4x4 GetRelativeScaleMatrix(float3 origin, float3 scale) 17 | { 18 | float4x4 relativeScaleMatrix = { { scale.x, 0.0, 0.0, (1 - scale.x) * origin.x }, { 0.0, scale.y, 0.0, (1 - scale.y) * origin.y }, { 0.0, 0.0, scale.z, (1 - scale.z) * origin.z }, { 0.0, 0.0, 0.0, 1.0 } }; 19 | return relativeScaleMatrix; 20 | } 21 | 22 | // returns a matrix which reverses scale relative to a given point. 23 | // source: https://studylib.net/doc/5892312/scaling-relative-to-a-fixed-point-using-matrix-using-the 24 | float4x4 GetInverseRelativeScaleMatrix(float3 origin, float3 scale) 25 | { 26 | return transpose(GetRelativeScaleMatrix(origin, 1 / scale)); 27 | } 28 | 29 | float3 ExtractScale(float4x4 mat) 30 | { 31 | return float3(length(mat._m00_m10_m20), length(mat._m01_m11_m21), length(mat._m02_m12_m22)); 32 | } 33 | 34 | float3 InverseScaleRelative(float3 position, float3 origin, float3 scale) 35 | { 36 | return mul(float4(position, 1), GetInverseRelativeScaleMatrix(origin, scale)).xyz; 37 | } 38 | 39 | float3 ScaleRelative(float3 position, float3 origin, float3 scale) 40 | { 41 | return mul(float4(position, 1), GetRelativeScaleMatrix(origin, scale)).xyz; 42 | } 43 | 44 | #define UNITY_MATRIX_M ApplyCameraTranslationToMatrix(_ObjectToWorld) 45 | 46 | float4x4 Grass_GetObjectToWorldMatrix() 47 | { 48 | #ifdef FROM_PROCEDURAL 49 | return UNITY_MATRIX_M; 50 | #else 51 | return GetObjectToWorldMatrix(); 52 | #endif 53 | } 54 | 55 | float3 Grass_TransformObjectToWorld(float3 positionOS) 56 | { 57 | return mul(Grass_GetObjectToWorldMatrix(), float4(positionOS, 1.0)).xyz; 58 | } 59 | 60 | #endif // GRASS_COMPUTE_TRANSFORMFUNCTIONS -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_TransformFunctions.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: acffebc070943ff45addb232a0020ffe 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Vertex.hlsl: -------------------------------------------------------------------------------- 1 | //#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl" 2 | 3 | #include "../../Grass_Common.hlsl" 4 | //#include "GrassShaderStructs.hlsl" 5 | #include "Grass_Compute_TransformFunctions.hlsl" 6 | #include "Grass_Compute_Properties.hlsl" 7 | 8 | float3 ApplyWindAndDisplacementOS(float3 origin, float3 position, float height) 9 | { 10 | #ifdef GRASS_BLADE_SCALING 11 | // this line removes the scaling from the actual grass blades 12 | position = InverseScaleRelative(position, origin, ExtractScale(Grass_GetObjectToWorldMatrix())); 13 | #endif 14 | 15 | // This return the camera relative position (if enabled) 16 | float3 absoluteVertexPos = GetAbsolutePositionWS(Grass_TransformObjectToWorld(position)); 17 | float3 absolutePos = GetAbsolutePositionWS(Grass_TransformObjectToWorld(origin)); 18 | 19 | //////////////// DISPLACEMENT SPHERES 20 | 21 | float3 totalSphereDisp = float3(0, 0, 0); 22 | //#ifdef APPLY_DISPLACEMENT 23 | for (int i = 0; i < _GrassDisplacementSpheresBufferCount; i++) 24 | { 25 | float3 sphereDisp = float3(0, 0, 0); 26 | 27 | GrassDisplacement displacementData = _GrassDisplacementSpheresBuffer[i]; 28 | float3 displacerPos = displacementData.position; 29 | 30 | float distance = length(displacerPos - absolutePos); 31 | float3 circle = 1 - saturate(distance * displacementData.inverseRadius); 32 | 33 | sphereDisp += (absolutePos - displacerPos) * circle; 34 | sphereDisp = clamp(sphereDisp.xyz * displacementData.power, -0.8, 0.8); 35 | 36 | totalSphereDisp += sphereDisp; 37 | } 38 | //#endif 39 | 40 | absoluteVertexPos += totalSphereDisp * height; 41 | 42 | //////////////// 43 | 44 | //////////////// WIND 45 | 46 | float2 windUV = absolutePos.xz * _WindDistortionMap_ST.xy + _WindDistortionMap_ST.zw + _WindFrequency * _Time.y; 47 | float2 windSample = (tex2Dlod(_WindDistortionMap, float4(windUV, 0, 0)).rg * 2 - 1) * max(0.000001, abs(_WindStrength)); 48 | float3 wind = normalize(float3(windSample.x, windSample.y, 0)); 49 | 50 | absoluteVertexPos += float3(windSample.x, 0, windSample.y) * height; 51 | //////////////// 52 | 53 | return absoluteVertexPos; 54 | } 55 | 56 | #ifdef FROM_PROCEDURAL 57 | #include "Grass_Compute_VertexProcedural.hlsl" 58 | #else 59 | #include "Grass_Compute_VertexMesh.hlsl" 60 | #endif -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_Vertex.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9c4687eac369014ebe43b13330b99eb 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_VertexMesh.hlsl: -------------------------------------------------------------------------------- 1 | // in 'mesh mode' the data just comes from a standard mesh 2 | // todo: write the 'grass origin' into one of the UV channels 3 | PackedVaryingsType GrassVertex(AttributesMesh inputMesh) 4 | { 5 | float3 grassBladeOrigin = float3(inputMesh.uv2.x, inputMesh.uv2.y, inputMesh.uv3.x); 6 | float3 grassBladeVertexPos = inputMesh.positionOS; 7 | float height = inputMesh.uv0.y; 8 | 9 | inputMesh.positionOS = TransformWorldToObject(GetCameraRelativePositionWS(ApplyWindAndDisplacementOS(grassBladeOrigin, grassBladeVertexPos, height))); 10 | 11 | VaryingsType varyingsType; 12 | varyingsType.vmesh = VertMesh(inputMesh); 13 | return PackVaryingsType(varyingsType); 14 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_VertexMesh.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f70c869f15010643ad23497ff43dc0a 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_VertexProcedural.hlsl: -------------------------------------------------------------------------------- 1 | #include "Grass_Compute_CommonStructs.hlsl" 2 | 3 | StructuredBuffer _OutMesh; 4 | 5 | PackedVaryingsType ToPackedVaryingsType(AttributesMesh inputMesh) 6 | { 7 | VaryingsType varyingsType; 8 | varyingsType.vmesh = VertMesh(inputMesh); 9 | return PackVaryingsType(varyingsType); 10 | } 11 | 12 | 13 | // Vertex input attributes 14 | struct Attributes 15 | { 16 | uint vertexID : SV_VertexID; 17 | UNITY_VERTEX_INPUT_INSTANCE_ID 18 | }; 19 | 20 | AttributesMesh GrassToAttributesMesh(Attributes input, GrassBladeVertex vertex, GrassBladeTriangle tri) 21 | { 22 | // Imitate a common vertex vertex. 23 | AttributesMesh am; 24 | am.positionOS = vertex.positionOS; 25 | 26 | #ifdef ATTRIBUTES_NEED_NORMAL 27 | am.normalOS = float3(0, 1, 0);//vertex.normalOS; 28 | #endif 29 | #ifdef ATTRIBUTES_NEED_TANGENT 30 | am.tangentOS = 0; 31 | #endif 32 | //#ifdef ATTRIBUTES_NEED_TEXCOORD0 33 | am.uv0 = vertex.uv; 34 | //#endif 35 | //#ifdef ATTRIBUTES_NEED_TEXCOORD1 36 | am.uv1 = tri.space.uv; 37 | //#endif 38 | #ifdef ATTRIBUTES_NEED_TEXCOORD2 39 | am.uv2 = 0; 40 | #endif 41 | #ifdef ATTRIBUTES_NEED_TEXCOORD3 42 | am.uv3 = 0; 43 | #endif 44 | #ifdef ATTRIBUTES_NEED_COLOR 45 | am.color = 0; 46 | #endif 47 | UNITY_TRANSFER_INSTANCE_ID(input, am); 48 | 49 | return am; 50 | } 51 | 52 | // in 'procedural mode', the vertex data comes from a graphics.drawprocedural 53 | PackedVaryingsType GrassVertex(Attributes input) 54 | { 55 | int vertexID = input.vertexID; 56 | 57 | // get the vertex from the buffer. 58 | // since the buffer is triangles, we need to divide the vertex ID by 3 59 | // to get the triangle, and then modulo by 3 to get the specific vertex on that triangle. 60 | GrassBladeTriangle tri = _OutMesh[vertexID / 3]; 61 | GrassBladeVertex vertex = tri.points[vertexID % 3]; 62 | 63 | float3 grassBladeOrigin = tri.space.positionOS; 64 | float3 grassBladeVertexPos = vertex.positionOS; 65 | float height = vertex.uv.y; 66 | 67 | vertex.positionOS = ApplyWindAndDisplacementOS(grassBladeOrigin, grassBladeVertexPos, height); 68 | 69 | // convert the data into a form HDRP understands 70 | return ToPackedVaryingsType(GrassToAttributesMesh(input, vertex, tri)); 71 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Compute/Shaders/Grass_Compute_VertexProcedural.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 036e9eacd9cfef244a3899ed82458696 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/GrassDisplacementSphere.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using UnityEngine; 4 | 5 | namespace Grass 6 | { 7 | /// 8 | /// Attach this component to an object to make it displace the grass around to to a set radius. 9 | /// 10 | [ExecuteInEditMode] 11 | public class GrassDisplacementSphere : MonoBehaviour 12 | { 13 | private const int MAX_GRASS_DISPLACEMENT_SPHERES = 10; 14 | 15 | private const string BUFFER_NAME = "_GrassDisplacementSpheresBuffer"; 16 | private const string BUFFER_COUNT = "_GrassDisplacementSpheresBufferCount"; 17 | 18 | [SerializeField] 19 | [Min(0f)] 20 | [Tooltip("How far the effect of the displacement extends.")] 21 | private float m_radius = 1; 22 | 23 | [SerializeField] 24 | [Min(0f)] 25 | [Tooltip("How strongly the displacer moves the grass.")] 26 | private float m_power = 1; 27 | 28 | [SerializeField] 29 | private bool m_showGizmo = false; 30 | 31 | private void OnEnable() 32 | { 33 | Register(this); 34 | } 35 | 36 | private void OnDisable()// 37 | { 38 | Deregister(this); 39 | } 40 | 41 | private void Update() 42 | { 43 | if (transform.hasChanged) 44 | { 45 | ResendBufferData(); 46 | transform.hasChanged = false; 47 | } 48 | } 49 | 50 | private void OnValidate() 51 | { 52 | if (enabled) 53 | ResendBufferData(); 54 | } 55 | 56 | #if UNITY_EDITOR 57 | private void OnDrawGizmosSelected() 58 | { 59 | if (!m_showGizmo) 60 | return; 61 | 62 | Color col = Color.white; 63 | col.a = 0.666f; 64 | 65 | Gizmos.color = col; 66 | Gizmos.DrawSphere(transform.position, m_radius); 67 | } 68 | #endif 69 | 70 | public GrassDisplacement GenerateDataStruct() 71 | { 72 | return new GrassDisplacement(transform.position, m_radius, m_power); 73 | } 74 | 75 | #region Static 76 | 77 | private static int m_bufferNameID = -1; 78 | private static int BufferNameID 79 | { 80 | get 81 | { 82 | if (m_bufferNameID == -1) 83 | m_bufferNameID = Shader.PropertyToID(BUFFER_NAME); 84 | 85 | return m_bufferNameID; 86 | } 87 | } 88 | 89 | private static int m_bufferCountID = -1; 90 | private static int BufferCountID 91 | { 92 | get 93 | { 94 | if (m_bufferCountID == -1) 95 | m_bufferCountID = Shader.PropertyToID(BUFFER_COUNT); 96 | 97 | return m_bufferCountID; 98 | } 99 | } 100 | 101 | private static int m_lastFrameUpdated = -1; 102 | 103 | private static ComputeBuffer m_buffer; 104 | 105 | private static HashSet m_allGrassDisplacementSpheres = new HashSet();// 106 | 107 | private static void Register(GrassDisplacementSphere sphere) 108 | { 109 | if (!sphere) 110 | return; 111 | 112 | if (m_allGrassDisplacementSpheres == null) 113 | m_allGrassDisplacementSpheres = new HashSet(); 114 | 115 | if (!m_allGrassDisplacementSpheres.Contains(sphere) && m_allGrassDisplacementSpheres.Count >= MAX_GRASS_DISPLACEMENT_SPHERES) 116 | { 117 | Debug.LogError("Max Grass Displacement Spheres (" + MAX_GRASS_DISPLACEMENT_SPHERES + ") exceeded! Object '" + sphere.name + "' will be ignored!", sphere); 118 | return; 119 | } 120 | 121 | if (m_allGrassDisplacementSpheres.Add(sphere)) 122 | ResendBufferData(); 123 | } 124 | 125 | private static void Deregister(GrassDisplacementSphere sphere) 126 | { 127 | if (!sphere) 128 | return; 129 | 130 | if (m_allGrassDisplacementSpheres != null) 131 | { 132 | m_allGrassDisplacementSpheres.Remove(sphere); 133 | 134 | if (m_allGrassDisplacementSpheres.Count == 0) 135 | { 136 | m_buffer?.Release(); 137 | m_buffer = null; 138 | } 139 | else 140 | { 141 | ResendBufferData(); 142 | } 143 | } 144 | } 145 | 146 | private static void ResendBufferData() 147 | { 148 | int currentFrame = Time.frameCount; 149 | if (m_lastFrameUpdated != -1 && m_lastFrameUpdated == currentFrame) 150 | return; 151 | 152 | m_lastFrameUpdated = currentFrame; 153 | 154 | if (m_buffer == null) 155 | { 156 | m_buffer = new ComputeBuffer(MAX_GRASS_DISPLACEMENT_SPHERES, GrassDisplacement.Stride); 157 | Shader.SetGlobalBuffer(BufferNameID, m_buffer); 158 | } 159 | 160 | Shader.SetGlobalInt(BufferCountID, m_allGrassDisplacementSpheres.Count); 161 | 162 | m_buffer.SetData( 163 | m_allGrassDisplacementSpheres 164 | .Select(sphere => sphere.GenerateDataStruct()) 165 | .ToArray()); 166 | } 167 | 168 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] 169 | private static void ClearStaticData() 170 | { 171 | if (m_allGrassDisplacementSpheres != null) 172 | m_allGrassDisplacementSpheres.Clear(); 173 | 174 | m_buffer?.Release(); 175 | m_buffer = null; 176 | } 177 | 178 | #endregion 179 | } 180 | 181 | public struct GrassDisplacement 182 | { 183 | public const int Stride = sizeof(float) * 5;// 184 | 185 | public Vector3 Position; 186 | public float InverseRadius; 187 | public float Power; 188 | 189 | public GrassDisplacement(Vector3 position, float radius, float power) 190 | { 191 | Position = position; 192 | InverseRadius = radius == 0f ? 0f : 1f / radius; 193 | Power = power; 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/GrassDisplacementSphere.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e7c954ee412c224cbd163d487dd55c6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_Common.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GRASS_COMMON 2 | #define GRASS_COMMON 3 | 4 | #define EPSILON 0.00000001 5 | #define RANDOM_SMOOTHING 4.5 6 | 7 | #include "Grass_CommonStructs.hlsl" 8 | 9 | uniform StructuredBuffer _GrassDisplacementSpheresBuffer : register(t1); 10 | uniform int _GrassDisplacementSpheresBufferCount; 11 | 12 | #define MAX_GRASS_DISPLACEMENT_SPHERES 10 13 | 14 | #ifndef UNITY_COMMON_INCLUDED 15 | 16 | #define PI 3.1415926 17 | 18 | float DegToRad(float deg) 19 | { 20 | return deg * (PI / 180.0); 21 | } 22 | 23 | float RadToDeg(float rad) 24 | { 25 | return rad * (180.0 / PI); 26 | } 27 | 28 | #endif 29 | 30 | // Construct a rotation matrix that rotates around the provided axis, sourced from: 31 | // https://gist.github.com/keijiro/ee439d5e7388f3aafc5296005c8c3f33 32 | float3x3 AngleAxis3x3(float angle, float3 axis) 33 | { 34 | float c, s; 35 | sincos(angle, s, c); 36 | 37 | float t = 1 - c; 38 | float x = axis.x; 39 | float y = axis.y; 40 | float z = axis.z; 41 | 42 | return float3x3( 43 | t * x * x + c, t * x * y - s * z, t * x * z + s * y, 44 | t * x * y + s * z, t * y * y + c, t * y * z - s * x, 45 | t * x * z - s * y, t * y * z + s * x, t * z * z + c 46 | ); 47 | } 48 | 49 | //float3x3 AngleAxisDerp(float3 source, float3 target, float3 axis) 50 | //{ 51 | // axis = abs(axis); 52 | // target -= source; 53 | 54 | // float3 projectedTarget = target - dot(target, axis) * axis; 55 | // float3 forward = normalize(projectedTarget); 56 | 57 | // float3x3 x = AngleAxis3x3(-atan2(forward.y, forward.z), axis); 58 | // float3x3 y = AngleAxis3x3(atan2(forward.x, forward.z), axis); 59 | // float3x3 z = AngleAxis3x3(-atan2(forward.x, forward.y), axis); 60 | 61 | // return y; 62 | //} 63 | 64 | //float GetAngleInvariant(float3 cameraPos, float3 origin, float3 axis) 65 | //{ 66 | // float3 transformedCameraPos = cameraPos - dot(cameraPos, axis) * axis; 67 | // float3 transformedPos = origin - dot(origin, axis) * axis; 68 | // float3 dir = normalize(transformedCameraPos - transformedPos); 69 | // return atan2(dir.z, dir.x); 70 | //} 71 | 72 | //float3x3 AxisBillboard(float3 upAxis, float3 viewDirection) 73 | //{ 74 | // float3 rightAxis = normalize(cross(upAxis, viewDirection)); 75 | // float3 forwardAxis = cross(rightAxis, upAxis); 76 | 77 | // float3x3 result; 78 | // result[0].xyz = rightAxis; 79 | // result[1].xyz = upAxis; 80 | // result[2].xyz = forwardAxis; 81 | 82 | // return result; 83 | //} 84 | 85 | //// Returns a 'pseudo-LookAt' matrix which only rotates around the given axis. 86 | //float3x3 FlatLookAt(float3 source, float3 target, float3 axis) 87 | //{ 88 | // target -= source; 89 | 90 | // float3 projectedTarget = target - dot(target, axis) * axis; 91 | 92 | // float3 forward = normalize(projectedTarget); 93 | // float3 right = cross(axis, forward); 94 | // float3 up = cross(forward, right); 95 | 96 | // float3x3 result; 97 | // result[0].xyz = right; 98 | // result[1].xyz = up; 99 | // result[2].xyz = forward; 100 | 101 | // return result; 102 | //} 103 | 104 | float SignedAngle(float3 from, float3 to, float3 axis) 105 | { 106 | float unsignedAngle = acos(dot(from, to)); 107 | 108 | float cross_x = from.y * to.z - from.z * to.y; 109 | float cross_y = from.z * to.x - from.x * to.z; 110 | float cross_z = from.x * to.y - from.y * to.x; 111 | float signOfAngle = sign(axis.x * cross_x + axis.y * cross_y + axis.z * cross_z); 112 | return unsignedAngle * signOfAngle; 113 | } 114 | 115 | float3 ProjectOnPlane(float3 vec, float3 normal, float3 planePos) 116 | { 117 | return vec - normal * dot(vec, normal) + dot(planePos, normal) * normal; 118 | } 119 | 120 | float GetProjectedAngle(float3 pos, float3 cameraPos, float3 up, float3 right) 121 | { 122 | float3 projectedPoint = ProjectOnPlane(cameraPos, up, pos); 123 | 124 | float3 dir = normalize(projectedPoint - pos); 125 | 126 | return SignedAngle(right, dir, up); 127 | } 128 | 129 | 130 | float randSin(float p) 131 | { 132 | p = sin(p * 0.1031f); 133 | p *= p + 33.33f; 134 | p *= p + p; 135 | return frac(p); 136 | } 137 | 138 | // Simple noise function, sourced from http://answers.unity.com/answers/624136/view.html 139 | // Extended discussion on this function can be found at the following link: 140 | // https://forum.unity.com/threads/am-i-over-complicating-this-random-function.454887/#post-2949326 141 | // Returns a number in the 0...1 range. 142 | float rand(float3 co) 143 | { 144 | return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 53.539))) * 43758.5453); 145 | } 146 | 147 | float rand(float co) 148 | { 149 | return rand(float3(co * 3832.33, co * 11.8322, co * 0.38723)); 150 | } 151 | 152 | float smooth(float val) 153 | { 154 | return (int) (val * RANDOM_SMOOTHING); 155 | 156 | } 157 | 158 | float smoothRand(float3 co) 159 | { 160 | co = float3(smooth(co.x), smooth(co.y), smooth(co.z)); 161 | return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 53.539))) * 43758.5453); 162 | } 163 | 164 | float smoothRand(float co) 165 | { 166 | co = smooth(co); 167 | return rand(float3(co * 3832.33, co * 11.8322, co * 0.38723)); 168 | } 169 | 170 | 171 | int when_eq(float x, float y) 172 | { 173 | return 1 - abs(sign(x - y)); 174 | } 175 | 176 | int when_neq(float x, float y) 177 | { 178 | return abs(sign(x - y)); 179 | } 180 | 181 | int when_gt(float x, float y) 182 | { 183 | return max(sign(x - y), 0); 184 | } 185 | 186 | int when_lt(float x, float y) 187 | { 188 | return max(sign(y - x), 0); 189 | } 190 | 191 | int when_ge(float x, float y) 192 | { 193 | return 1 - when_lt(x, y); 194 | } 195 | 196 | int when_le(float x, float y) 197 | { 198 | return 1 - when_gt(x, y); 199 | } 200 | 201 | int and(int a, int b) 202 | { 203 | return a * b; 204 | } 205 | 206 | int or(int a, int b) 207 | { 208 | return min(a + b, 1); 209 | } 210 | 211 | int xor(int a, int b) 212 | { 213 | return (a + b) % 2; 214 | } 215 | 216 | int not(int a) 217 | { 218 | return 1 - a; 219 | } 220 | 221 | #endif // GRASS_COMMON -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d24e62ed452b594d801b1bac9726cec 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_CommonStructs.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef GRASS_COMMON_STRUCTS 2 | #define GRASS_COMMON_STRUCTS 3 | 4 | struct GrassDisplacement 5 | { 6 | float3 position; 7 | float inverseRadius; 8 | float power; 9 | }; 10 | 11 | #endif // GRASS_COMMON_STRUCTS -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_CommonStructs.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 384b83be4f17f634d9e07e6958e7d017 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_Common_GBuffer.hlsl: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GRASS_COMMON_GBUFFER 3 | #define GRASS_COMMON_GBUFFER 4 | 5 | // Note: 6 | // For standard we have chose to always encode fresnel0. Even when we use metal/baseColor parametrization. This avoid 7 | // compiler optimization problem that was using VGPR to deal with the various combination of metal non metal. 8 | 9 | // For SSS, we move diffusionProfile(4) / subsurfaceMask(4) in GBuffer0.a so the forward SSS code only need to write into one RT 10 | // and the SSS postprocess only need to read one RT 11 | // We duplicate diffusionProfile / subsurfaceMask in GBuffer2.b so the compiler don't need to read the GBuffer0 before PostEvaluateBSDF 12 | // The lighting code have been adapted to only apply diffuseColor at the end. 13 | // This save VGPR as we don' need to keep the GBuffer0 value in register. 14 | 15 | // The layout is also design to only require one RT for the material classification. All the material feature flags are deduced from GBuffer2. 16 | 17 | // Encode SurfaceData (BSDF parameters) into GBuffer 18 | // Must be in sync with RT declared in HDRenderPipeline.cs ::Rebuild 19 | void Grass_EncodeIntoGBuffer( SurfaceData surfaceData 20 | , BuiltinData builtinData 21 | , uint2 positionSS 22 | , out GBufferType0 outGBuffer0 23 | , out GBufferType1 outGBuffer1 24 | , out GBufferType2 outGBuffer2 25 | , out GBufferType3 outGBuffer3 26 | #if GBUFFERMATERIAL_COUNT > 4 27 | , out GBufferType4 outGBuffer4 28 | #endif 29 | #if GBUFFERMATERIAL_COUNT > 5 30 | , out GBufferType5 outGBuffer5 31 | #endif 32 | ) 33 | { 34 | // This encode normalWS and PerceptualSmoothness into GBuffer1 35 | EncodeIntoNormalBuffer(ConvertSurfaceDataToNormalData(surfaceData), positionSS, outGBuffer1); 36 | 37 | // colour, the important bit :O 38 | outGBuffer0 = float4(surfaceData.baseColor, 0.0); //surfaceData.specularOcclusion); 39 | 40 | // fresnel 41 | outGBuffer2 = 0.0; 42 | 43 | // RT3 - 11f:11f:10f 44 | // In deferred we encode emissive color with bakeDiffuseLighting. We don't have the room to store emissiveColor. 45 | // It mean that any futher process that affect bakeDiffuseLighting will also affect emissiveColor, like SSAO for example. 46 | outGBuffer3 = float4(builtinData.bakeDiffuseLighting * surfaceData.ambientOcclusion + builtinData.emissiveColor, 0.0); 47 | 48 | // Pre-expose lighting buffer 49 | outGBuffer3 *= GetCurrentExposureMultiplier(); 50 | 51 | #ifdef LIGHT_LAYERS 52 | // Note: we need to mask out only 8bits of the layer mask before encoding it as otherwise any value > 255 will map to all layers active 53 | OUT_GBUFFER_LIGHT_LAYERS = float4(0.0, 0.0, 0.0, (builtinData.renderingLayers & 0x000000FF) / 255.0); 54 | #endif 55 | 56 | #ifdef SHADOWS_SHADOWMASK 57 | OUT_GBUFFER_SHADOWMASK = BUILTIN_DATA_SHADOW_MASK; 58 | #endif 59 | } 60 | 61 | #ifdef GBUFFERMATERIAL_COUNT 62 | 63 | #if GBUFFERMATERIAL_COUNT == 2 64 | 65 | //#define OUTPUT_GBUFFER(NAME) \ 66 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 67 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1 68 | 69 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1)) 70 | 71 | #elif GBUFFERMATERIAL_COUNT == 3 72 | 73 | //#define OUTPUT_GBUFFER(NAME) \ 74 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 75 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 76 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2 77 | 78 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME,0), MERGE_NAME(NAME,1), MERGE_NAME(NAME,2)) 79 | 80 | #elif GBUFFERMATERIAL_COUNT == 4 81 | 82 | //#define OUTPUT_GBUFFER(NAME) \ 83 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 84 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 85 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ 86 | // out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3 87 | 88 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3)) 89 | 90 | #elif GBUFFERMATERIAL_COUNT == 5 91 | 92 | //#define OUTPUT_GBUFFER(NAME) \ 93 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 94 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 95 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ 96 | // out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \ 97 | // out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4 98 | 99 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4)) 100 | 101 | #elif GBUFFERMATERIAL_COUNT == 6 102 | 103 | //#define OUTPUT_GBUFFER(NAME) \ 104 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 105 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 106 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ 107 | // out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \ 108 | // out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4, \ 109 | // out GBufferType5 MERGE_NAME(NAME, 5) : SV_Target5 110 | 111 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), MERGE_NAME(NAME, 5)) 112 | 113 | #elif GBUFFERMATERIAL_COUNT == 7 114 | 115 | //#define OUTPUT_GBUFFER(NAME) \ 116 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 117 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 118 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ 119 | // out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \ 120 | // out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4, \ 121 | // out GBufferType5 MERGE_NAME(NAME, 5) : SV_Target5, \ 122 | // out GBufferType6 MERGE_NAME(NAME, 6) : SV_Target6 123 | 124 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), MERGE_NAME(NAME, 5), MERGE_NAME(NAME, 6)) 125 | 126 | #elif GBUFFERMATERIAL_COUNT == 8 127 | 128 | //#define OUTPUT_GBUFFER(NAME) \ 129 | // out GBufferType0 MERGE_NAME(NAME, 0) : SV_Target0, \ 130 | // out GBufferType1 MERGE_NAME(NAME, 1) : SV_Target1, \ 131 | // out GBufferType2 MERGE_NAME(NAME, 2) : SV_Target2, \ 132 | // out GBufferType3 MERGE_NAME(NAME, 3) : SV_Target3, \ 133 | // out GBufferType4 MERGE_NAME(NAME, 4) : SV_Target4, \ 134 | // out GBufferType5 MERGE_NAME(NAME, 5) : SV_Target5, \ 135 | // out GBufferType6 MERGE_NAME(NAME, 6) : SV_Target6, \ 136 | // out GBufferType7 MERGE_NAME(NAME, 7) : SV_Target7 137 | 138 | #define GRASS_ENCODE_INTO_GBUFFER(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, NAME) Grass_EncodeIntoGBuffer(SURFACE_DATA, BUILTIN_DATA, UNPOSITIONSS, MERGE_NAME(NAME, 0), MERGE_NAME(NAME, 1), MERGE_NAME(NAME, 2), MERGE_NAME(NAME, 3), MERGE_NAME(NAME, 4), MERGE_NAME(NAME, 5), MERGE_NAME(NAME, 6), MERGE_NAME(NAME, 7)) 139 | 140 | #endif 141 | 142 | #endif 143 | 144 | #endif // GRASS_COMMON_GBUFFER -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Grass_Common_GBuffer.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49e3d18d56b17534c9c674157a3a0c88 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Mover.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Grass 6 | { 7 | [ExecuteInEditMode] 8 | public class Mover : MonoBehaviour 9 | { 10 | [SerializeField] 11 | private Vector3 m_centre = Vector3.zero; 12 | 13 | [SerializeField] 14 | [Min(0f)] 15 | private float m_radius = 1f; 16 | 17 | [SerializeField] 18 | private float m_speed = 1f; 19 | 20 | private float m_currentPos = 0f; 21 | 22 | private void Reset() => m_currentPos = 0f; 23 | 24 | private void Update() 25 | { 26 | m_currentPos += m_speed * Time.deltaTime; 27 | 28 | Vector3 pos = m_centre + m_radius * new Vector3(Mathf.Cos(m_currentPos * Mathf.PI), 0f, Mathf.Sin(m_currentPos * Mathf.PI)); 29 | 30 | transform.position = pos; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Mover.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c80ee62e2deb324286969590e762942 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 274b808704ec25944bf9c1d7ce54b8ce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Scenes/Grass_Compute_TestScene.unity: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a36092961ba6843b48437a05f6b6b24be9ecaa6e9ea3acefd82574b53fc34cdc 3 | size 19941 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Scenes/Grass_Compute_TestScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c849a37adcf2c2f41845abb440a653a4 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Scenes/Grass_TesselationGeometry_Scene.unity: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2d7023f614c7b25e657532837304f61b6d42dbbcf3b57f182a0628ea26f57131 3 | size 51716 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Scenes/Grass_TesselationGeometry_Scene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd6cde9fb7fadd241839a0caa07ec0d6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 722a29b588857494fa05ad43eb7fcac8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/GrassShader.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b3975e57b3254470ede3154a837ab1f16bef0d2b5e1a6b0db6a2f324a93191e8 3 | size 775481 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/GrassShader.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab2319714f2de4940b886d6586cac7ef 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc8a50109b51f4d4b85bde7673afdfac 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/AlienGrass.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a016b2773f5954049a8e72c6f06c7b53 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/CartoonyGrass.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e145eed405ec5a04bb8fb127210ec883 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c9702cc1109f58499039b412916b95d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/NormalGround.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: NormalGround 11 | m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3} 12 | m_ShaderKeywords: _DISABLE_DECALS _DISABLE_SSR _NORMALMAP_TANGENT_SPACE 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: 19 | - DistortionVectors 20 | - MOTIONVECTORS 21 | - TransparentDepthPrepass 22 | - TransparentDepthPostpass 23 | - TransparentBackface 24 | m_SavedProperties: 25 | serializedVersion: 3 26 | m_TexEnvs: 27 | - _AnisotropyMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _BaseColorMap: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _BentNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _BentNormalMapOS: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _CoatMaskMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _DetailMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _DistortionVectorMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _EmissiveColorMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _HeightMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _IridescenceMaskMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _IridescenceThicknessMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - _MainTex: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - _MaskMap: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - _NormalMap: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | - _NormalMapOS: 84 | m_Texture: {fileID: 0} 85 | m_Scale: {x: 1, y: 1} 86 | m_Offset: {x: 0, y: 0} 87 | - _SpecularColorMap: 88 | m_Texture: {fileID: 0} 89 | m_Scale: {x: 1, y: 1} 90 | m_Offset: {x: 0, y: 0} 91 | - _SubsurfaceMaskMap: 92 | m_Texture: {fileID: 0} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | - _TangentMap: 96 | m_Texture: {fileID: 0} 97 | m_Scale: {x: 1, y: 1} 98 | m_Offset: {x: 0, y: 0} 99 | - _TangentMapOS: 100 | m_Texture: {fileID: 0} 101 | m_Scale: {x: 1, y: 1} 102 | m_Offset: {x: 0, y: 0} 103 | - _ThicknessMap: 104 | m_Texture: {fileID: 0} 105 | m_Scale: {x: 1, y: 1} 106 | m_Offset: {x: 0, y: 0} 107 | - _TransmittanceColorMap: 108 | m_Texture: {fileID: 0} 109 | m_Scale: {x: 1, y: 1} 110 | m_Offset: {x: 0, y: 0} 111 | m_Floats: 112 | - _AORemapMax: 1 113 | - _AORemapMin: 0 114 | - _ATDistance: 1 115 | - _AddPrecomputedVelocity: 0 116 | - _AlbedoAffectEmissive: 0 117 | - _AlphaCutoff: 0.5 118 | - _AlphaCutoffEnable: 0 119 | - _AlphaCutoffPostpass: 0.5 120 | - _AlphaCutoffPrepass: 0.5 121 | - _AlphaCutoffShadow: 0.5 122 | - _AlphaDstBlend: 0 123 | - _AlphaSrcBlend: 1 124 | - _Anisotropy: 0 125 | - _BlendMode: 0 126 | - _CoatMask: 0 127 | - _CullMode: 2 128 | - _CullModeForward: 2 129 | - _Cutoff: 0.5 130 | - _DepthOffsetEnable: 0 131 | - _DetailAlbedoScale: 1 132 | - _DetailNormalScale: 1 133 | - _DetailSmoothnessScale: 1 134 | - _DiffusionProfile: 0 135 | - _DiffusionProfileHash: 0 136 | - _DisplacementLockObjectScale: 1 137 | - _DisplacementLockTilingScale: 1 138 | - _DisplacementMode: 0 139 | - _DistortionBlendMode: 0 140 | - _DistortionBlurBlendMode: 0 141 | - _DistortionBlurDstBlend: 1 142 | - _DistortionBlurRemapMax: 1 143 | - _DistortionBlurRemapMin: 0 144 | - _DistortionBlurScale: 1 145 | - _DistortionBlurSrcBlend: 1 146 | - _DistortionDepthTest: 1 147 | - _DistortionDstBlend: 1 148 | - _DistortionEnable: 0 149 | - _DistortionScale: 1 150 | - _DistortionSrcBlend: 1 151 | - _DistortionVectorBias: -1 152 | - _DistortionVectorScale: 2 153 | - _DoubleSidedEnable: 0 154 | - _DoubleSidedNormalMode: 1 155 | - _DstBlend: 0 156 | - _EmissiveColorMode: 1 157 | - _EmissiveExposureWeight: 1 158 | - _EmissiveIntensity: 1 159 | - _EmissiveIntensityUnit: 0 160 | - _EnableBlendModePreserveSpecularLighting: 1 161 | - _EnableFogOnTransparent: 1 162 | - _EnableGeometricSpecularAA: 0 163 | - _EnergyConservingSpecularColor: 1 164 | - _HeightAmplitude: 0.02 165 | - _HeightCenter: 0.5 166 | - _HeightMapParametrization: 0 167 | - _HeightMax: 1 168 | - _HeightMin: -1 169 | - _HeightOffset: 0 170 | - _HeightPoMAmplitude: 2 171 | - _HeightTessAmplitude: 2 172 | - _HeightTessCenter: 0.5 173 | - _InvTilingScale: 1 174 | - _Ior: 1.5 175 | - _IridescenceMask: 1 176 | - _IridescenceThickness: 1 177 | - _LinkDetailsWithBase: 1 178 | - _MaterialID: 1 179 | - _Metallic: 0 180 | - _NormalMapSpace: 0 181 | - _NormalScale: 1 182 | - _PPDLodThreshold: 5 183 | - _PPDMaxSamples: 15 184 | - _PPDMinSamples: 5 185 | - _PPDPrimitiveLength: 1 186 | - _PPDPrimitiveWidth: 1 187 | - _ReceivesSSR: 0 188 | - _RefractionModel: 0 189 | - _SSRefractionProjectionModel: 0 190 | - _Smoothness: 0.5 191 | - _SmoothnessRemapMax: 1 192 | - _SmoothnessRemapMin: 0 193 | - _SpecularAAScreenSpaceVariance: 0.1 194 | - _SpecularAAThreshold: 0.2 195 | - _SpecularOcclusionMode: 1 196 | - _SrcBlend: 1 197 | - _StencilRef: 0 198 | - _StencilRefDepth: 0 199 | - _StencilRefDistortionVec: 4 200 | - _StencilRefGBuffer: 2 201 | - _StencilRefMV: 32 202 | - _StencilWriteMask: 6 203 | - _StencilWriteMaskDepth: 8 204 | - _StencilWriteMaskDistortionVec: 4 205 | - _StencilWriteMaskGBuffer: 14 206 | - _StencilWriteMaskMV: 40 207 | - _SubsurfaceMask: 1 208 | - _SupportDecals: 0 209 | - _SurfaceType: 0 210 | - _TexWorldScale: 1 211 | - _TexWorldScaleEmissive: 1 212 | - _Thickness: 1 213 | - _TransmissionEnable: 1 214 | - _TransparentBackfaceEnable: 0 215 | - _TransparentCullMode: 2 216 | - _TransparentDepthPostpassEnable: 0 217 | - _TransparentDepthPrepassEnable: 0 218 | - _TransparentSortPriority: 0 219 | - _TransparentWritingMotionVec: 0 220 | - _TransparentZWrite: 0 221 | - _UVBase: 0 222 | - _UVDetail: 0 223 | - _UVEmissive: 0 224 | - _UseEmissiveIntensity: 0 225 | - _UseShadowThreshold: 0 226 | - _ZTestDepthEqualForOpaque: 3 227 | - _ZTestGBuffer: 4 228 | - _ZTestModeDistortion: 4 229 | - _ZTestTransparent: 4 230 | - _ZWrite: 1 231 | m_Colors: 232 | - _BaseColor: {r: 0, g: 0.17924523, b: 0, a: 1} 233 | - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} 234 | - _Color: {r: 0, g: 0.1792452, b: 0, a: 1} 235 | - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} 236 | - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} 237 | - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} 238 | - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} 239 | - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} 240 | - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} 241 | - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 242 | - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} 243 | - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 244 | - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} 245 | - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} 246 | - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} 247 | - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} 248 | --- !u!114 &5734998384965385983 249 | MonoBehaviour: 250 | m_ObjectHideFlags: 11 251 | m_CorrespondingSourceObject: {fileID: 0} 252 | m_PrefabInstance: {fileID: 0} 253 | m_PrefabAsset: {fileID: 0} 254 | m_GameObject: {fileID: 0} 255 | m_Enabled: 1 256 | m_EditorHideFlags: 0 257 | m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} 258 | m_Name: 259 | m_EditorClassIdentifier: 260 | version: 2 261 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/NormalGround.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da7208c05e27ba14c9aa3c5e108f03e4 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/RedGround.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: RedGround 11 | m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3} 12 | m_ShaderKeywords: _DISABLE_DECALS _DISABLE_SSR _NORMALMAP_TANGENT_SPACE 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: 19 | - DistortionVectors 20 | - MOTIONVECTORS 21 | - TransparentDepthPrepass 22 | - TransparentDepthPostpass 23 | - TransparentBackface 24 | m_SavedProperties: 25 | serializedVersion: 3 26 | m_TexEnvs: 27 | - _AnisotropyMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _BaseColorMap: 32 | m_Texture: {fileID: 0} 33 | m_Scale: {x: 1, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _BentNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _BentNormalMapOS: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _CoatMaskMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _DetailMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _DistortionVectorMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _EmissiveColorMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _HeightMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _IridescenceMaskMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _IridescenceThicknessMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - _MainTex: 72 | m_Texture: {fileID: 0} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - _MaskMap: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - _NormalMap: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | - _NormalMapOS: 84 | m_Texture: {fileID: 0} 85 | m_Scale: {x: 1, y: 1} 86 | m_Offset: {x: 0, y: 0} 87 | - _SpecularColorMap: 88 | m_Texture: {fileID: 0} 89 | m_Scale: {x: 1, y: 1} 90 | m_Offset: {x: 0, y: 0} 91 | - _SubsurfaceMaskMap: 92 | m_Texture: {fileID: 0} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | - _TangentMap: 96 | m_Texture: {fileID: 0} 97 | m_Scale: {x: 1, y: 1} 98 | m_Offset: {x: 0, y: 0} 99 | - _TangentMapOS: 100 | m_Texture: {fileID: 0} 101 | m_Scale: {x: 1, y: 1} 102 | m_Offset: {x: 0, y: 0} 103 | - _ThicknessMap: 104 | m_Texture: {fileID: 0} 105 | m_Scale: {x: 1, y: 1} 106 | m_Offset: {x: 0, y: 0} 107 | - _TransmittanceColorMap: 108 | m_Texture: {fileID: 0} 109 | m_Scale: {x: 1, y: 1} 110 | m_Offset: {x: 0, y: 0} 111 | m_Floats: 112 | - _AORemapMax: 1 113 | - _AORemapMin: 0 114 | - _ATDistance: 1 115 | - _AddPrecomputedVelocity: 0 116 | - _AlbedoAffectEmissive: 0 117 | - _AlphaCutoff: 0.5 118 | - _AlphaCutoffEnable: 0 119 | - _AlphaCutoffPostpass: 0.5 120 | - _AlphaCutoffPrepass: 0.5 121 | - _AlphaCutoffShadow: 0.5 122 | - _AlphaDstBlend: 0 123 | - _AlphaSrcBlend: 1 124 | - _Anisotropy: 0 125 | - _BlendMode: 0 126 | - _CoatMask: 0 127 | - _CullMode: 2 128 | - _CullModeForward: 2 129 | - _Cutoff: 0.5 130 | - _DepthOffsetEnable: 0 131 | - _DetailAlbedoScale: 1 132 | - _DetailNormalScale: 1 133 | - _DetailSmoothnessScale: 1 134 | - _DiffusionProfile: 0 135 | - _DiffusionProfileHash: 0 136 | - _DisplacementLockObjectScale: 1 137 | - _DisplacementLockTilingScale: 1 138 | - _DisplacementMode: 0 139 | - _DistortionBlendMode: 0 140 | - _DistortionBlurBlendMode: 0 141 | - _DistortionBlurDstBlend: 1 142 | - _DistortionBlurRemapMax: 1 143 | - _DistortionBlurRemapMin: 0 144 | - _DistortionBlurScale: 1 145 | - _DistortionBlurSrcBlend: 1 146 | - _DistortionDepthTest: 1 147 | - _DistortionDstBlend: 1 148 | - _DistortionEnable: 0 149 | - _DistortionScale: 1 150 | - _DistortionSrcBlend: 1 151 | - _DistortionVectorBias: -1 152 | - _DistortionVectorScale: 2 153 | - _DoubleSidedEnable: 0 154 | - _DoubleSidedNormalMode: 1 155 | - _DstBlend: 0 156 | - _EmissiveColorMode: 1 157 | - _EmissiveExposureWeight: 1 158 | - _EmissiveIntensity: 1 159 | - _EmissiveIntensityUnit: 0 160 | - _EnableBlendModePreserveSpecularLighting: 1 161 | - _EnableFogOnTransparent: 1 162 | - _EnableGeometricSpecularAA: 0 163 | - _EnergyConservingSpecularColor: 1 164 | - _HeightAmplitude: 0.02 165 | - _HeightCenter: 0.5 166 | - _HeightMapParametrization: 0 167 | - _HeightMax: 1 168 | - _HeightMin: -1 169 | - _HeightOffset: 0 170 | - _HeightPoMAmplitude: 2 171 | - _HeightTessAmplitude: 2 172 | - _HeightTessCenter: 0.5 173 | - _InvTilingScale: 1 174 | - _Ior: 1.5 175 | - _IridescenceMask: 1 176 | - _IridescenceThickness: 1 177 | - _LinkDetailsWithBase: 1 178 | - _MaterialID: 1 179 | - _Metallic: 0 180 | - _NormalMapSpace: 0 181 | - _NormalScale: 1 182 | - _PPDLodThreshold: 5 183 | - _PPDMaxSamples: 15 184 | - _PPDMinSamples: 5 185 | - _PPDPrimitiveLength: 1 186 | - _PPDPrimitiveWidth: 1 187 | - _ReceivesSSR: 0 188 | - _RefractionModel: 0 189 | - _SSRefractionProjectionModel: 0 190 | - _Smoothness: 0.5 191 | - _SmoothnessRemapMax: 1 192 | - _SmoothnessRemapMin: 0 193 | - _SpecularAAScreenSpaceVariance: 0.1 194 | - _SpecularAAThreshold: 0.2 195 | - _SpecularOcclusionMode: 1 196 | - _SrcBlend: 1 197 | - _StencilRef: 0 198 | - _StencilRefDepth: 0 199 | - _StencilRefDistortionVec: 4 200 | - _StencilRefGBuffer: 2 201 | - _StencilRefMV: 32 202 | - _StencilWriteMask: 6 203 | - _StencilWriteMaskDepth: 8 204 | - _StencilWriteMaskDistortionVec: 4 205 | - _StencilWriteMaskGBuffer: 14 206 | - _StencilWriteMaskMV: 40 207 | - _SubsurfaceMask: 1 208 | - _SupportDecals: 0 209 | - _SurfaceType: 0 210 | - _TexWorldScale: 1 211 | - _TexWorldScaleEmissive: 1 212 | - _Thickness: 1 213 | - _TransmissionEnable: 1 214 | - _TransparentBackfaceEnable: 0 215 | - _TransparentCullMode: 2 216 | - _TransparentDepthPostpassEnable: 0 217 | - _TransparentDepthPrepassEnable: 0 218 | - _TransparentSortPriority: 0 219 | - _TransparentWritingMotionVec: 0 220 | - _TransparentZWrite: 0 221 | - _UVBase: 0 222 | - _UVDetail: 0 223 | - _UVEmissive: 0 224 | - _UseEmissiveIntensity: 0 225 | - _UseShadowThreshold: 0 226 | - _ZTestDepthEqualForOpaque: 3 227 | - _ZTestGBuffer: 4 228 | - _ZTestModeDistortion: 4 229 | - _ZTestTransparent: 4 230 | - _ZWrite: 1 231 | m_Colors: 232 | - _BaseColor: {r: 0.34947434, g: 0.048104316, b: 0.4433962, a: 1} 233 | - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} 234 | - _Color: {r: 0.34947428, g: 0.048104294, b: 0.44339618, a: 1} 235 | - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} 236 | - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} 237 | - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} 238 | - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} 239 | - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} 240 | - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} 241 | - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 242 | - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} 243 | - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 244 | - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} 245 | - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} 246 | - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} 247 | - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} 248 | --- !u!114 &5734998384965385983 249 | MonoBehaviour: 250 | m_ObjectHideFlags: 11 251 | m_CorrespondingSourceObject: {fileID: 0} 252 | m_PrefabInstance: {fileID: 0} 253 | m_PrefabAsset: {fileID: 0} 254 | m_GameObject: {fileID: 0} 255 | m_Enabled: 1 256 | m_EditorHideFlags: 0 257 | m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} 258 | m_Name: 259 | m_EditorClassIdentifier: 260 | version: 2 261 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/RedGround.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a5d0226a36f85c4e8d7628ba91c065d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/Soil.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Soil 11 | m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3} 12 | m_ShaderKeywords: _DISABLE_DECALS _DISABLE_SSR _NORMALMAP_TANGENT_SPACE 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: 19 | - DistortionVectors 20 | - MOTIONVECTORS 21 | - TransparentDepthPrepass 22 | - TransparentDepthPostpass 23 | - TransparentBackface 24 | m_SavedProperties: 25 | serializedVersion: 3 26 | m_TexEnvs: 27 | - _AnisotropyMap: 28 | m_Texture: {fileID: 0} 29 | m_Scale: {x: 1, y: 1} 30 | m_Offset: {x: 0, y: 0} 31 | - _BaseColorMap: 32 | m_Texture: {fileID: 2800000, guid: 527026e958cb93b4ea1bc984ff7f85de, type: 3} 33 | m_Scale: {x: 1.8, y: 1} 34 | m_Offset: {x: 0, y: 0} 35 | - _BentNormalMap: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | - _BentNormalMapOS: 40 | m_Texture: {fileID: 0} 41 | m_Scale: {x: 1, y: 1} 42 | m_Offset: {x: 0, y: 0} 43 | - _CoatMaskMap: 44 | m_Texture: {fileID: 0} 45 | m_Scale: {x: 1, y: 1} 46 | m_Offset: {x: 0, y: 0} 47 | - _DetailMap: 48 | m_Texture: {fileID: 0} 49 | m_Scale: {x: 1, y: 1} 50 | m_Offset: {x: 0, y: 0} 51 | - _DistortionVectorMap: 52 | m_Texture: {fileID: 0} 53 | m_Scale: {x: 1, y: 1} 54 | m_Offset: {x: 0, y: 0} 55 | - _EmissiveColorMap: 56 | m_Texture: {fileID: 0} 57 | m_Scale: {x: 1, y: 1} 58 | m_Offset: {x: 0, y: 0} 59 | - _HeightMap: 60 | m_Texture: {fileID: 0} 61 | m_Scale: {x: 1, y: 1} 62 | m_Offset: {x: 0, y: 0} 63 | - _IridescenceMaskMap: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | - _IridescenceThicknessMap: 68 | m_Texture: {fileID: 0} 69 | m_Scale: {x: 1, y: 1} 70 | m_Offset: {x: 0, y: 0} 71 | - _MainTex: 72 | m_Texture: {fileID: 2800000, guid: 527026e958cb93b4ea1bc984ff7f85de, type: 3} 73 | m_Scale: {x: 1, y: 1} 74 | m_Offset: {x: 0, y: 0} 75 | - _MaskMap: 76 | m_Texture: {fileID: 0} 77 | m_Scale: {x: 1, y: 1} 78 | m_Offset: {x: 0, y: 0} 79 | - _NormalMap: 80 | m_Texture: {fileID: 0} 81 | m_Scale: {x: 1, y: 1} 82 | m_Offset: {x: 0, y: 0} 83 | - _NormalMapOS: 84 | m_Texture: {fileID: 0} 85 | m_Scale: {x: 1, y: 1} 86 | m_Offset: {x: 0, y: 0} 87 | - _SpecularColorMap: 88 | m_Texture: {fileID: 0} 89 | m_Scale: {x: 1, y: 1} 90 | m_Offset: {x: 0, y: 0} 91 | - _SubsurfaceMaskMap: 92 | m_Texture: {fileID: 0} 93 | m_Scale: {x: 1, y: 1} 94 | m_Offset: {x: 0, y: 0} 95 | - _TangentMap: 96 | m_Texture: {fileID: 0} 97 | m_Scale: {x: 1, y: 1} 98 | m_Offset: {x: 0, y: 0} 99 | - _TangentMapOS: 100 | m_Texture: {fileID: 0} 101 | m_Scale: {x: 1, y: 1} 102 | m_Offset: {x: 0, y: 0} 103 | - _ThicknessMap: 104 | m_Texture: {fileID: 0} 105 | m_Scale: {x: 1, y: 1} 106 | m_Offset: {x: 0, y: 0} 107 | - _TransmittanceColorMap: 108 | m_Texture: {fileID: 0} 109 | m_Scale: {x: 1, y: 1} 110 | m_Offset: {x: 0, y: 0} 111 | m_Floats: 112 | - _AORemapMax: 1 113 | - _AORemapMin: 0 114 | - _ATDistance: 1 115 | - _AddPrecomputedVelocity: 0 116 | - _AlbedoAffectEmissive: 0 117 | - _AlphaCutoff: 0.5 118 | - _AlphaCutoffEnable: 0 119 | - _AlphaCutoffPostpass: 0.5 120 | - _AlphaCutoffPrepass: 0.5 121 | - _AlphaCutoffShadow: 0.5 122 | - _AlphaDstBlend: 0 123 | - _AlphaSrcBlend: 1 124 | - _Anisotropy: 0 125 | - _BlendMode: 0 126 | - _CoatMask: 0 127 | - _CullMode: 2 128 | - _CullModeForward: 2 129 | - _Cutoff: 0.5 130 | - _DepthOffsetEnable: 0 131 | - _DetailAlbedoScale: 1 132 | - _DetailNormalScale: 1 133 | - _DetailSmoothnessScale: 1 134 | - _DiffusionProfile: 0 135 | - _DiffusionProfileHash: 0 136 | - _DisplacementLockObjectScale: 1 137 | - _DisplacementLockTilingScale: 1 138 | - _DisplacementMode: 0 139 | - _DistortionBlendMode: 0 140 | - _DistortionBlurBlendMode: 0 141 | - _DistortionBlurDstBlend: 1 142 | - _DistortionBlurRemapMax: 1 143 | - _DistortionBlurRemapMin: 0 144 | - _DistortionBlurScale: 1 145 | - _DistortionBlurSrcBlend: 1 146 | - _DistortionDepthTest: 1 147 | - _DistortionDstBlend: 1 148 | - _DistortionEnable: 0 149 | - _DistortionScale: 1 150 | - _DistortionSrcBlend: 1 151 | - _DistortionVectorBias: -1 152 | - _DistortionVectorScale: 2 153 | - _DoubleSidedEnable: 0 154 | - _DoubleSidedNormalMode: 1 155 | - _DstBlend: 0 156 | - _EmissiveColorMode: 1 157 | - _EmissiveExposureWeight: 1 158 | - _EmissiveIntensity: 1 159 | - _EmissiveIntensityUnit: 0 160 | - _EnableBlendModePreserveSpecularLighting: 1 161 | - _EnableFogOnTransparent: 1 162 | - _EnableGeometricSpecularAA: 0 163 | - _EnergyConservingSpecularColor: 1 164 | - _HeightAmplitude: 0.02 165 | - _HeightCenter: 0.5 166 | - _HeightMapParametrization: 0 167 | - _HeightMax: 1 168 | - _HeightMin: -1 169 | - _HeightOffset: 0 170 | - _HeightPoMAmplitude: 2 171 | - _HeightTessAmplitude: 2 172 | - _HeightTessCenter: 0.5 173 | - _InvTilingScale: 0.71428573 174 | - _Ior: 1.5 175 | - _IridescenceMask: 1 176 | - _IridescenceThickness: 1 177 | - _LinkDetailsWithBase: 1 178 | - _MaterialID: 1 179 | - _Metallic: 0.883 180 | - _NormalMapSpace: 0 181 | - _NormalScale: 1 182 | - _PPDLodThreshold: 5 183 | - _PPDMaxSamples: 15 184 | - _PPDMinSamples: 5 185 | - _PPDPrimitiveLength: 1 186 | - _PPDPrimitiveWidth: 1 187 | - _ReceivesSSR: 0 188 | - _RefractionModel: 0 189 | - _SSRefractionProjectionModel: 0 190 | - _Smoothness: 0 191 | - _SmoothnessRemapMax: 1 192 | - _SmoothnessRemapMin: 0 193 | - _SpecularAAScreenSpaceVariance: 0.1 194 | - _SpecularAAThreshold: 0.2 195 | - _SpecularOcclusionMode: 1 196 | - _SrcBlend: 1 197 | - _StencilRef: 0 198 | - _StencilRefDepth: 0 199 | - _StencilRefDistortionVec: 4 200 | - _StencilRefGBuffer: 2 201 | - _StencilRefMV: 32 202 | - _StencilWriteMask: 6 203 | - _StencilWriteMaskDepth: 8 204 | - _StencilWriteMaskDistortionVec: 4 205 | - _StencilWriteMaskGBuffer: 14 206 | - _StencilWriteMaskMV: 40 207 | - _SubsurfaceMask: 1 208 | - _SupportDecals: 0 209 | - _SurfaceType: 0 210 | - _TexWorldScale: 1 211 | - _TexWorldScaleEmissive: 1 212 | - _Thickness: 1 213 | - _TransmissionEnable: 1 214 | - _TransparentBackfaceEnable: 0 215 | - _TransparentCullMode: 2 216 | - _TransparentDepthPostpassEnable: 0 217 | - _TransparentDepthPrepassEnable: 0 218 | - _TransparentSortPriority: 0 219 | - _TransparentWritingMotionVec: 0 220 | - _TransparentZWrite: 0 221 | - _UVBase: 0 222 | - _UVDetail: 0 223 | - _UVEmissive: 0 224 | - _UseEmissiveIntensity: 0 225 | - _UseShadowThreshold: 0 226 | - _ZTestDepthEqualForOpaque: 3 227 | - _ZTestGBuffer: 4 228 | - _ZTestModeDistortion: 4 229 | - _ZTestTransparent: 4 230 | - _ZWrite: 1 231 | m_Colors: 232 | - _BaseColor: {r: 1, g: 1, b: 1, a: 1} 233 | - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} 234 | - _Color: {r: 1, g: 1, b: 1, a: 1} 235 | - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} 236 | - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} 237 | - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} 238 | - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} 239 | - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} 240 | - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} 241 | - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 242 | - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} 243 | - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} 244 | - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} 245 | - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} 246 | - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} 247 | - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} 248 | --- !u!114 &6939720239304055979 249 | MonoBehaviour: 250 | m_ObjectHideFlags: 11 251 | m_CorrespondingSourceObject: {fileID: 0} 252 | m_PrefabInstance: {fileID: 0} 253 | m_PrefabAsset: {fileID: 0} 254 | m_GameObject: {fileID: 0} 255 | m_Enabled: 1 256 | m_EditorHideFlags: 0 257 | m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} 258 | m_Name: 259 | m_EditorClassIdentifier: 260 | version: 2 261 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/Ground/Soil.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 121c0b76b63d31d41a9cb564f7ebad26 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/LawnGrass.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: daa21b6504271fe4b8b9bf0d7dc0a5ea 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Materials/WildGrass.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b57368107a5790341ac4f0f453988bad 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb1c4167faa85d94db39083606fb08ba 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e14b76641f6820e4ba71a2889c431383 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/ColourOptionUIBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering.HighDefinition; 5 | using UnityEngine.Rendering; 6 | using UnityEditor; 7 | 8 | using static Grass.Editor.HDMaterialProperties; 9 | 10 | namespace Grass.Editor 11 | { 12 | class ColourOptionUIBlock : MaterialUIBlock 13 | { 14 | static class Styles 15 | { 16 | public const string optionText = "Colour Options"; 17 | 18 | public static GUIContent grassTextureText = new GUIContent("Grass Colours", "Use this texture to colour the grass, and the two colours to modify the bottom and top of the grass blades respectively."); 19 | public static GUIContent grassFieldTextureText = new GUIContent("Grass Field Texture", "Apply a texture to the entire field of grass."); 20 | public static GUIContent metallicText = new GUIContent("Metallic", "Controls the scale factor for the material's metallic effect."); 21 | public static GUIContent smoothnessText = new GUIContent("Smoothness", "Controls the scale factor for the material's smoothness."); 22 | } 23 | 24 | private MaterialProperty[] m_grassBottomColourProperty = new MaterialProperty[kMaxLayerCount]; 25 | private const string GRASS_BOTTOM_COLOUR_PROPERTY = "_GrassBottomColour"; 26 | 27 | private MaterialProperty[] m_grassTopColourProperty = new MaterialProperty[kMaxLayerCount]; 28 | private const string GRASS_TOP_COLOUR_PROPERTY = "_GrassTopColour"; 29 | 30 | private MaterialProperty[] m_fieldTextureProperty = new MaterialProperty[kMaxLayerCount]; 31 | private const string FIELD_TEXTURE_PROPERTY = "_FieldTexture"; 32 | 33 | private MaterialProperty[] m_bladeTextureProperty = new MaterialProperty[kMaxLayerCount]; 34 | private const string BLADE_TEXTURE_PROPERTY = "_BladeTexture"; 35 | 36 | MaterialProperty[] m_metallicProperty = new MaterialProperty[kMaxLayerCount]; 37 | private const string METALLIC_PROPERTY = "_Metallic"; 38 | 39 | MaterialProperty[] m_smoothnessProperty = new MaterialProperty[kMaxLayerCount]; 40 | private const string SMOOTHNESS_PROPERTY = "_Smoothness"; 41 | 42 | private Expandable m_ExpandableBit; 43 | private int m_LayerCount; 44 | private int m_LayerIndex; 45 | 46 | public ColourOptionUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0) 47 | { 48 | m_ExpandableBit = expandableBit; 49 | m_LayerCount = layerCount; 50 | m_LayerIndex = layerIndex; 51 | } 52 | 53 | public override void LoadMaterialProperties() 54 | { 55 | m_fieldTextureProperty = FindPropertyLayered(FIELD_TEXTURE_PROPERTY, m_LayerCount); 56 | m_bladeTextureProperty = FindPropertyLayered(BLADE_TEXTURE_PROPERTY, m_LayerCount); 57 | 58 | m_grassTopColourProperty = FindPropertyLayered(GRASS_TOP_COLOUR_PROPERTY, m_LayerCount); 59 | m_grassBottomColourProperty = FindPropertyLayered(GRASS_BOTTOM_COLOUR_PROPERTY, m_LayerCount); 60 | 61 | m_metallicProperty = FindPropertyLayered(METALLIC_PROPERTY, m_LayerCount); 62 | m_smoothnessProperty = FindPropertyLayered(SMOOTHNESS_PROPERTY, m_LayerCount); 63 | } 64 | 65 | public override void OnGUI() 66 | { 67 | using (MaterialHeaderScope header = new MaterialHeaderScope(Styles.optionText, (uint)m_ExpandableBit, materialEditor)) 68 | { 69 | if (header.expanded) 70 | DrawGUI(); 71 | } 72 | } 73 | 74 | private void DrawGUI() 75 | { 76 | materialEditor.TexturePropertySingleLine(Styles.grassTextureText, m_bladeTextureProperty[m_LayerIndex], m_grassBottomColourProperty[m_LayerIndex], m_grassTopColourProperty[m_LayerIndex]); 77 | 78 | //materialEditor.ShaderProperty(m_metallicProperty[m_LayerIndex], Styles.metallicText); 79 | //materialEditor.ShaderProperty(m_smoothnessProperty[m_LayerIndex], Styles.smoothnessText); 80 | 81 | //materialEditor.TextureScaleOffsetProperty(m_grassTextureProperty[m_LayerIndex]); 82 | 83 | // materialEditor.TextureProperty() 84 | //materialEditor.TextureProperty(Styles.grassTextureText, m_fieldTextureProperty[m_LayerIndex]); 85 | materialEditor.TexturePropertySingleLine(Styles.grassFieldTextureText, m_fieldTextureProperty[m_LayerIndex]); 86 | materialEditor.TextureScaleOffsetProperty(m_fieldTextureProperty[m_LayerIndex]); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/ColourOptionUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a27378b239249f48a10f2afc3415323 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassAdvancedUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5dcb96c2556a8345b7eb29c8d02a461 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassDebugUIBlock.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using static Grass.Editor.HDMaterialProperties; 4 | 5 | namespace Grass.Editor 6 | { 7 | class GrassDebugUIBlock : MaterialUIBlock 8 | { 9 | static class Styles 10 | { 11 | public const string optionText = "Debug"; 12 | 13 | public static GUIContent debugViewText = new GUIContent("Debug View", "Visualize the wind, displacement, or LODs of the grass."); 14 | public static GUIContent drawSourceGeometryText = new GUIContent("Draw Source Geometry", "Display the mesh this material is applied to instead of the grass."); 15 | } 16 | 17 | private const string VISUALIZE_WIND_PROPERTY = "VISUALIZE_WIND"; 18 | private const string VISUALIZE_DISPLACEMENT_PROPERTY = "VISUALIZE_DISPLACEMENT"; 19 | private const string VISUALIZE_LODS_PROPERTY = "VISUALIZE_LODS"; 20 | private const string DRAW_SOURCE_GEOMETRY_PROPERTY = "DRAW_SOURCE_GEOMETRY"; 21 | 22 | private Expandable m_ExpandableBit; 23 | private int m_LayerCount; 24 | private int m_LayerIndex; 25 | 26 | private enum DebugView { Off, Wind, Displacement, LODs } 27 | private string[] m_debugViewLabels = new string[] { "Off", "Wind", "Displacement", "LODs" }; 28 | 29 | public GrassDebugUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0) 30 | { 31 | m_ExpandableBit = expandableBit; 32 | m_LayerCount = layerCount; 33 | m_LayerIndex = layerIndex; 34 | } 35 | 36 | public override void LoadMaterialProperties() 37 | { 38 | 39 | } 40 | 41 | public override void OnGUI() 42 | { 43 | using (MaterialHeaderScope header = new MaterialHeaderScope(Styles.optionText, (uint)m_ExpandableBit, materialEditor)) 44 | { 45 | if (header.expanded) 46 | DrawGUI(); 47 | } 48 | } 49 | 50 | // doesnt really work well for multiple materials selected but neither does any enum so whatever 51 | private DebugView GetCurrentDebugView() 52 | { 53 | foreach (Material material in materials) 54 | { 55 | if (material.IsKeywordEnabled(VISUALIZE_WIND_PROPERTY)) 56 | return DebugView.Wind; 57 | if (material.IsKeywordEnabled(VISUALIZE_DISPLACEMENT_PROPERTY)) 58 | return DebugView.Displacement; 59 | if (material.IsKeywordEnabled(VISUALIZE_LODS_PROPERTY)) 60 | return DebugView.LODs; 61 | } 62 | 63 | return DebugView.Off; 64 | } 65 | 66 | private void SetCurrentDebugView(DebugView view) 67 | { 68 | foreach (Material material in materials) 69 | { 70 | if (view == DebugView.Wind) 71 | { 72 | material.EnableKeyword(VISUALIZE_WIND_PROPERTY); 73 | material.DisableKeyword(VISUALIZE_DISPLACEMENT_PROPERTY); 74 | material.DisableKeyword(VISUALIZE_LODS_PROPERTY); 75 | } 76 | else if (view == DebugView.Displacement) 77 | { 78 | material.DisableKeyword(VISUALIZE_WIND_PROPERTY); 79 | material.EnableKeyword(VISUALIZE_DISPLACEMENT_PROPERTY); 80 | material.DisableKeyword(VISUALIZE_LODS_PROPERTY); 81 | } 82 | else if (view == DebugView.LODs) 83 | { 84 | material.DisableKeyword(VISUALIZE_WIND_PROPERTY); 85 | material.DisableKeyword(VISUALIZE_DISPLACEMENT_PROPERTY); 86 | material.EnableKeyword(VISUALIZE_LODS_PROPERTY); 87 | } 88 | else 89 | { 90 | material.DisableKeyword(VISUALIZE_WIND_PROPERTY); 91 | material.DisableKeyword(VISUALIZE_DISPLACEMENT_PROPERTY); 92 | material.DisableKeyword(VISUALIZE_LODS_PROPERTY); 93 | } 94 | } 95 | } 96 | 97 | private void DrawGUI() 98 | { 99 | DebugView debugView = GetCurrentDebugView(); 100 | 101 | EditorGUI.BeginChangeCheck(); 102 | debugView = (DebugView)EditorGUILayout.Popup(Styles.debugViewText, (int)debugView, m_debugViewLabels); 103 | if (EditorGUI.EndChangeCheck()) 104 | SetCurrentDebugView(debugView); 105 | 106 | EditorGUI.BeginChangeCheck(); 107 | bool drawGeometry = EditorGUILayout.Toggle(Styles.drawSourceGeometryText, materials[0].IsKeywordEnabled(DRAW_SOURCE_GEOMETRY_PROPERTY)); 108 | if (EditorGUI.EndChangeCheck()) 109 | { 110 | foreach (Material material in materials) 111 | { 112 | if (drawGeometry) 113 | material.EnableKeyword(DRAW_SOURCE_GEOMETRY_PROPERTY); 114 | else 115 | material.DisableKeyword(DRAW_SOURCE_GEOMETRY_PROPERTY); 116 | } 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassDebugUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d659dd6e74c57949abaa786592c8094 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassDistributionUIBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering.HighDefinition; 5 | using UnityEngine.Rendering; 6 | using UnityEditor; 7 | 8 | using static Grass.Editor.HDMaterialProperties; 9 | 10 | namespace Grass.Editor 11 | { 12 | class GrassDistributionUIBlock : MaterialUIBlock 13 | { 14 | static class Styles 15 | { 16 | public const string optionText = "Grass Distribution"; 17 | 18 | public static GUIContent grassDensityText = new GUIContent("Grass Density", "The density of the grass. This will be proportional to the amount of vertices on the original mesh."); 19 | public static GUIContent positionRandomizationText = new GUIContent("Position Randomization", "Randomly offsets the grass blades' positions from their source vertices. Good for breaking up the pattern created by tesselation."); 20 | public static GUIContent grassMap = new GUIContent("Grass Map", "Samples using the source geometry's UVs to affect the distribution of grass. Vertex colours are also used. Leave this blank to put grass everywhere."); 21 | } 22 | 23 | private MaterialProperty[] m_grassPositionProperty = new MaterialProperty[kMaxLayerCount]; 24 | private const string GRASS_POSITION_RANDOMIZATION = "_GrassOffset"; 25 | 26 | private MaterialProperty[] m_grassMapProperty = new MaterialProperty[kMaxLayerCount]; 27 | private const string GRASS_MAP_PROPERTY = "_GrassMap"; 28 | 29 | private Expandable m_ExpandableBit; 30 | private int m_LayerCount; 31 | private int m_LayerIndex; 32 | 33 | public GrassDistributionUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0) 34 | { 35 | m_ExpandableBit = expandableBit; 36 | m_LayerCount = layerCount; 37 | m_LayerIndex = layerIndex; 38 | } 39 | 40 | public override void LoadMaterialProperties() 41 | { 42 | base.LoadMaterialProperties(); 43 | 44 | m_grassPositionProperty = FindPropertyLayered(GRASS_POSITION_RANDOMIZATION, m_LayerCount); 45 | m_grassMapProperty = FindPropertyLayered(GRASS_MAP_PROPERTY, m_LayerCount); 46 | } 47 | 48 | public override void OnGUI() 49 | { 50 | using (MaterialHeaderScope header = new MaterialHeaderScope(Styles.optionText, (uint)m_ExpandableBit, materialEditor)) 51 | { 52 | if (header.expanded) 53 | DrawGUI(); 54 | } 55 | } 56 | 57 | private void DrawGUI() 58 | { 59 | float density = GetScaledDensity(0); 60 | 61 | EditorGUI.BeginChangeCheck(); 62 | density = EditorGUILayout.Slider(Styles.grassDensityText, density, 0f, 1f);//Mathf.Lerp(0f, GetMaxDensity(), EditorGUILayout.Slider(Styles.grassDensityText, density, 0f, 1f)); 63 | if (EditorGUI.EndChangeCheck()) 64 | SetScaledDensity(density, 0); 65 | //m_grassDensityProperty.floatValue = density; 66 | 67 | if (density <= 0f) 68 | EditorGUILayout.HelpBox("Density of 0 might produce no geometry!", MessageType.Warning); 69 | 70 | materialEditor.ShaderProperty(m_grassPositionProperty[m_LayerIndex], Styles.positionRandomizationText); 71 | materialEditor.TexturePropertySingleLine(Styles.grassMap, m_grassMapProperty[m_LayerIndex]); 72 | 73 | materialEditor.TextureScaleOffsetProperty(m_grassMapProperty[m_LayerIndex]); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassDistributionUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a28be531cc5960743b748586256b27d7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassGUI.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Rendering.HighDefinition; 3 | using UnityEngine.Rendering; 4 | using UnityEditor.Rendering.HighDefinition; 5 | using UnityEditor.Rendering; 6 | using UnityEditor.Experimental.Rendering; 7 | 8 | using UnityEditor; 9 | 10 | namespace Grass.Editor 11 | { 12 | public class GrassGUI : ShaderGUI 13 | { 14 | public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) 15 | { 16 | using (EditorGUI.ChangeCheckScope changed = new EditorGUI.ChangeCheckScope()) 17 | { 18 | uiBlocks.OnGUI(materialEditor, properties); 19 | } 20 | } 21 | 22 | MaterialUIBlockList uiBlocks = new MaterialUIBlockList 23 | { 24 | new ColourOptionUIBlock(MaterialUIBlock.Expandable.Colour), 25 | new GrassDistributionUIBlock(MaterialUIBlock.Expandable.Distribution), 26 | new GrassShapeUIBlock(MaterialUIBlock.Expandable.Shape), 27 | new GrassWindUIBlock(MaterialUIBlock.Expandable.Wind), 28 | new GrassAdvancedUIBlock(MaterialUIBlock.Expandable.Advanced), 29 | new GrassDebugUIBlock(MaterialUIBlock.Expandable.Debug), 30 | }; 31 | 32 | //protected bool m_FirstFrame = true; 33 | 34 | //protected void ApplyKeywordsAndPassesIfNeeded(bool changed, Material[] materials) 35 | //{ 36 | // // !!! HACK !!! 37 | // // When a user creates a new Material from the contextual menu, the material is created from the editor code and the appropriate shader is applied to it. 38 | // // This means that we never setup keywords and passes for a newly created material. The material is then in an invalid state. 39 | // // To work around this, as the material is automatically selected when created, we force an update of the keyword at the first "frame" of the editor. 40 | 41 | // // Apply material keywords and pass: 42 | // if (changed || m_FirstFrame) 43 | // { 44 | // m_FirstFrame = false; 45 | 46 | // foreach (var material in materials) 47 | // SetupMaterialKeywordsAndPassInternal(material); 48 | // } 49 | //} 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassGUI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5bb6df1a001f7be4e8cd098265946126 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassShapeUIBlock.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using static Grass.Editor.HDMaterialProperties; 4 | 5 | namespace Grass.Editor 6 | { 7 | class GrassShapeUIBlock : MaterialUIBlock 8 | { 9 | static class Styles 10 | { 11 | public const string optionText = "Grass Shape"; 12 | 13 | public static GUIContent styleText = new GUIContent("Style", "The shape of the generated grass."); 14 | public static GUIContent billboardText = new GUIContent("Billboarding", "Grass always rotates to face the camera."); 15 | public static GUIContent medianBladeWidthText = new GUIContent("Median Blade Width", "The width of the average grass blade."); 16 | public static GUIContent maxRandomWidthOffsetText = new GUIContent("Max Random Width Offset", "The variation of the grass blade width from the average. Sampled uniformly."); 17 | public static GUIContent medianBladeHeightText = new GUIContent("Median Blade Height", "The height of the average grass blade."); 18 | public static GUIContent maxRandomHeightOffsetText = new GUIContent("Max Random Height Offset", "The variation of the grass blade height from the average. Sampled uniformly."); 19 | public static GUIContent rotationRangeText = new GUIContent("Rotation Range", "The max rotation of the grass blades around their local y axis, in degrees."); 20 | public static GUIContent maxDownwardRotationText = new GUIContent("Max Downward Rotation", "The max rotation of the grass blades around their local x axis, in degrees."); 21 | public static GUIContent curvatureText = new GUIContent("Curvature", "How much the grass blades curve along their height."); 22 | public static GUIContent curvatureTipBiasText = new GUIContent("Curvature Tip Bias", "The offset along the blades' local z axis from the tip relative to the base."); 23 | } 24 | 25 | private MaterialProperty[] m_bladeWidthProperty = new MaterialProperty[kMaxLayerCount]; 26 | private const string BLADE_WIDTH_PROPERTY = "_BladeWidth"; 27 | 28 | private MaterialProperty[] m_bladeWidthRandomProperty = new MaterialProperty[kMaxLayerCount]; 29 | private const string BLADE_WIDTH_RANDOM_PROPERTY = "_BladeWidthRandom"; 30 | 31 | private MaterialProperty[] m_bladeHeightProperty = new MaterialProperty[kMaxLayerCount]; 32 | private const string BLADE_HEIGHT_PROPERTY = "_BladeHeight"; 33 | 34 | private MaterialProperty[] m_bladeHeightRandomProperty = new MaterialProperty[kMaxLayerCount]; 35 | private const string BLADE_HEIGHT_RANDOM_PROPERTY = "_BladeHeightRandom"; 36 | 37 | private MaterialProperty[] m_bladeRotationRangeProperty = new MaterialProperty[kMaxLayerCount]; 38 | private const string BLADE_ROTATION_RANGE_PROPERTY = "_BladeRotationRange"; 39 | 40 | private MaterialProperty[] m_maxDownwardRotationProperty = new MaterialProperty[kMaxLayerCount]; 41 | private const string MAX_DOWNWARD_ROTATION_PROPERTY = "_BendRotationRandom"; 42 | 43 | private MaterialProperty[] m_curvatureProperty = new MaterialProperty[kMaxLayerCount]; 44 | private const string CURVATURE_PROPERTY = "_BladeCurve"; 45 | 46 | private MaterialProperty[] m_curvatureTipBiasProperty = new MaterialProperty[kMaxLayerCount]; 47 | private const string CURVATURE_TIP_BIAS = "_BladeForward"; 48 | 49 | private const string BILLBOARD_PROPERTY = "BILLBOARD"; 50 | 51 | private const string GENERATE_QUADS_PROPERTY = "GENERATE_QUADS"; 52 | 53 | private Expandable m_ExpandableBit; 54 | private int m_LayerCount; 55 | private int m_LayerIndex; 56 | 57 | public GrassShapeUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0) 58 | { 59 | m_ExpandableBit = expandableBit; 60 | m_LayerCount = layerCount; 61 | m_LayerIndex = layerIndex; 62 | } 63 | 64 | public override void LoadMaterialProperties() 65 | { 66 | m_bladeWidthProperty = FindPropertyLayered(BLADE_WIDTH_PROPERTY, m_LayerCount); 67 | m_bladeWidthRandomProperty = FindPropertyLayered(BLADE_WIDTH_RANDOM_PROPERTY, m_LayerCount); 68 | m_bladeHeightProperty = FindPropertyLayered(BLADE_HEIGHT_PROPERTY, m_LayerCount); 69 | m_bladeHeightRandomProperty = FindPropertyLayered(BLADE_HEIGHT_RANDOM_PROPERTY, m_LayerCount); 70 | m_bladeRotationRangeProperty = FindPropertyLayered(BLADE_ROTATION_RANGE_PROPERTY, m_LayerCount); 71 | m_maxDownwardRotationProperty = FindPropertyLayered(MAX_DOWNWARD_ROTATION_PROPERTY, m_LayerCount); 72 | m_curvatureProperty = FindPropertyLayered(CURVATURE_PROPERTY, m_LayerCount); 73 | m_curvatureTipBiasProperty = FindPropertyLayered(CURVATURE_TIP_BIAS, m_LayerCount); 74 | } 75 | 76 | public override void OnGUI() 77 | { 78 | using (MaterialHeaderScope header = new MaterialHeaderScope(Styles.optionText, (uint)m_ExpandableBit, materialEditor)) 79 | { 80 | if (header.expanded) 81 | DrawGUI(); 82 | } 83 | } 84 | 85 | private enum GrassStyle { Blade, Quad } 86 | 87 | private void DrawGUI() 88 | { 89 | bool generateQuads = GetKeyword(GENERATE_QUADS_PROPERTY); 90 | GrassStyle currentGrassStyle = generateQuads ? GrassStyle.Quad : GrassStyle.Blade; 91 | 92 | EditorGUI.BeginChangeCheck(); 93 | currentGrassStyle = (GrassStyle)EditorGUILayout.EnumPopup(Styles.styleText, currentGrassStyle); 94 | if (EditorGUI.EndChangeCheck()) 95 | { 96 | SetKeyword(GENERATE_QUADS_PROPERTY, currentGrassStyle == GrassStyle.Quad); 97 | } 98 | 99 | bool billboarding = DrawKeyword(BILLBOARD_PROPERTY, Styles.billboardText); 100 | 101 | void SetPropertyWithMin(MaterialProperty property, GUIContent label, MaterialProperty variationProperty, GUIContent variationLabel, float min, string warning = null) 102 | { 103 | float current = property.floatValue; 104 | 105 | EditorGUI.BeginChangeCheck(); 106 | current = Mathf.Max(min, EditorGUILayout.FloatField(label, current)); 107 | if (EditorGUI.EndChangeCheck()) 108 | property.floatValue = current; 109 | 110 | materialEditor.ShaderProperty(variationProperty, variationLabel); 111 | 112 | float variation = variationProperty.floatValue; 113 | 114 | if (current <= min && variation == 0f && !string.IsNullOrEmpty(warning)) 115 | EditorGUILayout.HelpBox(warning, MessageType.Warning); 116 | } 117 | 118 | SetPropertyWithMin(m_bladeWidthProperty[m_LayerIndex], Styles.medianBladeWidthText, m_bladeWidthRandomProperty[m_LayerIndex], Styles.maxRandomWidthOffsetText, 0f, "Width and width offset of 0 might produce no geometry!"); 119 | SetPropertyWithMin(m_bladeHeightProperty[m_LayerIndex], Styles.medianBladeHeightText, m_bladeHeightRandomProperty[m_LayerIndex], Styles.maxRandomHeightOffsetText, 0f, "Height and height offset of 0 might produce no geometry!"); 120 | 121 | if (!billboarding) 122 | materialEditor.ShaderProperty(m_bladeRotationRangeProperty[m_LayerIndex], Styles.rotationRangeText); 123 | else 124 | EditorGUILayout.HelpBox("Grass blade local transform settings are disabled when billboarding. (Temporarily)", MessageType.Warning); 125 | 126 | GUI.enabled = !billboarding; 127 | 128 | materialEditor.ShaderProperty(m_maxDownwardRotationProperty[m_LayerIndex], Styles.maxDownwardRotationText); 129 | materialEditor.ShaderProperty(m_curvatureProperty[m_LayerIndex], Styles.curvatureText); 130 | materialEditor.ShaderProperty(m_curvatureTipBiasProperty[m_LayerIndex], Styles.curvatureTipBiasText); 131 | 132 | GUI.enabled = true; 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassShapeUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 629f4f09b975bce4b9a9f4f258f0c511 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassWindUIBlock.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using static Grass.Editor.HDMaterialProperties; 4 | 5 | namespace Grass.Editor 6 | { 7 | class GrassWindUIBlock : MaterialUIBlock 8 | { 9 | static class Styles 10 | { 11 | public const string optionText = "Wind"; 12 | 13 | public static GUIContent windMapText = new GUIContent("Wind Distortion Map", "This texture describes the shape of the wind which displaces the grass blades. It should be tileable, with red representing movement on the x axis and green representing movement on the z axis."); 14 | public static GUIContent windFrequencyText = new GUIContent("Wind Frequency", "The speed of the wind displacement along the x and z axes."); 15 | public static GUIContent windStrengthText = new GUIContent("Wind Strength", "The power of the wind displacement."); 16 | } 17 | 18 | private MaterialProperty[] m_windMapProperty = new MaterialProperty[kMaxLayerCount]; 19 | private const string WIND_MAP_PROPERTY = "_WindDistortionMap"; 20 | 21 | private MaterialProperty[] m_windFrequencyProperty = new MaterialProperty[kMaxLayerCount]; 22 | private const string WIND_FREQUENCY_PROPERTY = "_WindFrequency"; 23 | 24 | private MaterialProperty[] m_windStrengthProperty = new MaterialProperty[kMaxLayerCount]; 25 | private const string WIND_STRENGTH_PROPERTY = "_WindStrength"; 26 | 27 | private Expandable m_ExpandableBit; 28 | private int m_LayerCount; 29 | private int m_LayerIndex; 30 | 31 | public GrassWindUIBlock(Expandable expandableBit, int layerCount = 1, int layerIndex = 0) 32 | { 33 | m_ExpandableBit = expandableBit; 34 | m_LayerCount = layerCount; 35 | m_LayerIndex = layerIndex; 36 | } 37 | 38 | public override void LoadMaterialProperties() 39 | { 40 | m_windMapProperty = FindPropertyLayered(WIND_MAP_PROPERTY, m_LayerCount); 41 | m_windFrequencyProperty = FindPropertyLayered(WIND_FREQUENCY_PROPERTY, m_LayerCount); 42 | m_windStrengthProperty = FindPropertyLayered(WIND_STRENGTH_PROPERTY, m_LayerCount); 43 | } 44 | 45 | public override void OnGUI() 46 | { 47 | using (MaterialHeaderScope header = new MaterialHeaderScope(Styles.optionText, (uint)m_ExpandableBit, materialEditor)) 48 | { 49 | if (header.expanded) 50 | DrawGUI(); 51 | } 52 | } 53 | 54 | private void DrawGUI() 55 | { 56 | materialEditor.TexturePropertySingleLine(Styles.windMapText, m_windMapProperty[m_LayerIndex]); 57 | 58 | materialEditor.ShaderProperty(m_windStrengthProperty[m_LayerIndex], Styles.windStrengthText); 59 | 60 | EditorGUI.BeginChangeCheck(); 61 | Vector2 windFrequencySetting = EditorGUILayout.Vector2Field(Styles.windFrequencyText, m_windFrequencyProperty[m_LayerIndex].vectorValue); 62 | if (EditorGUI.EndChangeCheck()) 63 | m_windFrequencyProperty[m_LayerIndex].vectorValue = windFrequencySetting; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/GrassWindUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dea6198bba326da44ba1a3df6ab7b55f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c94a0b80577b85747bc6386d39c64021 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/HDStringConstants.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3fb0eb2bb0308b44c82c3ad7077f6c31 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialEditorExtension.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor.Rendering.HighDefinition; 3 | using UnityEditor; 4 | 5 | namespace Grass.Editor 6 | { 7 | internal static class MaterialEditorExtension 8 | { 9 | static uint defaultExpandedState => 0xFFFFFFFF; //all opened by default 10 | 11 | private const string k_KeyPrefix = "HDRP:Material:UI_State:"; 12 | 13 | public static void InitExpandableState(this MaterialEditor editor) 14 | { 15 | string key = GetKey(editor); 16 | if(!EditorPrefs.HasKey(key)) 17 | { 18 | EditorPrefs.SetInt(key, (int)defaultExpandedState); 19 | } 20 | } 21 | 22 | public static bool GetExpandedAreas(this MaterialEditor editor, uint mask) 23 | { 24 | uint state = GetState(editor); 25 | bool result = (state & mask) > 0; 26 | return result; 27 | } 28 | 29 | public static void SetExpandedAreas(this MaterialEditor editor, uint mask, bool value) 30 | { 31 | uint state = GetState(editor); 32 | 33 | if (value) 34 | { 35 | state |= mask; 36 | } 37 | else 38 | { 39 | mask = ~mask; 40 | state &= mask; 41 | } 42 | 43 | SetState(editor, state); 44 | } 45 | 46 | static uint GetState(this MaterialEditor editor) 47 | { 48 | return (uint)EditorPrefs.GetInt(GetKey(editor)); 49 | } 50 | 51 | static void SetState(this MaterialEditor editor, uint value) 52 | { 53 | EditorPrefs.SetInt(GetKey(editor), (int)value); 54 | } 55 | 56 | static string GetKey(this MaterialEditor editor) 57 | { 58 | return k_KeyPrefix + ((Material)editor.target).shader.name; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialEditorExtension.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a273d8ae3545f9640b1da25c18408ac2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialHeaderScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEditor.Rendering; 4 | using UnityEngine; 5 | 6 | namespace Grass.Editor 7 | { 8 | /// 9 | /// Create a toggleable header for material UI, must be used within a scope. 10 | /// Example: 11 | /// 12 | /// void OnGUI() 13 | /// { 14 | /// using (var header = new MaterialHeaderScope(text, ExpandBit, editor)) 15 | /// { 16 | /// if (header.expanded) 17 | /// EditorGUILayout.LabelField("Hello World !"); 18 | /// } 19 | /// } 20 | /// 21 | /// 22 | /// 23 | internal struct MaterialHeaderScope : IDisposable 24 | { 25 | public readonly bool expanded; 26 | bool spaceAtEnd; 27 | #if !UNITY_2020_1_OR_NEWER 28 | int oldIndentLevel; 29 | #endif 30 | 31 | public MaterialHeaderScope(string title, uint bitExpanded, MaterialEditor materialEditor, bool spaceAtEnd = true, Color colorDot = default(Color), bool subHeader = false) 32 | { 33 | bool beforeExpended = materialEditor.GetExpandedAreas(bitExpanded); 34 | 35 | #if !UNITY_2020_1_OR_NEWER 36 | oldIndentLevel = EditorGUI.indentLevel; 37 | EditorGUI.indentLevel = subHeader ? 1 : 0; //fix for preset in 2019.3 (preset are one more indentation depth in material) 38 | #endif 39 | 40 | this.spaceAtEnd = spaceAtEnd; 41 | if (!subHeader) 42 | CoreEditorUtils.DrawSplitter(); 43 | GUILayout.BeginVertical(); 44 | 45 | bool saveChangeState = GUI.changed; 46 | if (colorDot != default(Color)) 47 | title = " " + title; 48 | expanded = subHeader 49 | ? CoreEditorUtils.DrawSubHeaderFoldout(title, beforeExpended) 50 | : CoreEditorUtils.DrawHeaderFoldout(title, beforeExpended); 51 | if (colorDot != default(Color)) 52 | { 53 | Rect dotRect = GUILayoutUtility.GetLastRect(); 54 | dotRect.width = 5; 55 | dotRect.height = 5; 56 | dotRect.y += 7; 57 | dotRect.x += 17; 58 | EditorGUI.DrawRect(dotRect, colorDot); 59 | } 60 | if (expanded ^ beforeExpended) 61 | { 62 | materialEditor.SetExpandedAreas((uint)bitExpanded, expanded); 63 | saveChangeState = true; 64 | } 65 | GUI.changed = saveChangeState; 66 | 67 | if (expanded) 68 | ++EditorGUI.indentLevel; 69 | } 70 | 71 | void IDisposable.Dispose() 72 | { 73 | if (expanded) 74 | { 75 | if (spaceAtEnd && (Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout)) 76 | EditorGUILayout.Space(); 77 | --EditorGUI.indentLevel; 78 | } 79 | 80 | #if !UNITY_2020_1_OR_NEWER 81 | EditorGUI.indentLevel = oldIndentLevel; 82 | #endif 83 | GUILayout.EndVertical(); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialHeaderScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 372a066d861ad1549bb18a7f5a30b187 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialUIBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Rendering.HighDefinition; 6 | using UnityEditor.Rendering; 7 | using UnityEditor; 8 | 9 | namespace Grass.Editor 10 | { 11 | abstract class MaterialUIBlock 12 | { 13 | protected const float MAX_DENSITY_UNIFORM = 64f; 14 | protected const float MAX_DENSITY_PROPORTIONAL = 7f; 15 | 16 | 17 | //protected MaterialProperty m_grassDensityProperty = new MaterialProperty(); 18 | //protected const string GRASS_DENSITY_PROPERTY = "_GrassDensity"; 19 | 20 | 21 | protected MaterialProperty m_lodDensitiesProperty = new MaterialProperty(); 22 | protected const string LOD_DENSITIES_PROPERTY = "_GrassLODDensities"; 23 | 24 | 25 | protected const string PROPORTIONAL_TESSELATION_PROPERTY = "PROPORTIONAL_TESSELATION"; 26 | 27 | protected float GetMaxDensity() 28 | { 29 | bool isProportionalDensity = GetKeyword(PROPORTIONAL_TESSELATION_PROPERTY); 30 | return isProportionalDensity ? MAX_DENSITY_PROPORTIONAL : MAX_DENSITY_UNIFORM; 31 | 32 | } 33 | 34 | protected float GetScaledDensity(int lod) 35 | { 36 | return Mathf.InverseLerp(0f, GetMaxDensity(), m_lodDensitiesProperty.vectorValue[lod]); 37 | } 38 | 39 | protected void SetScaledDensity(float density, int lod) 40 | { 41 | Vector4 val = m_lodDensitiesProperty.vectorValue; 42 | val[lod] = Mathf.Lerp(0f, GetMaxDensity(), density); 43 | m_lodDensitiesProperty.vectorValue = val; 44 | } 45 | 46 | // doesnt really work well for multiple materials selected but neither does any enum so whatever 47 | protected bool GetKeyword(string keyword) 48 | { 49 | foreach (Material material in materials) 50 | { 51 | if (material.IsKeywordEnabled(keyword)) 52 | return true; 53 | } 54 | 55 | return false; 56 | } 57 | 58 | protected void SetKeyword(string keyword, bool val) 59 | { 60 | foreach (Material material in materials) 61 | { 62 | if (val) 63 | material.EnableKeyword(keyword); 64 | else 65 | material.DisableKeyword(keyword); 66 | } 67 | } 68 | 69 | protected bool DrawKeyword(string keyword, GUIContent label) 70 | { 71 | bool val = GetKeyword(keyword); 72 | EditorGUI.BeginChangeCheck(); 73 | val = EditorGUILayout.Toggle(label, val); 74 | if (EditorGUI.EndChangeCheck()) 75 | SetKeyword(keyword, val); 76 | 77 | return val; 78 | } 79 | 80 | 81 | protected MaterialEditor materialEditor; 82 | protected Material[] materials; 83 | protected MaterialProperty[] properties; 84 | 85 | protected MaterialUIBlockList parent; 86 | 87 | [Flags] 88 | public enum Expandable : uint 89 | { 90 | // Standard 91 | Base = 1 << 0, 92 | Colour = 1 << 1, 93 | Distribution = 1 << 2, 94 | Shape = 1 << 3, 95 | Wind = 1 << 4, 96 | Advanced = 1 << 5, 97 | Debug = 1 << 6, 98 | } 99 | 100 | public void Initialize(MaterialEditor materialEditor, MaterialProperty[] properties, MaterialUIBlockList parent) 101 | { 102 | this.materialEditor = materialEditor; 103 | this.parent = parent; 104 | materials = materialEditor.targets.Select(target => target as Material).ToArray(); 105 | 106 | // We should always register the key used to keep collapsable state 107 | materialEditor.InitExpandableState(); 108 | } 109 | 110 | public void UpdateMaterialProperties(MaterialProperty[] properties) 111 | { 112 | this.properties = properties; 113 | LoadMaterialProperties(); 114 | } 115 | 116 | protected MaterialProperty FindProperty(string propertyName, bool isMandatory = false) 117 | { 118 | // ShaderGUI.FindProperty is a protected member of ShaderGUI so we can't call it here: 119 | // return ShaderGUI.FindProperty(propertyName, properties, isMandatory); 120 | 121 | // TODO: move this to a map since this is done at every editor frame 122 | foreach (var prop in properties) 123 | if (prop.name == propertyName) 124 | return prop; 125 | 126 | if (isMandatory) 127 | throw new ArgumentException("Could not find MaterialProperty: '" + propertyName + "', Num properties: " + properties.Length); 128 | return null; 129 | } 130 | 131 | protected MaterialProperty[] FindPropertyLayered(string propertyName, int layerCount, bool isMandatory = false) 132 | { 133 | MaterialProperty[] properties = new MaterialProperty[layerCount]; 134 | 135 | // If the layerCount is 1, then it means that the property we're fetching is not from a layered material 136 | // thus it doesn't have a prefix 137 | string[] prefixes = (layerCount > 1) ? new[] { "0", "1", "2", "3" } : new[] { "" }; 138 | 139 | for (int i = 0; i < layerCount; i++) 140 | { 141 | properties[i] = FindProperty(string.Format("{0}{1}", propertyName, prefixes[i]), isMandatory); 142 | } 143 | 144 | return properties; 145 | } 146 | 147 | public virtual void LoadMaterialProperties() 148 | { 149 | m_lodDensitiesProperty = FindProperty(LOD_DENSITIES_PROPERTY); 150 | } 151 | 152 | public abstract void OnGUI(); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialUIBlock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ae3c84c0ccb9f54fba35bd212b1c559 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialUIBlockList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Rendering.HighDefinition; 4 | using System.Linq; 5 | using UnityEditor; 6 | 7 | namespace Grass.Editor 8 | { 9 | // A Material can be authored from the shader graph or by hand. When written by hand we need to provide an inspector. 10 | // Such a Material will share some properties between it various variant (shader graph variant or hand authored variant). 11 | // To create a such GUI, we provide Material UI Blocks, a modular API to create custom Material UI that allow 12 | // you to reuse HDRP pre-defined blocks and access support header toggles automatically. 13 | // Examples of such material UIs can be found in the classes UnlitGUI, LitGUI or LayeredLitGUI. 14 | 15 | /// 16 | /// Wrapper to handle Material UI Blocks, it will handle initialization of the blocks when drawing the GUI. 17 | /// 18 | class MaterialUIBlockList : List 19 | { 20 | [System.NonSerialized] 21 | bool m_Initialized = false; 22 | 23 | Material[] m_Materials; 24 | 25 | /// 26 | /// Parent of the ui block list, in case of nesting (Layered Lit material) 27 | /// 28 | public MaterialUIBlockList parent; 29 | 30 | /// 31 | /// List of materials currently selected in the inspector 32 | /// 33 | public Material[] materials => m_Materials; 34 | 35 | /// 36 | /// Construct a sub ui block list by passing the parent ui block list (useful for layered UI where ui blocks are nested) 37 | /// 38 | /// 39 | public MaterialUIBlockList(MaterialUIBlockList parent) => this.parent = parent; 40 | 41 | /// 42 | /// Construct a ui block list 43 | /// 44 | /// 45 | public MaterialUIBlockList() : this(null) {} 46 | 47 | /// 48 | /// Render the list of ui blocks added contained in the materials property 49 | /// 50 | /// 51 | /// 52 | public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) 53 | { 54 | // Use default labelWidth 55 | EditorGUIUtility.labelWidth = 0f; 56 | Initialize(materialEditor, properties); 57 | foreach (var uiBlock in this) 58 | { 59 | // We load material properties at each frame because materials can be animated and to make undo/redo works 60 | uiBlock.UpdateMaterialProperties(properties); 61 | uiBlock.OnGUI(); 62 | } 63 | } 64 | 65 | /// 66 | /// Initialize the ui blocks, can be called at every frame, a guard is prevents more that one initialization 67 | /// This function is called automatically by MaterialUIBlockList.OnGUI so you only need this when you want to render the UI Blocks in a custom order 68 | /// 69 | public void Initialize(MaterialEditor materialEditor, MaterialProperty[] properties) 70 | { 71 | if (!m_Initialized) 72 | { 73 | foreach (var uiBlock in this) 74 | uiBlock.Initialize(materialEditor, properties, this); 75 | 76 | m_Materials = materialEditor.targets.Select(target => target as Material).ToArray(); 77 | m_Initialized = true; 78 | } 79 | } 80 | 81 | /// 82 | /// Fetch the first ui block of type T in the current list of material blocks 83 | /// 84 | /// MaterialUIBlock type 85 | /// 86 | public T FetchUIBlock< T >() where T : MaterialUIBlock 87 | { 88 | return this.FirstOrDefault(uiBlock => uiBlock is T) as T; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Scripts/Editor/HDRPCopiedStuff/MaterialUIBlockList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dda528db502034c4ba68cd4d8858fd4e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c491333e5fe43ab4ba7ef41db6bb12cf 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Common.hlsl: -------------------------------------------------------------------------------- 1 | #include "../../Grass_Common.hlsl" 2 | 3 | //uniform StructuredBuffer _GrassDisplacementSpheresBuffer : register(t1); 4 | //uniform int _GrassDisplacementSpheresBufferCount; 5 | 6 | //#define MAX_GRASS_DISPLACEMENT_SPHERES 10 7 | 8 | //// Simple noise function, sourced from http://answers.unity.com/answers/624136/view.html 9 | //// Extended discussion on this function can be found at the following link: 10 | //// https://forum.unity.com/threads/am-i-over-complicating-this-random-function.454887/#post-2949326 11 | //// Returns a number in the 0...1 range. 12 | //float rand(float3 co) 13 | //{ 14 | // // smooths out floating point weirdness 15 | // co = round(co * 100); 16 | 17 | // return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 53.539))) * 43758.5453); 18 | //} 19 | 20 | //// Construct a rotation matrix that rotates around the provided axis, sourced from: 21 | //// https://gist.github.com/keijiro/ee439d5e7388f3aafc5296005c8c3f33 22 | //float3x3 AngleAxis3x3(float angle, float3 axis) 23 | //{ 24 | // float c, s; 25 | // sincos(angle, s, c); 26 | 27 | // float t = 1 - c; 28 | // float x = axis.x; 29 | // float y = axis.y; 30 | // float z = axis.z; 31 | 32 | // return float3x3( 33 | // t * x * x + c, t * x * y - s * z, t * x * z + s * y, 34 | // t * x * y + s * z, t * y * y + c, t * y * z - s * x, 35 | // t * x * z - s * y, t * y * z + s * x, t * z * z + c 36 | // ); 37 | //} 38 | 39 | void SetPosition(inout PackedVaryingsToPS ps, float3 offset) 40 | { 41 | #ifdef VARYINGS_NEED_POSITION_WS 42 | ps.vmesh.interpolators0 = offset; 43 | #endif 44 | ps.vmesh.positionCS = TransformWorldToHClip(ps.vmesh.interpolators0); 45 | } 46 | 47 | void SetNormal(inout PackedVaryingsToPS ps, float3 normal) 48 | { 49 | #ifdef VARYINGS_NEED_TANGENT_TO_WORLD 50 | ps.vmesh.interpolators1 = normal; 51 | #endif 52 | } 53 | 54 | void SetUV0(inout PackedVaryingsToPS ps, float2 uv) 55 | { 56 | #ifdef VARYINGS_NEED_TEXCOORD0 57 | ps.vmesh.interpolators3.xy = uv; 58 | #endif 59 | } 60 | 61 | void SetUV1(inout PackedVaryingsToPS ps, float2 uv) 62 | { 63 | #ifdef VARYINGS_NEED_TEXCOORD1 64 | ps.vmesh.interpolators3.zw = uv; 65 | #endif 66 | } 67 | 68 | float2 GetUV0(inout PackedVaryingsToPS ps) 69 | { 70 | #ifdef VARYINGS_NEED_TEXCOORD0 71 | return ps.vmesh.interpolators3.xy; 72 | #else 73 | return float2(0, 0); 74 | #endif 75 | } 76 | 77 | float2 GetUV1(inout PackedVaryingsToPS ps) 78 | { 79 | #ifdef VARYINGS_NEED_TEXCOORD1 80 | return ps.vmesh.interpolators3.zw; 81 | #else 82 | return float2(0, 0); 83 | #endif 84 | } 85 | 86 | float2 GetUV2(inout PackedVaryingsToPS ps) 87 | { 88 | #ifdef VARYINGS_NEED_TEXCOORD2 89 | return ps.vmesh.interpolators4.xy; 90 | #else 91 | return float2(0, 0); 92 | #endif 93 | } 94 | 95 | float2 GetUV3(inout PackedVaryingsToPS ps) 96 | { 97 | #ifdef VARYINGS_NEED_TEXCOORD3 98 | return ps.vmesh.interpolators4.zw; 99 | #else 100 | return float2(0, 0); 101 | #endif 102 | } 103 | 104 | float4 GetColor(inout PackedVaryingsToPS ps) 105 | { 106 | #ifdef VARYINGS_NEED_COLOR 107 | return ps.vmesh.interpolators5; 108 | #else 109 | return float4(0, 0, 0, 0); 110 | #endif 111 | } 112 | 113 | float3 GetPosition(inout PackedVaryingsToPS ps) 114 | { 115 | #ifdef VARYINGS_NEED_POSITION_WS 116 | return ps.vmesh.interpolators0; 117 | #else 118 | return float3(0, 0, 0); 119 | #endif 120 | } 121 | 122 | float3 GetNormal(inout PackedVaryingsToPS ps) 123 | { 124 | #ifdef VARYINGS_NEED_TANGENT_TO_WORLD 125 | return ps.vmesh.interpolators1; 126 | #else 127 | return float3(0, 0, 0); 128 | #endif 129 | } 130 | 131 | float4 GetTangent(inout PackedVaryingsToPS ps) 132 | { 133 | #ifdef VARYINGS_NEED_TANGENT_TO_WORLD 134 | return ps.vmesh.interpolators2; 135 | #else 136 | return float4(0, 0, 0, 0); 137 | #endif 138 | } 139 | 140 | int GetLOD(float3 absoluteWorldPosition) 141 | { 142 | #ifndef LODS_ENABLED 143 | return 0; 144 | #else 145 | 146 | float3 disp = absoluteWorldPosition - _WorldSpaceCameraPos; 147 | float sqrDist = dot(disp, disp); 148 | 149 | int result = 3; 150 | result = lerp(result, 2, sqrDist < _GrassLODSqrDistances[2]); 151 | result = lerp(result, 1, sqrDist < _GrassLODSqrDistances[1]); 152 | result = lerp(result, 0, sqrDist < _GrassLODSqrDistances[0]); 153 | 154 | return result; 155 | #endif 156 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d7c4fe8fd35cc743a56d605e6ea17fb 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Fragment.hlsl: -------------------------------------------------------------------------------- 1 | #include "../../Grass_Common_GBuffer.hlsl" 2 | 3 | void GrassFragment( 4 | PackedVaryingsToPS packedInput, 5 | OUTPUT_GBUFFER(outGBuffer) 6 | #ifdef _DEPTHOFFSET_ON 7 | , out float outputDepth : SV_Depth 8 | #endif 9 | ) 10 | { 11 | // force this to 'none' so unity doesnt try to do any normal flipping 12 | _DoubleSidedConstants = float4(1, 1, 1, 1); 13 | 14 | FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); 15 | 16 | // input.positionSS is SV_Position 17 | PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS); 18 | 19 | float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); 20 | 21 | SurfaceData surfaceData; 22 | BuiltinData builtinData; 23 | GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); 24 | 25 | #ifdef NORMAL_TYPE_OVERRIDE 26 | surfaceData.normalWS = mul(normalize(_AbsoluteNormal).xyz, input.tangentToWorld).xyz; 27 | #endif 28 | 29 | #ifdef VISUALIZE_WIND 30 | 31 | float3 absolutePos = GetAbsolutePositionWS(input.positionRWS); 32 | float2 windUV = absolutePos.xz * _WindDistortionMap_ST.xy + _WindDistortionMap_ST.zw + _WindFrequency * _Time.y; 33 | half2 windSample = (tex2Dlod(_WindDistortionMap, float4(windUV, 0, 0)).xy); 34 | 35 | surfaceData.baseColor = float3(windSample, 0); 36 | 37 | #elif VISUALIZE_DISPLACEMENT 38 | 39 | float3 absolutePos = GetAbsolutePositionWS(input.positionRWS); 40 | half3 sphereDisp = half3(0, 0, 0); 41 | for (int i = 0; i < _GrassDisplacementSpheresBufferCount; i++) 42 | { 43 | GrassDisplacement displacementData = _GrassDisplacementSpheresBuffer[i]; 44 | float3 position = _GrassDisplacementSpheresBuffer[i].position; 45 | 46 | float3 distance = length(position - absolutePos); 47 | float3 circle = 1 - saturate(distance * displacementData.inverseRadius); 48 | 49 | sphereDisp += (absolutePos - position) * circle; 50 | sphereDisp = clamp(sphereDisp.xyz * displacementData.power, -0.8, 0.8); 51 | } 52 | 53 | surfaceData.baseColor = sphereDisp; 54 | 55 | #elif VISUALIZE_LODS 56 | 57 | int lod = GetLOD(GetAbsolutePositionWS(input.positionRWS)); 58 | 59 | half3 col = half3(0, 0, 0); 60 | col = lerp(col, half3(1, 0, 0), lod == 0); 61 | col = lerp(col, half3(0, 1, 0), lod == 1); 62 | col = lerp(col, half3(0, 0, 1), lod == 2); 63 | 64 | surfaceData.baseColor = col; 65 | #else 66 | 67 | #ifdef VARYINGS_NEED_TEXCOORD1 68 | float2 grassTextureUV = packedInput.vmesh.interpolators3.zw * _FieldTexture_ST.xy + _FieldTexture_ST.zw; 69 | surfaceData.baseColor = tex2Dlod(_FieldTexture, float4(grassTextureUV, 0, 0)).rgb; 70 | #else 71 | surfaceData.baseColor = half3(1, 1, 1); 72 | #endif 73 | 74 | float3 grassBladeTex = tex2Dlod(_BladeTexture, float4(input.texCoord0.xy, 0, 0)).rgb; 75 | 76 | surfaceData.baseColor *= grassBladeTex * lerp(_GrassBottomColour, _GrassTopColour, input.texCoord0.y).rgb; 77 | //surfaceData.baseColor = float3(1, 0, 0); 78 | 79 | builtinData.opacity = 0.5; 80 | 81 | #endif 82 | 83 | /*GRASS_*/ENCODE_INTO_GBUFFER(surfaceData, builtinData, posInput.positionSS, outGBuffer); 84 | 85 | #ifdef _DEPTHOFFSET_ON 86 | outputDepth = posInput.deviceDepth; 87 | #endif 88 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Fragment.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76f54db28b109bd4daa1d49c21712ed2 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_FragmentForward.hlsl: -------------------------------------------------------------------------------- 1 | 2 | void Frag2(PackedVaryingsToPS packedInput, 3 | #ifdef OUTPUT_SPLIT_LIGHTING 4 | out float4 outColor : SV_Target0, // outSpecularLighting 5 | out float4 outDiffuseLighting : SV_Target1, 6 | OUTPUT_SSSBUFFER(outSSSBuffer) 7 | #else 8 | out float4 outColor : SV_Target0 9 | #ifdef _WRITE_TRANSPARENT_MOTION_VECTOR 10 | , out float4 outMotionVec : SV_Target1 11 | #endif // _WRITE_TRANSPARENT_MOTION_VECTOR 12 | #endif // OUTPUT_SPLIT_LIGHTING 13 | #ifdef _DEPTHOFFSET_ON 14 | , out float outputDepth : SV_Depth 15 | #endif 16 | ) 17 | { 18 | #ifdef _WRITE_TRANSPARENT_MOTION_VECTOR 19 | // Init outMotionVector here to solve compiler warning (potentially unitialized variable) 20 | // It is init to the value of forceNoMotion (with 2.0) 21 | outMotionVec = float4(2.0, 0.0, 0.0, 0.0); 22 | #endif 23 | 24 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput); 25 | FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh); 26 | 27 | // We need to readapt the SS position as our screen space positions are for a low res buffer, but we try to access a full res buffer. 28 | input.positionSS.xy = _OffScreenRendering > 0 ? (input.positionSS.xy * _OffScreenDownsampleFactor) : input.positionSS.xy; 29 | 30 | uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize(); 31 | 32 | // input.positionSS is SV_Position 33 | PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex); 34 | 35 | #ifdef VARYINGS_NEED_POSITION_WS 36 | float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS); 37 | #else 38 | // Unused 39 | float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0 40 | #endif 41 | 42 | SurfaceData surfaceData; 43 | BuiltinData builtinData; 44 | GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData); 45 | 46 | 47 | BSDFData bsdfData = ConvertSurfaceDataToBSDFData(input.positionSS.xy, surfaceData); 48 | 49 | PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); 50 | 51 | outColor = float4(0.0, 0.0, 0.0, 0.0); 52 | 53 | 54 | 55 | 56 | // We need to skip lighting when doing debug pass because the debug pass is done before lighting so some buffers may not be properly initialized potentially causing crashes on PS4. 57 | 58 | #ifdef DEBUG_DISPLAY 59 | // Init in debug display mode to quiet warning 60 | #ifdef OUTPUT_SPLIT_LIGHTING 61 | outDiffuseLighting = 0; 62 | ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer); 63 | #endif 64 | 65 | 66 | 67 | // Same code in ShaderPassForwardUnlit.shader 68 | // Reminder: _DebugViewMaterialArray[i] 69 | // i==0 -> the size used in the buffer 70 | // i>0 -> the index used (0 value means nothing) 71 | // The index stored in this buffer could either be 72 | // - a gBufferIndex (always stored in _DebugViewMaterialArray[1] as only one supported) 73 | // - a property index which is different for each kind of material even if reflecting the same thing (see MaterialSharedProperty) 74 | bool viewMaterial = false; 75 | int bufferSize = int(_DebugViewMaterialArray[0]); 76 | if (bufferSize != 0) 77 | { 78 | bool needLinearToSRGB = false; 79 | float3 result = float3(1.0, 0.0, 1.0); 80 | 81 | // Loop through the whole buffer 82 | // Works because GetSurfaceDataDebug will do nothing if the index is not a known one 83 | for (int index = 1; index <= bufferSize; index++) 84 | { 85 | int indexMaterialProperty = int(_DebugViewMaterialArray[index]); 86 | 87 | // skip if not really in use 88 | if (indexMaterialProperty != 0) 89 | { 90 | viewMaterial = true; 91 | 92 | GetPropertiesDataDebug(indexMaterialProperty, result, needLinearToSRGB); 93 | GetVaryingsDataDebug(indexMaterialProperty, input, result, needLinearToSRGB); 94 | GetBuiltinDataDebug(indexMaterialProperty, builtinData, result, needLinearToSRGB); 95 | GetSurfaceDataDebug(indexMaterialProperty, surfaceData, result, needLinearToSRGB); 96 | GetBSDFDataDebug(indexMaterialProperty, bsdfData, result, needLinearToSRGB); 97 | } 98 | } 99 | 100 | // TEMP! 101 | // For now, the final blit in the backbuffer performs an sRGB write 102 | // So in the meantime we apply the inverse transform to linear data to compensate. 103 | if (!needLinearToSRGB) 104 | result = SRGBToLinear(max(0, result)); 105 | 106 | outColor = float4(result, 1.0); 107 | } 108 | 109 | if (!viewMaterial) 110 | { 111 | if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_DIFFUSE_COLOR || _DebugFullScreenMode == FULLSCREENDEBUGMODE_VALIDATE_SPECULAR_COLOR) 112 | { 113 | float3 result = float3(0.0, 0.0, 0.0); 114 | 115 | GetPBRValidatorDebug(surfaceData, result); 116 | 117 | outColor = float4(result, 1.0f); 118 | } 119 | else if (_DebugFullScreenMode == FULLSCREENDEBUGMODE_TRANSPARENCY_OVERDRAW) 120 | { 121 | float4 result = _DebugTransparencyOverdrawWeight * float4(TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_COST, TRANSPARENCY_OVERDRAW_A); 122 | outColor = result; 123 | } 124 | else 125 | #endif 126 | { 127 | #ifdef _SURFACE_TYPE_TRANSPARENT 128 | uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_TRANSPARENT; 129 | #else 130 | uint featureFlags = LIGHT_FEATURE_MASK_FLAGS_OPAQUE; 131 | #endif 132 | float3 diffuseLighting; 133 | float3 specularLighting; 134 | 135 | LightLoop(V, posInput, preLightData, bsdfData, builtinData, featureFlags, diffuseLighting, specularLighting); 136 | 137 | diffuseLighting *= GetCurrentExposureMultiplier(); 138 | specularLighting *= GetCurrentExposureMultiplier(); 139 | 140 | #ifdef OUTPUT_SPLIT_LIGHTING 141 | if (_EnableSubsurfaceScattering != 0 && ShouldOutputSplitLighting(bsdfData)) 142 | { 143 | outColor = float4(specularLighting, 1.0); 144 | outDiffuseLighting = float4(TagLightingForSSS(diffuseLighting), 1.0); 145 | } 146 | else 147 | { 148 | outColor = float4(diffuseLighting + specularLighting, 1.0); 149 | outDiffuseLighting = 0; 150 | } 151 | ENCODE_INTO_SSSBUFFER(surfaceData, posInput.positionSS, outSSSBuffer); 152 | #else 153 | outColor = ApplyBlendMode(diffuseLighting, specularLighting, builtinData.opacity); 154 | outColor = EvaluateAtmosphericScattering(posInput, V, outColor); 155 | 156 | #ifdef VARYINGS_NEED_TEXCOORD1 157 | float2 grassTextureUV = packedInput.vmesh.interpolators3.zw * _FieldTexture_ST.xy + _FieldTexture_ST.zw; 158 | outColor *= tex2Dlod(_FieldTexture, float4(grassTextureUV, 0, 0)); 159 | #else 160 | outColor *= float4(1, 1, 1, 1); 161 | #endif 162 | 163 | float4 grassBladeTex = tex2Dlod(_BladeTexture, float4(input.texCoord0.xy, 0, 0)); 164 | 165 | outColor *= grassBladeTex * lerp(_GrassBottomColour, _GrassTopColour, input.texCoord0.y); 166 | 167 | 168 | #endif 169 | 170 | #ifdef _WRITE_TRANSPARENT_MOTION_VECTOR 171 | VaryingsPassToPS inputPass = UnpackVaryingsPassToPS(packedInput.vpass); 172 | bool forceNoMotion = any(unity_MotionVectorsParams.yw == 0.0); 173 | // outMotionVec is already initialize at the value of forceNoMotion (see above) 174 | if (!forceNoMotion) 175 | { 176 | float2 motionVec = CalculateMotionVector(inputPass.positionCS, inputPass.previousPositionCS); 177 | EncodeMotionVector(motionVec * 0.5, outMotionVec); 178 | outMotionVec.zw = 1.0; 179 | } 180 | #endif 181 | } 182 | 183 | #ifdef DEBUG_DISPLAY 184 | } 185 | #endif 186 | 187 | #ifdef _DEPTHOFFSET_ON 188 | outputDepth = posInput.deviceDepth; 189 | #endif 190 | } 191 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_FragmentForward.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db13c12ec409f9747973fba8c67386ec 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Geometry.hlsl: -------------------------------------------------------------------------------- 1 | #define MAX_SEGMENTS 10 2 | 3 | 4 | int GetSegmentCount(float3 absoluteWorldPosition) 5 | { 6 | int lod = GetLOD(absoluteWorldPosition); 7 | 8 | if (lod > 2) 9 | return 0; 10 | 11 | return _GrassLODSegments[lod]; 12 | } 13 | 14 | PackedVaryingsToPS GenerateGrass(PackedVaryingsToPS base, float3 vertexPosition, float3 displacement, float width, float height, float forward, float2 uv, float2 originalUVs, float3 worldUp, float3 tangent, float3x3 transformMatrix) 15 | { 16 | PackedVaryingsToPS result = base; 17 | 18 | vertexPosition += displacement; 19 | 20 | float3 _2dPoint = float3(width, forward, height); 21 | float3 tangentNormal = normalize(float3(0, -1, forward)); 22 | float3 localNormal = mul(transformMatrix, tangentNormal); 23 | 24 | float3 localPosition = mul(transformMatrix, _2dPoint); 25 | 26 | #ifdef NORMAL_TYPE_TRUE 27 | float3 normal = TransformObjectToWorldNormal(localNormal); 28 | #else 29 | float3 normal = worldUp; 30 | #endif 31 | 32 | #ifdef BILLBOARD 33 | float projectedAngle = GetProjectedAngle(vertexPosition, float3(0, 0, 0), worldUp, tangent); 34 | float3x3 projectedRot = AngleAxis3x3(PI * 0.5 + projectedAngle, worldUp); 35 | 36 | float3 worldPosition = vertexPosition + mul(projectedRot, localPosition); 37 | #else 38 | float3 worldPosition = vertexPosition + localPosition; 39 | #endif 40 | 41 | // set position in world space 42 | SetPosition(result, worldPosition); 43 | SetUV0(result, uv); 44 | SetUV1(result, originalUVs); 45 | SetNormal(result, normal); 46 | 47 | return result; 48 | } 49 | 50 | // Attributes -> VaryingsToPS 51 | 52 | [maxvertexcount(2 * (MAX_SEGMENTS * 2 + 1))] 53 | void GrassGeometry(triangle PackedVaryingsToPS input[3], uint pid : SV_PrimitiveID, inout TriangleStream outStream) 54 | { 55 | PackedVaryingsToPS ps0 = input[0]; 56 | PackedVaryingsToPS ps1 = input[1]; 57 | PackedVaryingsToPS ps2 = input[2]; 58 | 59 | // we get all the information about the first vertex of the triangle. 60 | // it's pretty much arbitrary that we use the first, we could use all three 61 | // vertices to get more accurate results but the tris are small enough that it should 62 | // be negligible. 63 | float3 position0 = GetPosition(ps0); 64 | float3 absolutePosition0 = GetAbsolutePositionWS(position0); 65 | 66 | int segmentCount = GetSegmentCount(absolutePosition0); 67 | 68 | if (segmentCount == 0) 69 | return; 70 | 71 | float3 normal0 = GetNormal(ps0); 72 | float4 tangent0 = GetTangent(ps0); 73 | float2 uv0 = GetUV0(ps0); 74 | float3 binormal0 = cross(normal0, tangent0.xyz) * tangent0.w; 75 | 76 | float3x3 tangentToLocal = float3x3 77 | ( 78 | tangent0.x, binormal0.x, normal0.x, 79 | tangent0.y, binormal0.y, normal0.y, 80 | tangent0.z, binormal0.z, normal0.z 81 | ); 82 | 83 | float3 idSeed = float3(pid, pid, pid); 84 | 85 | // randomly divide 1.0 in 3 ways in order to position the grass blade randomly on the tri 86 | half rand0 = smoothRand(absolutePosition0.yyz); 87 | half rand1 = smoothRand(absolutePosition0.yxz); 88 | half rand2 = smoothRand(absolutePosition0.xxz); 89 | half sum = rand0 + rand1 + rand2; 90 | 91 | half part0 = lerp(0.3333, rand0 / sum, _GrassOffset); 92 | half part1 = lerp(0.3333, rand1 / sum, _GrassOffset); 93 | half part2 = lerp(0.3333, rand2 / sum, _GrassOffset); 94 | 95 | float3 position = part0 * position0 + part1 * GetPosition(ps1) + part2 * GetPosition(ps2); 96 | float3 originalNormal = normal0;// part0 * normal0 + part1 * GetNormal(ps1) + part2 * GetNormal(ps2); 97 | half4 color = GetColor(ps0);//part0 * GetColor(ps0) + part1 * GetColor(ps1) + part2 * GetColor(ps2); 98 | 99 | half polybrush = color.r; 100 | 101 | // sampling from the grass map to scale the grass blades by the red channel at this position 102 | float2 grassMapUV = uv0 * _GrassMap_ST.xy + _GrassMap_ST.zw; 103 | float grassMapScale = tex2Dlod(_GrassMap, float4(grassMapUV, 0, 0)).r; 104 | 105 | half height = ((smoothRand(absolutePosition0.zyx) * 2 - 1) * _BladeHeightRandom + _BladeHeight) * grassMapScale * polybrush; 106 | half width = ((smoothRand(absolutePosition0.xzy) * 2 - 1) * _BladeWidthRandom + _BladeWidth) * grassMapScale * polybrush; 107 | 108 | if (height <= 0 || width <= 0) 109 | return; 110 | 111 | half forward = smoothRand(absolutePosition0.yzx) * _BladeForward; 112 | 113 | //////////////// WIND 114 | float2 windUV = absolutePosition0.xz * _WindDistortionMap_ST.xy + _WindDistortionMap_ST.zw + _WindFrequency * _Time.y; 115 | float2 windSample = (tex2Dlod(_WindDistortionMap, float4(windUV, 0, 0)).rg * 2 - 1) * max(0.000001, abs(_WindStrength)); 116 | half3 wind = normalize(float3(windSample.x, windSample.y, 0)); 117 | float3x3 windRotation = AngleAxis3x3(PI * length(windSample), wind); 118 | //////////////// 119 | 120 | #ifndef BILLBOARD 121 | float3x3 bendRotationMatrix = AngleAxis3x3(smoothRand(absolutePosition0.zzx) * _BendRotationRandom * PI * 0.5, float3(-1, 0, 0)); 122 | float3x3 facingRotationMatrix = AngleAxis3x3(DegToRad(smoothRand(absolutePosition0) * _BladeRotationRange), float3(0, 0, 1)); 123 | 124 | float3x3 transformationMatrix = mul(mul(mul(tangentToLocal, windRotation), facingRotationMatrix), bendRotationMatrix); 125 | float3x3 transformationMatrixFacing = mul(tangentToLocal, facingRotationMatrix); 126 | #else 127 | float3x3 transformationMatrix = mul(tangentToLocal, windRotation); 128 | float3x3 transformationMatrixFacing = tangentToLocal; 129 | #endif 130 | 131 | //////////////// DISPLACEMENT SPHERES 132 | 133 | half3 totalSphereDisp = float3(0, 0, 0); 134 | #ifdef APPLY_DISPLACEMENT 135 | for (int i = 0; i < _GrassDisplacementSpheresBufferCount; i++) 136 | { 137 | half3 sphereDisp = float3(0, 0, 0); 138 | 139 | GrassDisplacement displacementData =_GrassDisplacementSpheresBuffer[i]; 140 | half3 displacerPos = displacementData.position; 141 | 142 | half3 distance = length(displacerPos - absolutePosition0); 143 | half3 circle = 1 - saturate(distance * displacementData.inverseRadius); 144 | 145 | sphereDisp += (absolutePosition0 - displacerPos) * circle; 146 | sphereDisp = clamp(sphereDisp.xyz * displacementData.power, -0.8, 0.8); 147 | 148 | totalSphereDisp += sphereDisp; 149 | } 150 | #endif 151 | //////////////// 152 | 153 | for (int j = 0; j < segmentCount; j++) 154 | { 155 | float t = j / (float)segmentCount; 156 | 157 | half segmentHeight = height * t; 158 | half segmentWidth = width; 159 | 160 | #ifndef GENERATE_QUADS 161 | segmentWidth *= (1 - t); 162 | #endif 163 | 164 | half segmentForward = pow(abs(t), _BladeCurve) * forward; 165 | 166 | float3x3 transformMatrix = j == 0 ? transformationMatrixFacing : transformationMatrix; 167 | half3 displacement = j == 0 ? float3(0, 0, 0) : totalSphereDisp; 168 | 169 | #ifdef VISUALIZE_WIND 170 | float2 uvLeft = uv0; 171 | float2 uvRight = uv0; 172 | #else 173 | float2 uvLeft = float2(0, t); 174 | float2 uvRight = float2(1, t); 175 | #endif 176 | 177 | outStream.Append(GenerateGrass(ps0, position, displacement, segmentWidth, segmentHeight, segmentForward, uvLeft, uv0, originalNormal, tangent0, transformMatrix)); 178 | outStream.Append(GenerateGrass(ps0, position, displacement, -segmentWidth, segmentHeight, segmentForward, uvRight, uv0, originalNormal, tangent0, transformMatrix)); 179 | } 180 | 181 | #ifdef VISUALIZE_WIND 182 | float2 uv = uv0; 183 | #else 184 | float2 uv = float2(0.5, 1); 185 | #endif 186 | 187 | #ifndef GENERATE_QUADS 188 | // the tip of the grass blade 189 | outStream.Append(GenerateGrass(ps0, position, float3(totalSphereDisp.x * 1.5, totalSphereDisp.y, totalSphereDisp.z * 1.5), 0, height, forward, float2(0.5, 1), uv0, originalNormal, tangent0, transformationMatrix)); 190 | #else 191 | // the tip of the grass quad 192 | outStream.Append(GenerateGrass(ps0, position, float3(totalSphereDisp.x * 1.5, totalSphereDisp.y, totalSphereDisp.z * 1.5), width, height, forward, float2(0, 1), uv0, originalNormal, tangent0, transformationMatrix)); 193 | outStream.Append(GenerateGrass(ps0, position, float3(totalSphereDisp.x * 1.5, totalSphereDisp.y, totalSphereDisp.z * 1.5), -width, height, forward, float2(1, 1), uv0, originalNormal, tangent0, transformationMatrix)); 194 | #endif 195 | 196 | outStream.RestartStrip(); 197 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Geometry.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97c826ebfa2f789439ff40d431d6bd12 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_GeometryPassthrough.hlsl: -------------------------------------------------------------------------------- 1 | [maxvertexcount(3)] 2 | void GrassGeometry(triangle PackedVaryingsToPS input[3], uint pid : SV_PrimitiveID, inout TriangleStream outStream) 3 | { 4 | outStream.Append(input[0]); 5 | outStream.Append(input[1]); 6 | outStream.Append(input[2]); 7 | 8 | outStream.RestartStrip(); 9 | } -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_GeometryPassthrough.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81f54f43a48bff347868e476092222fa 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Properties.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d8f5631408c78f4887d57a0b9b60834 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Shader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c53b87940c91d945a7892f9d6732be3 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: '{"shaderPath":"Grass","attributes":[{"channel":64,"index":0,"range":{"x":0.0,"y":1.0},"propertyTarget":"_Texture1","mask":0}]}' 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Tesselation.hlsl: -------------------------------------------------------------------------------- 1 | #if defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) 2 | // AMD recommand this value for GCN http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/05/GCNPerformanceTweets.pdf 3 | #define MAX_TESSELLATION_FACTORS 15.0 4 | #else 5 | #define MAX_TESSELLATION_FACTORS 64.0 6 | #endif 7 | 8 | struct TessellationFactorsCust 9 | { 10 | float edge[3] : SV_TessFactor; 11 | float inside : SV_InsideTessFactor; 12 | }; 13 | 14 | float UnityDistanceFromPlane(float3 pos, float4 plane) 15 | { 16 | return dot(float4(pos, 1), plane); 17 | } 18 | 19 | float GetDensity(float3 absoluteWorldPosition) 20 | { 21 | int lod = GetLOD(absoluteWorldPosition); 22 | 23 | return lerp(_GrassLODDensities[lod], 0, lod > 2); 24 | } 25 | 26 | // Returns true if triangle with given 3 world positions is outside of camera's view frustum. 27 | // cullEps is distance outside of frustum that is still considered to be inside (i.e. max displacement) 28 | bool UnityWorldViewFrustumCull (float3 wpos0, float3 wpos1, float3 wpos2, float cullEps) 29 | { 30 | float4 left = _FrustumPlanes[0]; 31 | float4 right = _FrustumPlanes[1]; 32 | float4 top = _FrustumPlanes[2]; 33 | float4 bottom = _FrustumPlanes[3]; 34 | 35 | // has to pass all 4 plane tests to be visible 36 | return !all(float4 37 | ( 38 | // left 39 | (UnityDistanceFromPlane(wpos0, left) > 0) + 40 | (UnityDistanceFromPlane(wpos1, left) > 0) + 41 | (UnityDistanceFromPlane(wpos2, left) > 0), 42 | 43 | // right 44 | (UnityDistanceFromPlane(wpos0, right) > 0) + 45 | (UnityDistanceFromPlane(wpos1, right) > 0) + 46 | (UnityDistanceFromPlane(wpos2, right) > 0), 47 | 48 | // top 49 | (UnityDistanceFromPlane(wpos0, top) > 0) + 50 | (UnityDistanceFromPlane(wpos1, top) > 0) + 51 | (UnityDistanceFromPlane(wpos2, top) > 0), 52 | 53 | // bottom 54 | (UnityDistanceFromPlane(wpos0, bottom) > 0) + 55 | (UnityDistanceFromPlane(wpos1, bottom) > 0) + 56 | (UnityDistanceFromPlane(wpos2, bottom) > 0) 57 | )); 58 | } 59 | 60 | TessellationFactorsCust HullConstantC(InputPatch input) 61 | { 62 | TessellationFactorsCust output; 63 | 64 | // don't do anything if it's the shadow pass and we're not casting shadows 65 | #if !defined(CAST_SHADOWS) && SHADERPASS == SHADERPASS_SHADOWS 66 | output.edge[0] = 0; 67 | output.edge[1] = 0; 68 | output.edge[2] = 0; 69 | output.inside = 0; 70 | return output; 71 | #else 72 | 73 | VaryingsToDS varying0 = UnpackVaryingsToDS(input[0]); 74 | VaryingsToDS varying1 = UnpackVaryingsToDS(input[1]); 75 | VaryingsToDS varying2 = UnpackVaryingsToDS(input[2]); 76 | 77 | float3 p0 = varying0.vmesh.positionRWS; 78 | float3 p1 = varying1.vmesh.positionRWS; 79 | float3 p2 = varying2.vmesh.positionRWS; 80 | 81 | float density = clamp(GetDensity(GetAbsolutePositionWS(p0)), 0, MAX_TESSELLATION_FACTORS); 82 | 83 | #ifdef FRUSTUM_CULLING 84 | if (UnityWorldViewFrustumCull(p0, p1, p2, _FrustumCullingScreenSpaceMargin)) 85 | { 86 | output.edge[0] = 0; 87 | output.edge[1] = 0; 88 | output.edge[2] = 0; 89 | output.inside = 0; 90 | return output; 91 | } 92 | #endif 93 | 94 | #ifdef PROPORTIONAL_TESSELATION 95 | float length12 = distance(p1, p2) * density; 96 | float length20 = distance(p2, p0) * density; 97 | float length01 = distance(p0, p1) * density; 98 | 99 | // ref: https://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/ 100 | 101 | output.edge[0] = length12; 102 | output.edge[1] = length20; 103 | output.edge[2] = length01; 104 | output.inside = (length12 + length20 + length01) * 0.333; 105 | #else 106 | output.edge[0] = density; 107 | output.edge[1] = density; 108 | output.edge[2] = density; 109 | output.inside = density; 110 | #endif 111 | 112 | return output; 113 | #endif 114 | } 115 | 116 | [maxtessfactor(MAX_TESSELLATION_FACTORS)] 117 | [domain("tri")] 118 | //[partitioning("fractional_odd")] 119 | [partitioning("integer")] 120 | [outputtopology("triangle_cw")] 121 | [patchconstantfunc("HullConstantC")] 122 | [outputcontrolpoints(3)] 123 | PackedVaryingsToDS GrassHull(InputPatch input, uint id : SV_OutputControlPointID) 124 | { 125 | // Pass-through 126 | return input[id]; 127 | } 128 | 129 | [domain("tri")] 130 | PackedVaryingsToPS GrassDomain(TessellationFactorsCust tessFactors, const OutputPatch input, float3 baryCoords : SV_DomainLocation) 131 | { 132 | VaryingsToDS varying0 = UnpackVaryingsToDS(input[0]); 133 | VaryingsToDS varying1 = UnpackVaryingsToDS(input[1]); 134 | VaryingsToDS varying2 = UnpackVaryingsToDS(input[2]); 135 | 136 | VaryingsToDS varying = InterpolateWithBaryCoordsToDS(varying0, varying1, varying2, baryCoords); 137 | 138 | //#ifdef HAVE_TESSELLATION_MODIFICATION 139 | // ApplyTessellationModification(varying.vmesh, varying.vmesh.normalWS, varying.vmesh.positionRWS); 140 | //#endif 141 | 142 | return VertTesselation(varying); 143 | } 144 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/TesselationGeometry/Shaders/Grass_TesselationGeometry_Tesselation.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20493844ffee61f48a897020e620cc68 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f88b8a10dcb7ca4d963aa29ffc8714f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/AlienGrass_FieldTex1.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:82dd3189e0bd714a1723b3766f1d0cea4e663e94858a8da16f8fe35035b9abe9 3 | size 4224 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/AlienGrass_FieldTex1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb3e7d19676494d4a922d76ca6c120c6 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 2048 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | spriteSheet: 87 | serializedVersion: 2 88 | sprites: [] 89 | outline: [] 90 | physicsShape: [] 91 | bones: [] 92 | spriteID: 93 | internalID: 0 94 | vertices: [] 95 | indices: 96 | edges: [] 97 | weights: [] 98 | secondaryTextures: [] 99 | spritePackingTag: 100 | pSDRemoveMatte: 0 101 | pSDShowRemoveMatteOption: 0 102 | userData: 103 | assetBundleName: 104 | assetBundleVariant: 105 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/AlienGrass_FieldTex2.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:e766b4418a1e3641f952c3c3a244ac1f193aca0403bf771625028202cae59ac1 3 | size 74149 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/AlienGrass_FieldTex2.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ad8d495b17a10d4e8c5a7270a8da7f5 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: 4 36 | mipBias: -1 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 8192 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 8192 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 1 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: iPhone 88 | maxTextureSize: 8192 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: Android 100 | maxTextureSize: 8192 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | - serializedVersion: 3 111 | buildTarget: Windows Store Apps 112 | maxTextureSize: 8192 113 | resizeAlgorithm: 0 114 | textureFormat: -1 115 | textureCompression: 1 116 | compressionQuality: 50 117 | crunchedCompression: 0 118 | allowsAlphaSplitting: 0 119 | overridden: 0 120 | androidETC2FallbackOverride: 0 121 | forceMaximumCompressionQuality_BC6H_BC7: 0 122 | spriteSheet: 123 | serializedVersion: 2 124 | sprites: [] 125 | outline: [] 126 | physicsShape: [] 127 | bones: [] 128 | spriteID: 129 | internalID: 0 130 | vertices: [] 131 | indices: 132 | edges: [] 133 | weights: [] 134 | secondaryTextures: [] 135 | spritePackingTag: 136 | pSDRemoveMatte: 0 137 | pSDShowRemoveMatteOption: 0 138 | userData: 139 | assetBundleName: 140 | assetBundleVariant: 141 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/GrassWind.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bde63a20b60f9126eef15e774f2212bf02c5f46c04becb195273f107662808bd 3 | size 197244 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/GrassWind.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ad620967ea439b4c9a63ca1b8ecf570 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 2 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 0 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 512 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 2 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 512 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 2 80 | compressionQuality: 50 81 | crunchedCompression: 0 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | spriteSheet: 87 | serializedVersion: 2 88 | sprites: [] 89 | outline: [] 90 | physicsShape: [] 91 | bones: [] 92 | spriteID: 93 | internalID: 0 94 | vertices: [] 95 | indices: 96 | edges: [] 97 | weights: [] 98 | secondaryTextures: [] 99 | spritePackingTag: 100 | pSDRemoveMatte: 0 101 | pSDShowRemoveMatteOption: 0 102 | userData: 103 | assetBundleName: 104 | assetBundleVariant: 105 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/Lawn.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:85384ab5675626f9caeaaf6140cd88b9aedce3a0b23a9459a6e425fd60c979a2 3 | size 454 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/Lawn.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52f0c7d9778429342bab1fb58ce72102 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 0 35 | aniso: 4 36 | mipBias: -1 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 0 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 256 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 3 68 | compressionQuality: 50 69 | crunchedCompression: 1 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | - serializedVersion: 3 75 | buildTarget: Standalone 76 | maxTextureSize: 256 77 | resizeAlgorithm: 0 78 | textureFormat: -1 79 | textureCompression: 3 80 | compressionQuality: 50 81 | crunchedCompression: 1 82 | allowsAlphaSplitting: 0 83 | overridden: 0 84 | androidETC2FallbackOverride: 0 85 | forceMaximumCompressionQuality_BC6H_BC7: 0 86 | - serializedVersion: 3 87 | buildTarget: iPhone 88 | maxTextureSize: 8192 89 | resizeAlgorithm: 0 90 | textureFormat: -1 91 | textureCompression: 1 92 | compressionQuality: 50 93 | crunchedCompression: 0 94 | allowsAlphaSplitting: 0 95 | overridden: 0 96 | androidETC2FallbackOverride: 0 97 | forceMaximumCompressionQuality_BC6H_BC7: 0 98 | - serializedVersion: 3 99 | buildTarget: Android 100 | maxTextureSize: 8192 101 | resizeAlgorithm: 0 102 | textureFormat: -1 103 | textureCompression: 1 104 | compressionQuality: 50 105 | crunchedCompression: 0 106 | allowsAlphaSplitting: 0 107 | overridden: 0 108 | androidETC2FallbackOverride: 0 109 | forceMaximumCompressionQuality_BC6H_BC7: 0 110 | - serializedVersion: 3 111 | buildTarget: Windows Store Apps 112 | maxTextureSize: 8192 113 | resizeAlgorithm: 0 114 | textureFormat: -1 115 | textureCompression: 1 116 | compressionQuality: 50 117 | crunchedCompression: 0 118 | allowsAlphaSplitting: 0 119 | overridden: 0 120 | androidETC2FallbackOverride: 0 121 | forceMaximumCompressionQuality_BC6H_BC7: 0 122 | spriteSheet: 123 | serializedVersion: 2 124 | sprites: [] 125 | outline: [] 126 | physicsShape: [] 127 | bones: [] 128 | spriteID: 129 | internalID: 0 130 | vertices: [] 131 | indices: 132 | edges: [] 133 | weights: [] 134 | secondaryTextures: [] 135 | spritePackingTag: 136 | pSDRemoveMatte: 0 137 | pSDShowRemoveMatteOption: 0 138 | userData: 139 | assetBundleName: 140 | assetBundleVariant: 141 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/Soil.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:52d3f9f356e7b621101129684cdfc3451e1e118704fdbef3a57ed2774e29a655 3 | size 167484 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/Soil.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 527026e958cb93b4ea1bc984ff7f85de 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/WildGrass_BladeTex.png: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f3af75eaaebe55123df04cffa2d00c098b1ef9b390df69c6f84fac26a42534d1 3 | size 379 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/Grass/Textures/WildGrass_BladeTex.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 867e1f27f12312545afb382ae1d919ef 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 1 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: -1 38 | wrapV: -1 39 | wrapW: -1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/HDRP.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 614af06565cac0c4c88420b99170fda5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/HDRP/HDRenderPipelineAsset.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:10e50b95a2911f88a1448b7868665f408133e9afcc1ff86e672fbf6ea3a74c41 3 | size 10260 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/HDRP/HDRenderPipelineAsset.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e2e6bfc59709614ab90c0cd7d755e48 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/HDRP/Sky and Fog Settings Profile.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:7636bafadd5d0793fe697b4f14442dd1d08fbc251d447460cc4ab1d6c1c3d111 3 | size 4918 4 | -------------------------------------------------------------------------------- /HDRPGrass/Assets/HDRP/Sky and Fog Settings Profile.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ec7bce1e563f1943b707ec1767a414d 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /HDRPGrass/Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.cinemachine": "2.6.3", 4 | "com.unity.collab-proxy": "1.2.16", 5 | "com.unity.ide.rider": "1.1.4", 6 | "com.unity.ide.vscode": "1.2.1", 7 | "com.unity.inputsystem": "1.0.0", 8 | "com.unity.polybrush": "1.0.1", 9 | "com.unity.probuilder": "4.4.0", 10 | "com.unity.render-pipelines.high-definition": "7.5.1", 11 | "com.unity.test-framework": "1.1.16", 12 | "com.unity.textmeshpro": "2.1.1", 13 | "com.unity.timeline": "1.2.16", 14 | "com.unity.ugui": "1.0.0", 15 | "com.unity.modules.ai": "1.0.0", 16 | "com.unity.modules.androidjni": "1.0.0", 17 | "com.unity.modules.animation": "1.0.0", 18 | "com.unity.modules.assetbundle": "1.0.0", 19 | "com.unity.modules.audio": "1.0.0", 20 | "com.unity.modules.cloth": "1.0.0", 21 | "com.unity.modules.director": "1.0.0", 22 | "com.unity.modules.imageconversion": "1.0.0", 23 | "com.unity.modules.imgui": "1.0.0", 24 | "com.unity.modules.jsonserialize": "1.0.0", 25 | "com.unity.modules.particlesystem": "1.0.0", 26 | "com.unity.modules.physics": "1.0.0", 27 | "com.unity.modules.physics2d": "1.0.0", 28 | "com.unity.modules.screencapture": "1.0.0", 29 | "com.unity.modules.terrain": "1.0.0", 30 | "com.unity.modules.terrainphysics": "1.0.0", 31 | "com.unity.modules.tilemap": "1.0.0", 32 | "com.unity.modules.ui": "1.0.0", 33 | "com.unity.modules.uielements": "1.0.0", 34 | "com.unity.modules.umbra": "1.0.0", 35 | "com.unity.modules.unityanalytics": "1.0.0", 36 | "com.unity.modules.unitywebrequest": "1.0.0", 37 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 38 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 39 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 40 | "com.unity.modules.unitywebrequestwww": "1.0.0", 41 | "com.unity.modules.vehicles": "1.0.0", 42 | "com.unity.modules.video": "1.0.0", 43 | "com.unity.modules.vr": "1.0.0", 44 | "com.unity.modules.wind": "1.0.0", 45 | "com.unity.modules.xr": "1.0.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:aeedeb3243f07b61dbbe854aa08b5ef6f0b5274dd9852ad9f6129dde3e105a31 3 | size 413 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:40e65dd214bf254955d2c8829ca8ce2130fd3510485560ce012e9a1ddd93e623 3 | size 114 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:efb428a805ef5e01fe7cddf6c7c28d80567e32021f4560fbd5117c51a1bf7f5e 3 | size 1247 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:92424063df71a0cc2c53540fd53efa3ce0f551e790451e1f5a5d758ffa2b4917 3 | size 479 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:90de54e759ae98eb2028bc1a04fc5eda4b7b9f42eb9f42a70251763de1a41c41 3 | size 1114 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:58d0270f0812cf42ce01f8a1da858c6efa08e6180a09d1755c99b963c3534aee 3 | size 4266 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/HDRPProjectSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:853ee3013bb5298cabcde050acc1002b6aadc2930eecfcc14f13f39f0b65c72e 3 | size 880 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1decafae25223dfc0669fcf5837682f2f303499df59d348ce7e783b46d168d16 3 | size 9731 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:80106cfa7e6181a1928b142c075f3e510d527441e3d79bc83590e4ac91e7cd66 3 | size 1308 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:46395def99a6b5ae38ebb19b3e18f75215a9d4172c219361521a5a51e051f386 3 | size 151 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/Packages/com.unity.polybrush/Settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "m_Name": "Settings", 3 | "m_Path": "ProjectSettings/Packages/com.unity.polybrush/Settings.json", 4 | "m_Dictionary": { 5 | "m_DictionaryValues": [ 6 | { 7 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 8 | "key": "Editor.FloatingWindow", 9 | "value": "{\"m_Value\":false}" 10 | }, 11 | { 12 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 13 | "key": "SmoothBrush.IgnoreOpenEdges", 14 | "value": "{\"m_Value\":true}" 15 | }, 16 | { 17 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 18 | "key": "Brush.IgnoreUnselected", 19 | "value": "{\"m_Value\":true}" 20 | }, 21 | { 22 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 23 | "key": "Mesh.UseAdditionalVertexStream", 24 | "value": "{\"m_Value\":false}" 25 | }, 26 | { 27 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 28 | "key": "Brush.HideWireframe", 29 | "value": "{\"m_Value\":true}" 30 | }, 31 | { 32 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 33 | "key": "Mesh.RebuildNormals", 34 | "value": "{\"m_Value\":true}" 35 | }, 36 | { 37 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 38 | "key": "Brush.LockBrushToFirstObject", 39 | "value": "{\"m_Value\":true}" 40 | }, 41 | { 42 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 43 | "key": "Mesh.RebuildColliders", 44 | "value": "{\"m_Value\":true}" 45 | }, 46 | { 47 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 48 | "key": "RaiseLowerBrush.IgnoreOpenEdges", 49 | "value": "{\"m_Value\":true}" 50 | }, 51 | { 52 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 53 | "key": "RaiseLowerBrush.StickToFirstAppliedDirection", 54 | "value": "{\"m_Value\":true}" 55 | }, 56 | { 57 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 58 | "key": "Scattering.UsePivotForPlacement", 59 | "value": "{\"m_Value\":false}" 60 | }, 61 | { 62 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 63 | "key": "Scattering.ParentObjectsWithSurface", 64 | "value": "{\"m_Value\":true}" 65 | }, 66 | { 67 | "type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 68 | "key": "Scattering.AvoidOverlappingObjects", 69 | "value": "{\"m_Value\":false}" 70 | }, 71 | { 72 | "type": "UnityEngine.Polybrush.BrushMirror, Unity.Polybrush, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 73 | "key": "Brush.MirrorAxis", 74 | "value": "{\"m_Value\":0}" 75 | }, 76 | { 77 | "type": "UnityEngine.Polybrush.MirrorCoordinateSpace, Unity.Polybrush, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 78 | "key": "Brush.MirrorSpace", 79 | "value": "{\"m_Value\":0}" 80 | }, 81 | { 82 | "type": "UnityEngine.Polybrush.PolyDirection, Unity.Polybrush, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 83 | "key": "Brush.Direction", 84 | "value": "{\"m_Value\":1}" 85 | }, 86 | { 87 | "type": "UnityEngine.Polybrush.PolyDirection, Unity.Polybrush, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 88 | "key": "RaiseLowerBrush.Direction", 89 | "value": "{\"m_Value\":0}" 90 | }, 91 | { 92 | "type": "UnityEngine.Color, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 93 | "key": "Brush.BrushColor", 94 | "value": "{\"m_Value\":{\"r\":0.0,\"g\":0.800000011920929,\"b\":1.0,\"a\":1.0}}" 95 | }, 96 | { 97 | "type": "UnityEngine.Gradient, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 98 | "key": "Brush.BrushColorGradient", 99 | "value": "{\"m_Value\":{\"serializedVersion\":\"2\",\"key0\":{\"r\":0.22699999809265138,\"g\":1.0,\"b\":0.22699999809265138,\"a\":1.0},\"key1\":{\"r\":1.0,\"g\":1.0,\"b\":1.0,\"a\":0.2587999999523163},\"key2\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"key3\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"key4\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"key5\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"key6\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"key7\":{\"r\":0.0,\"g\":0.0,\"b\":0.0,\"a\":0.0},\"ctime0\":0,\"ctime1\":65535,\"ctime2\":0,\"ctime3\":0,\"ctime4\":0,\"ctime5\":0,\"ctime6\":0,\"ctime7\":0,\"atime0\":0,\"atime1\":65535,\"atime2\":0,\"atime3\":0,\"atime4\":0,\"atime5\":0,\"atime6\":0,\"atime7\":0,\"m_Mode\":0,\"m_NumColorKeys\":2,\"m_NumAlphaKeys\":2}}" 100 | }, 101 | { 102 | "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 103 | "key": "Brush.VertexBillboardSize", 104 | "value": "{\"m_Value\":2.0}" 105 | }, 106 | { 107 | "type": "System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 108 | "key": "RaiseLowerBrush.Strength", 109 | "value": "{\"m_Value\":5.0}" 110 | }, 111 | { 112 | "type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 113 | "key": "GI.WorkflowMode", 114 | "value": "{\"m_Value\":1}" 115 | }, 116 | { 117 | "type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", 118 | "key": "ScatteringEditor.PreviewThumSize", 119 | "value": "{\"m_Value\":64}" 120 | }, 121 | { 122 | "type": "UnityEditor.Polybrush.PrefabLoadout, Unity.Polybrush.Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 123 | "key": "ScatteringEditor.userLoadout", 124 | "value": "{\"m_Value\":{\"infos\":[]}}" 125 | } 126 | ] 127 | } 128 | } -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:50e61d70bc38c632cb0e6efe364a9c5bcfd9a8dbcf4e7b5ecfb06a2030c4518f 3 | size 2028 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:8102b0722a5a01773912492afba3c47dc28ba9c3eff45e54f6ac13c0fdc0e771 3 | size 344 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:37e714f333289d1510bae815788dfa89594e2596eb696e2bff6a454831c01d59 3 | size 19485 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.4.11f1 2 | m_EditorVersionWithRevision: 2019.4.11f1 (2d9804dddde7) 3 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:edf9eb088bdd2a97e78655de0635721fbabdd97370b4765bb5b635c0e294f83e 3 | size 1241 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:de1f77188f0fafb0877a1eba1a91c4a91f08725363bd448a350f14bd8e1b0395 3 | size 513 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:189be5677190854c2847f2269152d0e3c5fe7711cd9f73137ff1bbd0d1c60bac 3 | size 195 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:1e06370b3d2256d4dbc8892f59a8467d9f9785f034a4836a6790380252eb4916 3 | size 853 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f68fa7e3da5ecd48db67967b9954016d78c9c386a7dc672ed1c0ffab07987637 3 | size 528 4 | -------------------------------------------------------------------------------- /HDRPGrass/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:edd2beb4a2e388312b4b7da241aa51070434005d82c59363f1237dd2e567585f 3 | size 158 4 | -------------------------------------------------------------------------------- /HDRPGrass/fmod_editor.log: -------------------------------------------------------------------------------- 1 | [LOG] System::create : Header version = 2.00.10. Current version = 2.00.10. 2 | [LOG] Manager::init : maxchannels = 256 studioflags = 00000006 flags 00000000 extradriverdata 0000000000000000. 3 | [LOG] SystemI::init : Initialize version=20010 (110198), maxchannels=256, flags=0x00020000 4 | [LOG] SystemI::setOutputInternal : Setting output to 'FMOD WASAPI Output' 5 | [LOG] OutputWASAPI::init : Mix Format (WAVEFORMATEX): wFormatTag=0xFFFE, nChannels=2, nSamplesPerSec=48000, nAvgBytesPerSec=384000, nBlockAlign=8, wBitsPerSample=32, cbSize=22. 6 | [LOG] OutputWASAPI::init : Mix Format (WAVEFORMATEXTENSIBLE): wValidBitsPerSample=32, dwChannelMask=0x00000003, SubFormat=00000003-0000-0010-8000-00AA00389B71. 7 | [LOG] OutputWASAPI::init : Output buffer size: 4096 samples, latency: 0.00ms, period: 10.00ms, DSP buffer: 1024 * 4 8 | [LOG] Thread::initThread : Init FMOD stream thread. Priority: 2, Stack Size: 98304, Semaphore: No, Sleep Time: 10, Looping: Yes. 9 | [LOG] Thread::initThread : Init FMOD mixer thread. Priority: 3, Stack Size: 81920, Semaphore: No, Sleep Time: 0, Looping: Yes. 10 | [LOG] AsyncManager::init : manager 000001D9B1309A38 isAsync 0 updatePeriod 0.02 11 | [LOG] AsyncManager::init : done 12 | [LOG] PlaybackSystem::init : 13 | [LOG] Thread::initThread : Init FMOD Studio sample load thread. Priority: 0, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No. 14 | [LOG] PlaybackSystem::init : done 15 | [LOG] Thread::initThread : Init FMOD Studio bank load thread. Priority: 0, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No. 16 | [LOG] Manager::init : done. 17 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 18 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 19 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 20 | [LOG] PlaybackSystem::acquireMasterBus : Setting master channel group format to 6 21 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 22 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 23 | [LOG] Manager::readBank : fileversion = 125, compatVersion = 119 (oldest = 44, newest = 125) 24 | [LOG] Thread::callback : FMOD Studio bank load thread finished. 25 | [LOG] Thread::callback : FMOD Studio sample load thread finished. 26 | [LOG] LiveUpdate::release : 27 | [LOG] LiveUpdate::reset : Reset connection (reason Disconnected) 28 | [LOG] Thread::callback : FMOD stream thread finished. 29 | [LOG] Thread::callback : FMOD mixer thread finished. 30 | [LOG] SystemI::close : Closed. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # HDRPGrass 3 | Grass for Unity's HD render pipeline. This project was an experiment to learn more about hand-writing HDRP shaders and writing shaders with custom tesselation steps. There's also an additional attempt to create grass using compute shaders + DrawProceduralIndirect. This project was written for Unity version 2019.4.11f1 and given the volatile nature of hand-writing HDRP shaders I doubt it will work in newer versions! 4 | 5 | This project was initially part of a larger 3D platformer game but I decided to separate the grass out as a little showcase. The grass was originally meant to be based off [this tutorial here](https://roystan.net/articles/grass-shader.html), but quickly veered off course when I realized I couldn't just write HDRP shaders easily, and shadergraph doesn't support tessellation. So began a week of hair-pulling as I disentangled the HDRP lit shader! In the end I not only matched the tutorial but added a few other nice features. 6 | 7 | I should note however that my end conclusion is that were I to do this again, I would not under ANY circumstances attempt to do it with tessellation. It's an outmoded approach and was a real pain to get working, and honestly, it takes up a lot of VRAM. I'd like to attempt this again and just use instances meshes. 8 | 9 | ![hdrpGrass0](https://user-images.githubusercontent.com/18707147/121815886-81bd4380-cc70-11eb-98f6-b842c7ba6033.gif) 10 | 11 | This project is divided by the two approaches: named 'TessellationGeometry' and 'Compute.' TessellationGeometry being much more fleshed out. 12 | 13 | ## TesselationGeometry 14 | 15 | TessellationGeometry grass is rendered simply by applying a material with the shader 'Grass/Grass_TessellationGeometry' to a mesh. The mesh geometry will be transformed into a field of verdant grass! 16 | 17 | This shader has a full custom material inspector in the style of Unity's render pipeline shaders. Each of these fields are explained via tooltips but I'll go over some of the more obtuse ones here. 18 | 19 | ![hdrpGrass1](https://user-images.githubusercontent.com/18707147/121816574-58061b80-cc74-11eb-9537-0ed09c654be3.png) 20 | 21 | - **Grass Colours**: This dictates how individual blades of grass are coloured from top to bottom. You can both specify two colours as a sample gradient and provide a texture. 22 | - **Grass Field Texture**: multiply the grass colour across the whole field, sampling a texture using the original geometry's UVs. This is how I create the alternate green colours in the lawn grass in the gif above. 23 | - **Grass Map**: A greyscale texture which affects the size of grass blades, again sampled using the original object's UVs. **Grass height can also be affected via the r channel of the geometry's vertex colours.** 24 | - **Style**: You can decide whether you want your blades of grass to taper to a point or be quads. 25 | - **Billboarding**: The grass can be set to rotat around its local vertical axis to face the camera. 26 | - **Wind Distortion Map**: A red and green texture which pushes the grass around over time, simulating wind. 27 | - **Apply Displacement**: Whether this grass is pushed around by displacement spheres. 28 | - **Tessellation Type**: This controls how the original geometry's polygons are tessellated. Proportional tessellation will tessellate large polygons more in order to produce a more even density. Uniform will tessellate all polygons equally. 29 | - **Normal Type**: How the normals of the grass blade vertices are determined. The default setting is 'From Source' which reproduces the normal of the source geometry at that point. This looks the best by far. I also include a 'true' setting which gives each grass blade vertex a normal perpendicular to the grass blade, and a normal override setting. 30 | 31 | ### LODs 32 | 33 | ![hdrpGrass2](https://user-images.githubusercontent.com/18707147/121816886-1d9d7e00-cc76-11eb-87d8-112943c4db18.png) 34 | 35 | You can have up to three levels of detail for the TessellationGeometry grass, based on its distance from the camera. 36 | 37 | From left to right, you have highest to lowest level of detail. In the above example, LOD0 displays when the grass is <10 units away, LOD1 at <30, and LOD2 at <90. At greater than 90 units, the grass is culled. 38 | 39 | For each LOD you can control how many segments the grass blades are broken into (which only really matters visually if the grass blade has curvature) and how dense the field of grass is. LOD0's density is controlled by the default density slider. 40 | 41 | You can view the LODs explicitly as a debug view. (See below). 42 | 43 | ### Debug Views 44 | 45 | ![hdrpGrass3](https://user-images.githubusercontent.com/18707147/121817042-ef6c6e00-cc76-11eb-9903-e7b0e021b4ca.png) 46 | 47 | #### Wind 48 | 49 | Display the wind texture as the grass field colour. 50 | 51 | ![hdrpGrass4](https://user-images.githubusercontent.com/18707147/121817140-6efa3d00-cc77-11eb-99bf-870a4db3fd5c.gif) 52 | 53 | #### Displacement 54 | 55 | Double check that displacement by GrassDisplacementSpheres is working. 56 | 57 | ![hdrpGrass5](https://user-images.githubusercontent.com/18707147/121817178-a5d05300-cc77-11eb-80fb-9968146790fc.gif) 58 | 59 | #### LOD 60 | 61 | Colour each LOD by RGB. 62 | 63 | ![hdrpGrass6](https://user-images.githubusercontent.com/18707147/121817221-f182fc80-cc77-11eb-8e48-fef1f637f546.gif) 64 | 65 | ## Compute 66 | 67 | ![hdrpGrass6](https://user-images.githubusercontent.com/18707147/122127471-1f5c7280-ce2b-11eb-8d8a-d4ac9f34f322.png) 68 | 69 | The demo for the Compute version is comparitively much simpler. Instead of using tessellation, the compute grass takes some input geometry and generates a fixed number of random evenly distributed points on its surface. Grass geometry is then generated at these points and buffered, making this approach a lot faster than tessellation, at the cost of being more unwieldy (it's not just a drag-and-drop material anymore.) 70 | 71 | This grass is controlled with a ProceduralGrassRenderer component. This component is also capable of 'baking' the generated mesh and saving it as an asset. When combined with the correct material, the result is exactly like the procedural output... 72 | 73 | ![hdrpGrass7](https://user-images.githubusercontent.com/18707147/122127958-d953de80-ce2b-11eb-92a2-b6836f7c75ad.png) 74 | 75 | but now your asset can be used as a brush in terrain! (The prefab used here is included in the project - 'LODGrass'.) 76 | 77 | ![placing-compute-shader-hdrp-grass](https://user-images.githubusercontent.com/18707147/122127892-c5a87800-ce2b-11eb-82a9-03a2126d6f4c.gif) 78 | --------------------------------------------------------------------------------