Custom Vertex Normals

Node-based Shader Editor

Custom Vertex Normals

Postby JordyJS » Wed Feb 20, 2019 4:09 pm

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 2483 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 2483 times
JordyJS
 
Posts: 4
Joined: Wed Sep 05, 2018 3:42 pm

Re: Custom Vertex Normals

Postby Amplify_Borba » Fri Feb 22, 2019 4:19 pm

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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Custom Vertex Normals

Postby JordyJS » Mon Mar 04, 2019 8:51 pm

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!
JordyJS
 
Posts: 4
Joined: Wed Sep 05, 2018 3:42 pm

Re: Custom Vertex Normals

Postby Amplify_Borba » Fri Mar 08, 2019 5:34 pm

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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 25 guests