Page 1 of 1

Custom Vertex Normals

PostPosted: Wed Feb 20, 2019 4:09 pm
by JordyJS
Hey there. So I've got a model with custom vertex normals on it to stylize it in a certain way. For various reasons (related to animation), I can no longer use the vertex normals themselves to drive this in the shader (for the record, I use the World Normal node to access these normals for proper custom lighting).

Is there another way to customize these normals other than modifying the vertex normals themselves? Some way to change the vertex normals before they're used in the World Normal node's calculations. Something like a texture I can apply within the shader to calculate normals manually before they're interpreted by a normal map/lighting/etc.

For reference, here's the vertex normals when I edit them manually:
NormalsEdited.PNG
These are the vertex normals after I've edited them in my modeling program. I'd like to get this same behaviour into my shader, but through something like a texture.
NormalsEdited.PNG (151 KiB) Viewed 2417 times


And here's them by default, unedited (which I want to avoid):
NormalsDefault.PNG
These are the vertex normals by default, without me editing them. This is what I would like to avoid.
NormalsDefault.PNG (106.74 KiB) Viewed 2417 times

Re: Custom Vertex Normals

PostPosted: Fri Feb 22, 2019 4:19 pm
by Amplify_Borba
Hello!

I'm not sure if I fully understood this situation, but I believe that you could create a texture with the altered normals and pass it to a shader, then when reading that texture in the vertex function you'd have to transform its value in a range between [-1 1] and normalize it, unless there's some reason why you're unable to export those custom normals from the model.

There is a caveat when calculating the new normals inside the shader though, nodes such as the World Normal access the original version of the Normal, so if you need a version of the new normal in world space ( the one extracted from the texture ), you'll have to get its value and transform it into world space.

Please let me know if this helps.

Re: Custom Vertex Normals

PostPosted: Mon Mar 04, 2019 8:51 pm
by JordyJS
Hey Borba, thanks a lot for the advice! This definitely sounds like a viable method, but I'm wondering how I'd go about capturing vertex normal information as a texture? I could paint my own of course, but I don't even know what kind of colour values I should be dealing with.

Any additional advice you could offer would be greatly appreciated!

Re: Custom Vertex Normals

PostPosted: Fri Mar 08, 2019 5:34 pm
by Amplify_Borba
Apologies for not getting back to you earlier but I'd recommend asking around Unity's shader forums as I'm not entirely sure of what to suggest regarding the matter, seeing as it's outside of the scope of our support.