Get the Vertex Normal in a Shader

Godot Version



I am currently writing an simple outline shader for learning purposes. I want to scale the objects vertices along its vertex normals. I used the normals input in the vertex function for that, but it seems as tho it is using the face normal.

I took a screenshot of the model.
Red arrows is the current behaviour, it seems to use face normals.
Yellow arrow is what I would want, vertex normals
Can someone help me with this problem?

1 Like

According to the docs (in the vertex built-in section:

Vertex data (VERTEX , NORMAL , TANGENT , BITANGENT ) are presented in local model space. If not written to, these values will not be modified and be passed through as they came.

Are you trying to access the vertex normal in the fragment function?

I am accessing the VERTEX Data inside the Vertex function.

Ah sorry I overread this in your initial post. Can you explain what type of effect you are going for / how it should look? Also a screenshot from a different perspective (the side perspective) and your current shader code would help.

Ok, I solved the issue.
Changing the shading of the model fixed the issue. I changed the shading to smooth shading so the vertex normal points in the right direction.
Flat Shading resulted in the vertex pointing in the direction of the face.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.