Grass plates rendering issue (URP)

Hello everyone!

I am not entirely new to unity but only recently could find the courage to dive into shader programming. Besides learning how to actually code shaders from all the awesome recourses, I am tinkering around a bit with the Shader Graph tool and recently tried to implement a basic grass shader. The graph is based on this tutorial

Note: Contrary to the tutorial, I am working in URP.

I created the planes for one grass patch as well as the cluster in Blender and handpainted some texture with alpha for the blades.
Now I am observing this phenomenon:
6961130--819881--screen1.png
That central plane of grass is just rendered in front of the other ones. Also the different planes are kind of rendered one after another, instead of intercepting. Viewed from above it looks like this:
6961130--819887--screen2.png

So my guess is that there is some issue with the render order ? My understanding of shaders is probably not good enough, but my guess was that it may have to do with the depth buffer. So i looked into the code generated by the shader graph and found that the ZWrite is turned Off. Could that be the issue ?
Unfortunately afaik, Shader Graph does not offer to enable the ZWrite. On the other hand I read in the Unity documentation (Unity - Manual: ShaderLab: commands) that for semitransparent stuff the ZWrite should be turned off. So I am not sure why that weird overlay happens.

Tl;dr/ Summary
What is the reason for the render order issue of the individual grass planes in the first image?
(the cluster is one mesh)

Thank you for any help !
Cheers
Lucas

Efficient and correct sorting of real time transparency is an unsolved problem.

Most of the possible work arounds for this aren’t possible when using URP, especially when using Shader Graph. And even if you could use them, almost none of them solve the case of intersecting triangles of mostly visibly opaque alpha blended objects. The only option is to use alpha testing. Set the master node to opaque and assign a Vector 1 node or property to the Alpha Clip Threshold.

2 Likes

Hey thanks a lot for that insight!

So if you were to not use shader graph, what kind of shader would you even use for stuff like grass?
There are a lot of recourses tackling unlit shaders but that seems to be unintuitive for grass. How would I learn about Lit or SimpleLit shaders in URP ?
I had a look at the Github Code from Unity’s official repo and its very convoluted. Besides, after just copy and pasting the SimpleLit code (with changing the name) I get errors already.
Or is the way to go to just start from an Unlit shader and add the lighting from there ?

Sorry for my unsorted questions, I am currently still in the “overwhelmed” state.

An alpha test shader.

Really, it is literally the only viable solution for intersecting visibly opaque geometry. I guess I could add alpha to coverage, but that basically just fancier MSAA alpha testing.

That’s as good as it gets right now.

Sure! … by basically copying all of the code in the SimpleLit shader and .hlsl files into it.

So, really no.

1 Like

Okay, well thanks a lot @bgolus ! That gave me some direction. I guess I will do some digging then (: