Hello there! I have a question regarding recalculating vertex normals after offsetting vertices. I'm using a heightmap to displace vertices around level geo, but I'd like to then inflate the verts a bit in the direction perpendicular to their tangents after the initial displacement. There is an example in the Amplify asset of recalculating vertices for a waving flag that I've used as a starting point, but when I try to displace the verts along their new normals they don't move in the correct direction.
My current shader calculates a new vertex position using a heightmap which is then added to new normals which are being multiplied by an inflation amount => (newVertexPosition + (newNormals * inflationAmount)).
Here is my system for the initial vertex displacement:
Here's a screenshot of the initial vert displacement (the red plane mesh has the shader applied and is conforming to level geo):
Here's a screenshot of the inflated verts being translated along their new normals after the initial displacement using the method in the included flag example:
One solution I tried was to use the "newVertexPosition" variable to calculate the Delta-X and Delta-Y rather than the Vertex Position node, but this only scaled them vertically along the y-axis when trying to inflate.
Any help would be greatly appreciated!
Vertex Normal Recalculation Issues
-
andrewtaylorjohnson
- Posts: 6
- Joined: Wed Mar 06, 2019 5:02 pm
Vertex Normal Recalculation Issues
Last edited by andrewtaylorjohnson on Thu Mar 07, 2019 12:45 am, edited 1 time in total.
-
andrewtaylorjohnson
- Posts: 6
- Joined: Wed Mar 06, 2019 5:02 pm
Re: Vertex Normal Recalculation Issues
Here is where I got to by the end of my day today. I've essentially copied everything over from the "VertexNormalReconstruction" example and ported it over to my shader. The only significant difference that I can see it the function I'm using to actually displace the verts, but for some reason my normals keep coming up with zero magnitude as far as I can tell and just completely breaks the shader (division by zero error when it passes through the normalize node).
Here are some images showing my network:
I'm at a real loss on this one
Here are some images showing my network:
I'm at a real loss on this one
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: Vertex Normal Recalculation Issues
Hello and apologies for the delay in our reply! Could you share a simple sample of what you achieved so far and with the error present so that we can look into it?
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
andrewtaylorjohnson
- Posts: 6
- Joined: Wed Mar 06, 2019 5:02 pm
Re: Vertex Normal Recalculation Issues
Hey Borba! Thanks for the reply. Here's the shader and it's main displacement function, as well as a test heightmap to plug into a material if you make one from the shader: I was unable to upload a test Unity project for you to use, so if you make a material out of the shader, plug-in the heightmap I sent into its corresponding field, set the 'SampleWidth' to 51, the 'MaxHeight' to 15, and give it a color that's not totally transparent.Amplify_Borba wrote:Hello and apologies for the delay in our reply! Could you share a simple sample of what you achieved so far and with the error present so that we can look into it?
Here's an image of what the shader does if I bypass adding the recalculated normals to the new vertex position: You can see where I've highlighted in red is the problem I'm trying to solve (along with one other that will use recalculated normals). The mesh conforms to the geo well, but it cuts through the edges of the cube, so I'd like to recalculate the normals and push the vertices out a bit in the direction of those new normals.
Here's an image of the error in engine: Let me know if you wanted anything else I failed to provide
Thanks again! Any help would be very much appreciated!
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: Vertex Normal Recalculation Issues
Hey there, I've been unable to get your shader to work as per your screenshots even with the supplied instructions, could you please share a simple project with the scene set up as shown in your last screenshot?
Apologies for insisting but our time is very limited and its always preferable to use the exact same data as the user when debugging potential issues, thank you for understanding.
Apologies for insisting but our time is very limited and its always preferable to use the exact same data as the user when debugging potential issues, thank you for understanding.
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
andrewtaylorjohnson
- Posts: 6
- Joined: Wed Mar 06, 2019 5:02 pm
Re: Vertex Normal Recalculation Issues
Hey Borba! Thanks for getting back. Same as before, I'm unable to upload the project files for some reason. Is there an email I can send them too instead?
Thanks!
EDIT:
I just PM'd you with a link to the project .zip on my drive.
Thanks!
EDIT:
I just PM'd you with a link to the project .zip on my drive.
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: Vertex Normal Recalculation Issues
Hey! Apologies but I haven't received anything through PM, could you please send it through [email protected]?
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: Vertex Normal Recalculation Issues
Our developer tested the sample and confirmed that this is not an ASE issue.
It is a bit hard to read but one factor that is contributing to these visual artifacts seems to be the shadow's own geometry.

Since the texture fetches for the vertex offset are being made on the vertex shader, for example in a border situation there are vertices that are in an area where the texture has registered a big offset but the vertices that are next to it don't.
What happens is that between the vertex and fragment stages ( rasterizer ) values are interpolated to fill the in-betweens and vertices will be connected. Since they are a bit far apart and have big offset differences, the connected geometry intersects the one below.
Please let us know if you have further questions, we'll be happy to assist!
It is a bit hard to read but one factor that is contributing to these visual artifacts seems to be the shadow's own geometry.

Since the texture fetches for the vertex offset are being made on the vertex shader, for example in a border situation there are vertices that are in an area where the texture has registered a big offset but the vertices that are next to it don't.
What happens is that between the vertex and fragment stages ( rasterizer ) values are interpolated to fill the in-betweens and vertices will be connected. Since they are a bit far apart and have big offset differences, the connected geometry intersects the one below.
Please let us know if you have further questions, we'll be happy to assist!
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!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
andrewtaylorjohnson
- Posts: 6
- Joined: Wed Mar 06, 2019 5:02 pm
Re: Vertex Normal Recalculation Issues
Thanks for checking it out! I must have asked this question in the wrong place though. I never thought this was an Amplify issue; I was just looking for some help to get my vertex normal recalculation working in this shader.
Sorry for the confusion! I'll go ask on the Unity forums instead.
Sorry for the confusion! I'll go ask on the Unity forums instead.