Skip to main content
Share Your Experience: Take the 2024 Developer Survey
28 votes
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 ...
DMGregory's user avatar
  • 135k
17 votes

How can I fix zig-zagging UV mapping artifacts on a generated mesh that tapers?

Typical UV mapping is what's called an affine transformation. That means the mapping of each triangle between 3D space and texture space can include rotation, translation, scaling/squash, and skew (ie....
DMGregory's user avatar
  • 135k
16 votes
Accepted

How to randomly generate biome with perlin noise?

There are three main steps here: Use some method to assign biomes to regions (this is the hard part, with multiple strategies I'll break down shortly) For each point in your mesh or tile/node in ...
DMGregory's user avatar
  • 135k
16 votes

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 ...
Kevin Reid's user avatar
  • 5,498
7 votes
Accepted

How can I generate the smallest enclosing sphere from a mesh?

Solving the bounding sphere problem Computing the bounding sphere for a set of given vertices means solving the minimum covering circle problem in three dimensions. There're many algorithms out there ...
liggiorgio's user avatar
  • 4,831
7 votes
Accepted

Unity block chunk generation pattern

Remember, the whole point of using a chunk mesh is to try to render just the outside skin, and hide all the internal detail inside the chunk where we can't see it. If we generate a whole cube (all 12 ...
DMGregory's user avatar
  • 135k
6 votes
Accepted

What are these odd distortions on far away textures?

This distortion pattern is an aliasing artifact caused by point sampling the wrong mip level of a texture. Change the "Filter Mode" from "Point" to bilinear, and make sure to check "Generate Mip Maps"....
ThisIsTheDave's user avatar
5 votes
Accepted

How can I convert my list of vertices and indices to a list of triangles?

Typically, your list of indices looks like this: ...
DMGregory's user avatar
  • 135k
5 votes
Accepted

Unity: How do I only show parts of objects that overlap [2D]

First, create a simple mesh (such as a quad or a cube). Place it over top the actual game area, and stretch it so that it covers the entire camera view. Next, create a new shader named "...
Coffee Boat's user avatar
5 votes

How does 3D mesh morphing work?

In the Sims 4, you can drag to reshape the face when you create a sim. How is the geometry morphing implemented? Only guys with access to the code can tell you that. In general, how do you code a ...
wychmaster's user avatar
5 votes
Accepted

How does LOD (Level of Detail) work in Unity?

Unity doesn't generate FBX files. The Unity Editor lets you import FBX files, which Unity converts into its own propriety file formats when you build your game. Each LOD is a separate mesh and will ...
Kevin's user avatar
  • 6,150
4 votes
Accepted

Unity - Small holes of light seems to go through my blender mesh

I believe that might be related to "shadow acne." Try lowering the bias of your directional lights. http://answers.unity3d.com/questions/925812/unity-5-real-time-lights-cast-shadows-with-gaps-li.html
Tashus's user avatar
  • 421
4 votes
Accepted

Why create meshes instead of using Planes?

First of all if you are interested in generating meshes I recommend to you this series of articles in gamasutra about procedural meshes Modelling by numbers So returning to the main question, ...
Santiago murillo's user avatar
4 votes
Accepted

Unity - An unwanted Collider , far too big , being added to meshes without reason and I cannot remove it

Well that collider might not even belong to the game object you are currently selecting, try to go through each game object that is a child object and you'd probably find it. And when you do you can ...
YeetlordTheFirst's user avatar
4 votes

How does 3D mesh morphing work?

We do not know the details of how they did it… However, there is a modding community for The Sims and they manage. The idea is as follows: There is one base model for body type. There are series of ...
Theraot's user avatar
  • 27k
4 votes

How do you have the clothing mesh hide the body mesh underneath?

This is a pretty common problem many people run into and the solution depends largely on what you are trying to do in your game. If your character is unable to change clothes in game, or has a very ...
Benjamin Danger Johnson's user avatar
3 votes

How to achieve this sprite/mesh tile splitting like in Peggle?

This can be done in general using a shape where you can get the normals at any point. It's particularly easy if the shape is a circle or an ellipse, because we can just use the parametric equation for ...
Jay's user avatar
  • 810
3 votes
Accepted

How can we achieve Earthquake Simulation in Unity - Simulation of P and S Waves

In order to do this you will have to write some code to modify the mesh programmatically. This is how you read the vertices of a mesh from a C# script: ...
Philipp's user avatar
  • 120k
3 votes
Accepted

How to cut a desired shape out of a mesh?

I have done this for automated medical CAD procedures as well as game engines, and will attempt to provide adequate information in order for you to accomplish this task on your own, but I will not be ...
Jon's user avatar
  • 534
3 votes
Accepted

How to make many perlin noise function match

Do not assign a biome per chunk. Instead, compute your biome as a function of position. There are a few popular ways to do this... Compute the low-frequency levels of your height map first (the ...
DMGregory's user avatar
  • 135k
3 votes
Accepted

Unity mesh shader for outlining colour changes

What you're finding here is that drawing the line based on your height above/below the boundary gives inconsistent results: in places where the height changes quickly (steep slopes), the outline ends ...
DMGregory's user avatar
  • 135k
3 votes

How to create a mesh in code?

The documentation actually has an article for this which I found while writing the question. Basically, vertices and indices are stored in MeshDraw instances, which ...
Ray's user avatar
  • 623
3 votes

How to create a mesh in code?

I posted example #5 in the mesh-from-code docs that you found. Since then, my LoadObjTest example has expanded to load WavefrontOBJ files at runtime. It handles the wavefront parsing (with C# code), ...
David Jeske's user avatar
3 votes
Accepted

How to create a mesh in code?

You can also make your own procedural model by inheriting from PrimitiveProceduralModelBase. This has several advantages: Write less code Available in Game Studio ...
thalm's user avatar
  • 227
3 votes
Accepted

How mesh transformation works under the hood

You correctly describe how transformations work, you're just making a wrong assumption that the process seems slow. Graphics processing units are tailor-made to do this specific thing, i.e. linear ...
PentaKon's user avatar
  • 348
3 votes

How mesh transformation works under the hood

There's an additional detail I want to clarify here: As far as I understand (at least I would do this), we store the original mesh, and then for every change (shift, rotation or scaling) we turn the ...
DMGregory's user avatar
  • 135k
2 votes

Bullet holes on curved surfaces and corners

I think unity can use stencil buffer though I never used it, if you are not able to do that I'll investigate deeper, One way to achieve that is to cut-out pieces of walls using some lowpoly spheres ...
CoffeDeveloper's user avatar
2 votes

How to rotate a triangle to look at a point?

Given points A, B and C of a triangle, the normal of the triangle is the cross product AB×AC (or possibly AC×AB depending on the vertex order). If the point on the triangle is M and the point towards ...
sam hocevar's user avatar
  • 23.9k
2 votes
Accepted

Checking if point is inside the mesh via raycasting - where to cast rays?

A lot of calculations can be simplified by turning this into a 2D problem, and you can do that by casting your ray along a single axis -- x, y, or z. For a given V = { Vx, Vy, Vz }, if we cast our ...
Jibb Smart's user avatar
  • 2,460

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