Problem with making my own grass and camera

Hi everyone,

I have some questions regarding on grass. I am doing a scene that doesn’t use terrain engine in Unity. That means I am having my terrain as a model. As a consequence, I cannot use ordinary grass coming with Unity’s terrain engine. So I have to use grass as a model also. There was no problem so far until I try to optimize my grass. This is what I did.

I use 2 camera. They have the same position and rotation.
Camera 1 :
Clear Flags : Skybox
Depth : 0
Culling Mask : everything except grass

Camera 2 :
Clear Flags : Depth only
Depth : 1
Culling Mask : only “grass” layer

The result was really good except that the grass is drawn on top of my main character and other objects. I think this is because Camera 2 is drawn after Camera 1.

Is there any way to make my grass behave like grass in the terrain engine like limiting how far the camera draw the grass?

Regards,

Bent

Yes there are ways to do that but I think you’re going about it in the wrong way. You’re right in that the way you have it set up everything rendered by your “grass” camera will be drawn on top of everything rendered by your other camera due to the way you have them layered.

Why not consider a particle system, with particles that are motionless yet always pointing at the camera for your grass? Or alternatively, a simple game object that takes your grass texture and that has a script to point at the camera, and when “too far” the plane’s mesh renderer is disabled? You could likely make a simple prefab out of that and thus get the desired effect.

Just some quick thoughts in case they help!

Thank you, HiggyB.
I’ll try your method.

Look for the old “Nature Demo” that pre-dated the terrain engine. It included a Unity package that included a grass script and shaders.