-
Notifications
You must be signed in to change notification settings - Fork 653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My Y normals (for directional lighting) seems backwards? #75
Comments
The full working example can be seen here: https://trusktr.io (for now). |
@greggman oh oh!! Is it because the ordering of my vertices is clockwise (so the right hand rule would make the normal point downward)? Does the normal direction become opposite if we reverse the ordering of the vertices? |
Ah, yep, I forgot that in the |
No, the normal doesn't flip based on the clockwise or counterclockwise unless you are computing the normal. You're not computing the normal you're supplying it precomputed. As for your question you should ask this on Stack Overflow and if you want debugging help you should make a minimal example. Here's a simple cube The top face's normal is [0, 1, 0]. The bottom is [0, -1, 0] as you'd expect. |
When making directional lighting, I found that for normals of a face that faces upwards (which is in the positive Y direction right?) that my normal is
0, -1, 0
, which seems to be backwards? I thought it would be+1
on the Y axis, since positive is up. For example, here's the normals for each side of my cube, (the cube sides are perpendicular to the XYZ axes), and it seems that "top" and "bottoms" face normals are backwards:Here's the full code.
Here's how the cubes are created, the sides are just perpenducular/parallel to axes.
As you can see, the top face is created 5th, and the top-face normal is also fifth in the above normals array, then the normals are mapped to the vertices.
I thought that the top face, which faces upwards, would have vertex normals of
0,1,0
, and the bottom face would have vertex normals of0,-1,0
.Why might it be opposite?
The text was updated successfully, but these errors were encountered: