# Get Started

## Asset dependency

Make sure you have these asset installed

* URP/HDRP
* Unity Shader Graph
* Unity Vfx Graph
* Gradient Texture Generator (my free asset)

## Set up

### 1.Layer & RenderTexture

<div><figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FZymJufsuVafDERMTujYG%2Fimage.png?alt=media&#x26;token=4dac0378-ce10-4d5f-a5e2-783e089af2ec" alt=""><figcaption></figcaption></figure> <figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2F5JdWUbgUPgpckCVG9tDY%2Fimage.png?alt=media&#x26;token=4319dd08-8695-4c8e-ac7b-940fb1c09bec" alt=""><figcaption></figcaption></figure></div>

Create 4 Render Texture and 3 layer

* Color Format of the Render Texture has to be \
  R16G16B16A16\_SFLOAT/R32G32B32A32\_SFLOAT
* 3 Layer for Ground, GrassKiller & GrassMotion

### 2.Camera

<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FilYQlDjHdZjNiFxrjnxe%2Fimage.png?alt=media&#x26;token=0cf4cf2a-e199-41ea-afb5-704bf956820c" alt=""><figcaption></figcaption></figure>

1. Create an empty gameobject and new camera as children

#### HDRP

Create 3 camera - projector(ground layer), killer & motion camera

1. Killer & motion camera have no special set up, just name it properly
2.

```
<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FGrv0RzMnfhfIDYec05Ie%2Fimage.png?alt=media&#x26;token=142bf533-4b01-447c-a610-a6be96ed62e7" alt=""><figcaption></figcaption></figure>
```

```
Attach a Custome Pass Volume to the Projector Camera, make it the target camera and use **NoramlBufferHDRP** as fullscreen material for a FullScreenscreenCustomPass
```

#### URP&#x20;

Create 4 camera - projector(ground layer), normal, killer & motion camera

1. Projector, killer & motion camera have no special set up, just name it properly
2.

```
<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FOWzamtA5URKy0ILccrDD%2Fimage.png?alt=media&#x26;token=32b14955-3733-4f16-a70c-cbc2627a9305" alt="" width="437"><figcaption></figcaption></figure>
```

```
Add a Full Screen Pass Renderer Feature to a new Universal Renderer Data with **NormalBufferURP** as Pass Material
```

3\.

```
<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2F6PjvhUs8sUaC3VAZp7tl%2Fimage.png?alt=media&#x26;token=6bf2a0a6-dc37-402f-a44d-e6474a652680" alt=""><figcaption></figcaption></figure>

Add the Universal Renderer Data you just created to your Universal Render Pipeline Asset's Renderer List
```

4\.

```
<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2Fp2g0H3De6RlHHZjTnNjo%2Fimage.png?alt=media&#x26;token=c397bafc-e72f-4f7c-8914-03405e32b963" alt="" width="439"><figcaption></figcaption></figure>

Set the Universal Renderer Data you just created as the Renderer on normal camera
```

#### After creating camera(HDRP/URP)

Attach a script - GrassManager.cs to the empty parent gameobject - the root of all camera

<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FJBzQxoKiSqKVEk1la2qU%2Fimage.png?alt=media&#x26;token=321b4cd4-954e-4bcd-8d09-c68146be6ad7" alt=""><figcaption></figcaption></figure>

1. Drag and drop the camera and render texture you just created&#x20;
2. Camera size = the area that spawn grass
3. Press Apply Settings

***

### 3.VFX

<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2FT29RNNcfVKa4fH3SzNhE%2Fimage.png?alt=media&#x26;token=e1f148c1-a2ef-4cb1-b2ea-19c77427f093" alt=""><figcaption></figcaption></figure>

1. Under the GrassManager, create an empty gameobject&#x20;
   1. Attach the vfx (GrassProjector\_Vfx) on it
   2. Attach VFXPropertyBinder.cs
      1. Bind 2 corresponding as shown above, either HDRP/URP
   3. Attach GrassSetting.cs, drag the corresponding Vfx
2. Go back to the GrassManager Attach the corresponding Vfx, hit Apply Settings. Now you are good to go, start playing around with GrassSetting to create the grass you want.

***

### 4.GrassKiller

Any object (no need collider) under "Grass Killer" layer will be capture by the grass killer camera's depth buffer

You could cover up the area you don't want grass with any object under "Grass Killer" layer to remove the grass over there.

***

### 5.Motion

<figure><img src="https://3374031394-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJZW2zR4mbZfSyHYuAIWI%2Fuploads%2Fm5leeFzItG3pwA3ThP6r%2Fimage.png?alt=media&#x26;token=dc2908c6-41ae-4a4c-857e-8e34bece7f84" alt=""><figcaption></figcaption></figure>

Attach this vfx under any interactive object and make it GrassMotion Layer, now it will push the grass away
