Hello,
I've been trying to make a grass shader using my own assets, in unity. I've been able to make the asset and shader work perfectly in unreal. But inside Unity for some reason some of the grass cards are totally black. I tried removing everything from the shader, and set a simple albedo, and it's still black. I don't think the issue comes from the shader; But why is it happening?
Thank you for reading
Replies
Its happening because a plane has vertex normals only for one of its side. And lighting uses the vertex normals to calculate the shading. Since the normal of those planes are facing the opposite direction relative to the light direction, they get dark.
But I am not sure it's the issue cause I did check earlier, and some planes are green on both sides, and the other are black on both sides, there isn't one that's black on one side and green on the other
vec3(0,0,1) * normalize(dot(camera vector, vertex normal));
This is what the 2 sided sign node does except the vec3. I just multiplied tangent space flat normal there. Plug this into the normal input of the shader. This will make both front and back faces to be shaded the same and should remove the blackness.
It gives this interesting results, now the black cards seems to be dynamic based on where I look from
Last idea:
There is some space mismatch between the nodes. The normal input of the material should be tangent space, and the camera vector and normal vector should be world space.
Also, next time please post in the dedicated Unity subforum here. There is one for that, and your displacement thread was moved there by admins. Save them some time, post Unity things there.
Also if you think I couldn't replicate your displacement but couldn't see anything wrong in any of my screenshot, posted with all the details of everything I did. Don't go and blame me for my incapacity of reproducing it
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Camera-Node.html
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/View-Direction-Node.html
If this still doesn't work, I'm not sure whats going on.
And I have no idea how to make your last suggestion work as the camera vector has no world space so I just tried all different camera output dot producted with world space normal vector. And nothing change
I thank you a lot again for trying to help me. I'm almost sure there's a basic setting somewhere that's obvious to a veteran and that would fix most problem but I have no idea
The one weird thing with this set-up, is that If I look at it on a specific side, everything looks normal, but on the backside everything is broken
OH WAIT NEVERMIND NOW IT WORKS, the dark side is the shadows now, not some weird normal bug, MANY THANKS DUDE
(also I did try to find this view direction node, but as I had no idea what to google for, I didn't find it, thank you for finding it )