I was wondering is it possible to get grass and trees to fade through transparency when hitting the draw distance. Currently when trees and grass just pop onto or out of the screen when they are in entering or exiting the cameras draw distance. I want them to gently fade in and out when moving in and out of draw distance.
Half Life 2 and the source engine uses this exact kind of system and makes the drawing of objects at a distance more visually appealing. Is there any way to accomplish this or a similar effect? I know a simple script attached to objects can do this for me, however, I donât know how or if it can apply to terrain details. Any solutions or suggestions would be greatly appreciated!
there is no such method for terrain detail objects.
they are part of the terrain and handled through the appropriate shader which you would need to modify and override the built in one with by naming it equally
In order to do fade out, you would need a scripted system that deals with such details, and would have to NOT use the built in terrain grass/tree system.
From there, you have to decide which items are going to fade. Considering size of the objects are likly an issue, I advise reading up on Unity - Scripting API: Camera.layerCullDistances and learning how to have things disappear based on layers.
Now, I have not tested this, and have no idea what the actual stress this will cause is, but you have to script the objects to fade with distance, and the easiest way to do that is with a single control script based on tags: Unity - Scripting API: GameObject.FindGameObjectsWithTag
With that command, you can get all objects tagged as âfade-smallâ.
Another way is to make all the objects for fade a child of a mail object that cycles through the children under it with a script, and checks distance from the camera:
Create a global variable that grabs the detail distance from your terrain data
Write a shader that does this for you since there are multiple ways to do this and each project is different
This is not difficult to do on your own and you will get a more project oriented solution if you do it yourself. You probably donât want to be using alpha that way anyways and instead will want to use alpha clipping (unless targeting some mobile hardware) or even scaling the size.