# Tag Info

## Hot answers tagged normals

Accepted

### Why are normal maps predominantly blue?

There are two types of normal maps commonly used in game development. The way you are thinking they should work is the way one type works (model-space normal maps), but most games use another type (...
• 2,308
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 ...
• 114k
Accepted

### What is the cause of this lighting artifact on my dynamic terrain mesh?

This isn't caused by your UVs or by your normals. The problem is triangle interpolation, and it's a very common problem for quad-based heightmaps. Here's a closeup of a small portion of your ...
• 21.2k

### Why are normal maps predominantly blue?

The normal map mostly points outward from a surface. Assuming you go with the usual mapping of the Z component of the XYZ normal vectors being the "depth" direction and an that mapping to the B ...
• 41.4k

### 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

### Calculated normals for mesh not working

vec3 norm = vec3(uViewMatrix * uModelMatrix * aNormal); The normal cannot be transformed like a point, to transform a normal you use the inverse transpose matrix. If you want the fun details of why ...
• 601
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

### Marching Cubes Vertex Normals

Essentially, the normal of the vertex would be the average of the adjacent faces' (triangles) normals. In pseudocode: ...
• 3,775
Accepted

### Normal matrix space has to be eye space?

It's common for people to compute lighting in eye space because of how the specular component of lighting in the Phong model is calculated. Doing the calculation in view space, allows you to avoid a ...
• 817
Accepted

### SSAO issue - surfaces darken based on camera angle

To me it looks very much like your issue here is that you are mixing world and viewspace or something similiar. Now your GBuffer normals look like they might be in viewspace in that picture, but the ...
• 1,765
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 ...
• 114k
Accepted

### Make a plane to display material from both sides

You need to edit your shader source file in order to add "Cull Off" inside, more info here If you are not writing your own shaders (and so use default provided Unity shaders) then you can look at ...
• 444
Accepted

### Malformed/Pixelated Vertex Normals

There is nothing inherently wrong with your original code when it comes to normalization. The only problem can be with meshes that do not properly share vertices, meaning your normalization code will ...
• 144
Accepted

### How many normals are needed to have a smooth surface?

The way you are computing vertex normals only considers an individual quad and not its neighbours. Thus you get the discontinuities between the somewhat flat quads. If you want smooth normals, the ...
• 4,074
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: ...
• 6,883
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 ...
• 114k
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.5k

### 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 ...
• 323
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 ...
• 114k
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, ...
• 18.5k

### GLSL Normals not transforming propertly

Andon is making the correct assumption I believe. Specifically, the n vector in the vertex shader should be assigned as ...
• 296
Accepted

### What is wrong with my specular phong shading

I have found the answer (and now I feel stupid) int DotOfNormalAndLight = Vec3Df::dotProduct(normal,relativeLightPos); should have been ...
• 965

### OpenGL: why do I have to set a normal with glNormal?

Minimal example that illustrates some details of how glNormal works with diffuse lightning. The comments of the display ...
Accepted

### Calculating the winding and normal when programatically adding triangles to a mesh

I don't completely understand the problem you're having, but this is a sketch of an extrusion algorithm Supposing polygon is an array of 3D points in counter-...
• 13.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 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,351
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,351