# Tag Info

Accepted

### What is a "normal" in game development

Direct Answer I see that other answer going into technical details, but I don't know if that hits the spot for answering "What are even normals" - so here's a plain English answer for ...
• 1,476

### What is a "normal" in game development

In the context of geometry, a normal is a vector that is oriented perpendicular to a given object. It is commonly used for lighting calculations, but it can also be used to for calculating visibility, ...
• 12.4k
Accepted

### How do game engines avoid recalculating normals upon mesh rotation?

They don't. When you rotate a mesh, the normals in memory are not changed in any way. All that changes is the object's transformation matrix is updated. The raw mesh vertex and normal data remains ...
• 135k
Accepted

### How can I get the normal vector for a plane from a set of vertices?

You could easily find the normal by calculating two vectors, V1 = P2-P1, and V2 = P3-P1, and then find the cross product N = V1 x V2. Then you normalize N. Depending on the ordering of the vertices (...
• 507

### What are some good examples of the practical usages of cross product in game development?

Generating Normals As Maximus Minimus notes in the comments, when we have a mesh without normal vectors (say just raw vertex positions from a procedural generator or 3D scanned point cloud), we can ...
• 135k

### How do game engines avoid recalculating normals upon mesh rotation?

DMGregory's answer explains how this is actually handled, but I'd like to point out a couple of misconceptions: Assume that a face of a mesh is defined by vertices ...
• 5,498

### Confused About My Code Suggesting The Normal Matrix Is Equivalent To The ModelView Matrix

When a matrix is orthogonal, inverse and transpose are equivalent making an inverse transpose equal to the original matrix. So if your model view matrix is orthogonal, the normal matrix will be equal ...
Accepted

### How does one calculate the surface normal, in 2D collisions?

I think the following may help. You have the sphere center, box center and hopefully the details of the rectangle. Since the rectangle may be rotated we need the rectangle extents, and the ...
• 428
Accepted

### Consistent normals at any angle in bezier curve

I'm not sure why you say the suggestion in the comments "gets worse" - I implemented it and it performs as expected: In each of these examples we have the same cubic spline being wrapped in a tube ...
• 135k
Accepted

### Normal Matrix in plain English

You need to use a different matrix to transform your normal vectors when your model's transformation might include non-uniform scale. When we stretch a shape along, say, just the y axis, the y ...
• 135k
Accepted

### How to calculate verticle normals of triangular mesh

It looks like some normals are pointing the wrong way. This means that those triangles aren't wound correctly. As a quick fix you can do: ...
• 7,381

### Algorithms for calculating vertex normals in 2D polygon

First, obtain the normals for each edge of the polygon. The normal for an edge is given by the normalized cross product of the edge vector (p2 - p1) with the 2D ...
• 932
Accepted

### How to know if two surface are in the same direction?

Imagine applying a force along those normals to the faces. If the normals both face in the same direction (e.g. outward), then it would have a book closing effect, the faces would get closer. If they ...
• 14.9k

### What are some good examples of the practical usages of cross product in game development?

Many.. many things: calculating normals for light/physics calculation using for calc distances (point/plane) checking orientation of (2D)-Polys (are they left or right wound?) calculating 2D-area of ...
• 338
Accepted

### Why is this back-facing texture showing through?

When you set a material to be transparent, by default this also disables it from writing to the depth buffer. This is important for avoiding ugly cut-out effects, where a transparent or faintly ...
• 135k
Accepted

### Convert a dot product scalar for a triangle's slope, into a translation ratio?

I don't understand your setup. However, 0.707106 looks familiar to me. It is approximately this: $$\frac{1}{\sqrt{2}}$$ And you say that is a 45º slope, right? So, ...
• 27.2k
Accepted

### How do I make my indices anti-clockwise, so I can cull triangles in OpenGL? (immediate mode)

Solved by reversing the indices for the problematic bottom face. Indices are now: ...
• 51
Accepted

### How to achieve good looking surface net normals?

A common way of generating vertex normals for a mesh is to sum the normals of the faces that touch each vertex, then normalize those sums. You're part-way there with taking cross-products from the ...
• 1,381
Accepted

### How do I calculate normals correctly for dynamic terrain (DX11, C++)?

I see several bugs, if I understand the structure of your mesh correctly. I think it's a grid of triangles, arranged so pairs of triangles form squares. First, when calculating ...
• 1,381

### Using indices in obj files and handling normals

First convert the obj mesh to a non-indexed mesh with vertex+normal+other attributes. Then convert back to indexed by merging identical vertex entries. The 2nd step can be made generic to be re-used ...

### Getting scene normals in Unity

you can use Replacement Shader to Displaying Mesh Normals First attach this script to camera: ...
• 8,343
Accepted

### Why does Unity ignore normals when calculating backfaces?

This is not a decision by Unity, but a standard part of the GPU rendering pipeline. (See eg. OpenGL) The primitive assembly step can be configured to discard faces based on their winding order on the ...
• 135k
Accepted

### Algorithms for calculating vertex normals in 2D polygon

If I understand the question correctly we have the following: Given a list of numbers (I'm going to presume we're working with doubles or decimals) we need to transform this into a sequence of 2D ...
Accepted

### Calculating surface normal numerically

You should use the Sobel opererator, which is a type of convolution filter. A 3x3 pixel convolution would work fine, but you need to do it twice: once for horizontal edges, then once for vertical ...
• 3,719
Accepted

### Unity - Blender models/animations showing gaps

You shouldn't put two faces with inverted normals instead, you have to use a Double Sided Shader in unity to show the backfaces too. if it's a custom shader, you can write ...
Accepted

### How to check if two normals/directions "look at" each other?

Given points P0 and P1 with normals N1 and N2... ...
• 3,719
Accepted

### Explain how Inigo Quilez calculates SDF box normals

We are looking at the function boxIntersection. I'll reiterate the information from the comment: // axis aligned box centered at the origin, with size boxSize We ...
• 27.2k
Accepted

### How To Convert World Space Normal To Tangent Space?

Your coordinate conversions are incorrect. The tangent and normal attributes that three.js provide to you are in object space. ...
• 135k
1 vote
Accepted

### Converting between world coordinate systems

Every time you interchange two axes, or negate an axis, you mirror space. So to go from xzy to zy-x we perform: Interchange <...
• 135k
1 vote

### Converting between world coordinate systems

Your mesh should not be in world space. It should be in "object space". It can then be scaled/translated/rotated into world space by homogeneous transform matrices on the GPU. This includes changes ...
• 2,649

Only top scored, non community-wiki answers of a minimum length are eligible