Jump to content

Recommended Posts

Posted

With three vertices, in counter-clockwise order, the unit-length normal for the face should be:

            double Ax = Vertices [ 2 ] . X - Vertices [ 1 ] . X ;

            double Ay = Vertices [ 2 ] . Y - Vertices [ 1 ] . Y ;

            double Az = Vertices [ 2 ] . Z - Vertices [ 1 ] . Z ;

 

            double Bx = Vertices [ 2 ] . X - Vertices [ 0 ] . X ;

            double By = Vertices [ 2 ] . Y - Vertices [ 0 ] . Y ;

            double Bz = Vertices [ 2 ] . Z - Vertices [ 0 ] . Z ;

 

            double Nx = Ay * Bz - Az * By ;

            double Ny = Az * Bx - Ax * Bz ;

            double Nz = Ax * By - Ay * Bx ;

 

            double N = Nx + Ny + Nz ;

 

            I = Nx / N ;

            J = Ny / N ;

            K = Nz / N ;

Someone please check my math and make sure that's right, because my brain has now melted and I'm getting dinner.

Posted

Just wondering, does that have anything to do with modding? Because I'm presently learning to mod, but this looks like... Nothing I've ever heard or read. If it does have to do with modding, could you tell what it is? So I know what to search for when I want to learn it. And if it doesn't, well... Tell anyway, I'm curious.

Posted

It's lighting for 3D: The normal points perpendicularly to the triangle being rendered (for example, if you drew a triangle on the sidewalk, the normal would be either straight into the ground or straight into the air, depending on which side of the triangle you consider "the front"), and this is used along with the positions of light sources to calculate brightness for faces.

Lighting becomes smoother if you use normals at every vertex (or even every fragment/pixel), but that's even more work, and for shapes with low triangle-count (like Minecraft blocks), vertex normals end up losing a lot of the sharp transitions making it harder to tell the edges of the blocks. (Vertex/fragment normals are better for smooth surfaces or something with a lot of triangles like the mesh of a human face).

Posted

It's lighting for 3D: The normal points perpendicularly to the triangle being rendered (for example, if you drew a triangle on the sidewalk, the normal would be either straight into the ground or straight into the air, depending on which side of the triangle you consider "the front"), and this is used along with the positions of light sources to calculate brightness for faces.

Lighting becomes smoother if you use normals at every vertex (or even every fragment/pixel), but that's even more work, and for shapes with low triangle-count (like Minecraft blocks), vertex normals end up losing a lot of the sharp transitions making it harder to tell the edges of the blocks. (Vertex/fragment normals are better for smooth surfaces or something with a lot of triangles like the mesh of a human face).

Alright, thanks for the heads up, I can nearly see sense in the code now. But I guess it's pretty obvious by now I can't really be of any help, good luck.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...