Terrain tree billboard strange edge if overlap water4 advanced

While I’m having a couple of problems I’m walking into while working with Unity. I found another strange thing I couldn’t find a solution for.
I’ve been googling and found someone having this same issue about 1 year ago with Unity 3.5. However, he wrote down that I should change a certain part in the billboard shader to let it work properly.
However, that didn’t work at all.

Here a screenshot to illustrate the problem I’m facing.

The problem is, that the tree billboard will have strange edges. They won’t show the water between the leaves, but instead ignore the water and render part of the terrain texture painted under the water.
Somehow the Water4 advanced asset in the standard asset has this problem in combination with the tree billboard shader. I don’t have knowledge about the watershader nor billboard shader to fix this.
It’s strange that default assets for Unity have this strange visible artifact. At least I would expect that it should work out of the box, even that it would have been fixed by now since Unity 3.5.

Final, I don’t have anything edited except turned off the planar reflection and Gerstner Displace. While both turned on, this problem is still there.

Does someone know how to fix this? It’s driving me crazy, how much I love Unity I can’t show this to my customer and tell I can’t fix this.

Its a simple matter of render order, the water must render before the trees for the alpha blend to work. So its possible to fix this by setting correct render queue in the water shader, tree shader and terrain shaders. Read more in the Unity documentation http://docs.unity3d.com/Documentation/Components/SL-SubshaderTags.html

Alternately you could use the much faster Alpha test instead of the current alpha blend. The difference is that alpha test renders all or nothing, so it doesn’t fade blend between tree and background. Alpha test is faster and doesn’t have this bug, but it does look a bit more rough.

You are not alone. We 've got the exact same issue. http://forum.unity3d.com/threads/59299-Replacing-Terrain-Shader?p=931585&viewfull=1

A fix would be awesome.

edit:
UnLogick was faster with his answer.
What shaders do we have to touch to get this fixed? There are quite a lot - each with their own fallback shaders and possibly relying on others shaders to do their work. Which ones render order should we change?

It is not a simple matter if people do not know, or are too scared to delve into the world of shaders (albeit just an edit). As this issue will affect a large number of people somewhere down the line, maybe it would be worth posting a step by step guide on how to actually do this. It would finally put these numerous threads to bed.

  • Matt.

Why isn’t this render queue applied by default on these assets / terrain system? Because I think the combination of these 3 together when creating terrains is about 80%. Who isn’t using trees, terrains and water together?

I doubt it’s good to have assets and systems that need a “fix”. Like creating something and you have to go trough a guide: “to use the assets, read trough these fixes” Shouldn’t it work right out of the box when it’s an asset delivered by Unity itself?
I would understand if it was both shaders I had created myself, then I can imagine I would ran into this problem. Altho I’m quite happy someone could reply on this topic, thanks for that :slight_smile:

Also I have really no clue on how to set these render queue inside the shaders.

Changed my render settings to Deferred Rendering, seamed to fix the issue as well setting Queue=Transparant-200 on the water. However when I did this on the water4example in Unity 4.x, this didn’t seam to work.
I had to reopen an old project from Unity 3.x where I got my water4example and chaged the Transparant to Transparant-200 inside the shader. Export package and import it into my Unity 4.x project. This seamed to fix the issue together with Deferred Rendering.

However, this is some bad ugly fix I had to find. It just doesn’t make sence that paying for something 1500,- bucks the standard assets needs to be messed around with to work properly. Some of my friends work with Unreal Engine, and I haven’t ever heard that they need to mess around with standard delivered assets to let them work properly, they seam to work straight out of the box in lots of situations.

Bit disappointed about this as other people in earlier reply’s write as well.
A few weeks ago I also had couple of another issues with terrains and patch size. Nobody seams to find a fix for that as well. As a perfectionist I’m never satisfied if I can do things better. In this cause I know I can do it better, but things are just limiting me.

This strange edge issue can be fixed as what I described above. However in Forward rendering, it seams I can’t remove the problem since I don’t know how to correctly edit the shaders.
Working on a huge project, this has been the 3rd big problem I encountered and had to fix it using an ugly work around. :confused:
I wonder if in a next Unity 4.x, this issue could be solved in the standard assets delivered with it.

Solved the problem

I did use an old water4example from another project. I don’t know if I fixed that back in the time and forgot to remember, or the shader has changed function in Unity 4.x, because this shader example is from Unity 3.5.x

Here is the package: http://bit.ly/Yn6kDl
Also not forget to set rendermode to Deffered

To Unity Developers

Can this be fixed in the standard Unity 3D assets?
Would like a reply on this topic about this.