I’m attempting to create a vegetation (grass and tree) shader combined with custom toon lighting that we’ve seen in many examples. The problem I’m running into is that both work fine on their own but doing vertex displacement on a custom lit object creates serious lighting artifacts. Has anyone been able to successfully combine the two?
I’ve been able to determine (with the help of advice from some outside sources) that this issue is the result of the lighting information being passed in based on how the light(s) affect the non deformed mesh. Given this, has anyone determined a method for either computing the lighting based on the deformed mesh or having normal recalculation within the shader?
Hope this helps!
I’ll give this a shot. Thanks! Any tips on how to use it? I’m getting errors when I import the package to my project.
What version are you on? The errors might be from version issues since the graphs were designed on HDRP 7.1.2 @ 2019.3.0b5.
I can downgrade the package.
I’m using LWRP in 2019.2.13. Thanks!
2019.2.0.f1 - LWRP
5234402–522221–Normal & UV Toolkit - LWRP.unitypackage (569 KB)
Thanks so much!
I’m a little confused on how this would work with the issue that I’m running into. I brought this into my project without any issues (thanks again for the new version) and applied it within the shader that I’m doing custom lighting and vertex displacement on but it seems that the normals are still creating issues. Any pointers on what I could be doing wrong?
With these settings (default spot texture) on my example
,
can you see results as below?
I think the normals do work in my graph; they are just not super accurate.
If you can see the above from my example, then the issue might be on your end.
(my shadergraph is based on My take on shaders: Water Shader – Harry Alisavakis - he talks about normal recalculation there)
talks about using more reads to fix accuracy. I will try to make a variant with 8 reads to see if that helps.
So 8 reads helps, but [quote=“”]
[/quote]
seems to have a fade to black bug as well (top-down is great, but fades to black upon viewing nearly tangent to the plane.)
All of this works fine for me. I can get displacement using textures. My initial concern was how to displace vertices and recalculate normals for something that is using custom lighting (for a toon shader). I’m still not seeing how this helps with that issue. Sorry.
I am assuming this is your workflow?:
Displace vertices, then calculate normals for the displacement, then use shadergraph’s normal blend node to add any extra normal detail. Then for a toon shader, simply replace all references to the mesh normal with the normal calculated from displacement.
My graph is designed to recaculate normals from displacement. I apologize if that did not help.
If you can post a picture of your issue or give me some more details, then I can take a look.
Apologies if I haven’t helped.
Please don’t apologize. I appreciate your help. Perhaps some images will illustrate the issue I’m facing. First is a tree without displacement and a toon shader applied. Next is the same with vertex displacement. You can see how the normals aren’t being adjusted. 

Is this in the same category like the issue i have?
It is.
Maybe this is not correct but through search of similar use cases i got the impression that the normals (and maybe even tangents) need to be adjusted for correct light calculation. (e.g. Materials: Rotating meshes using Vertex Shaders - Tom Looman)
This makes sense to me and i have the feeling that i know how i would do that in a plain vertex/fragment-shader. I tried transforming normal vectors to object space, rotating, normalising and connecting it to the masters normal input but this does not work for me.
But i have the feeling i don’t understand normals in shader graph in general because for example connecting a tangent-based normal vector node to the masters normal input gives wrong results comparing to just leaving the normal input empty (it says ‘tangent’ in this case)
So I tried this and it seems to help; the tangents will need to be recalculated as well.
But using my normal recalculation or the DDX/DDY-cross product method does not remove the shadow artifacts.
I believe it comes down to an order of execution issue. The shadow/light information is set prior to the displacement. I’m not sure how to overcome that.
This is definitely a bug.
in LWRP:-


in HDRP(with Lit master):

in HDRP with PBR:

Unfortunately, I don’t know either.

