Skip to main content
32 votes
Accepted

What is a vertex color?

Vertex colors aren't that relevant when you have a fully textured 3d mesh. But it gets interesting when you have an untextured but colored mesh. In that case you assign a color to every vertex. The ...
Philipp's user avatar
  • 120k
28 votes
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 (...
Hermetix's user avatar
  • 507
26 votes

What is a vertex color?

In theory, Vertex Color allows to color a model without having to bother with textures. This is quite common in CAD. In practice, it's just one more slot you can use to push data into the vertex, ...
Peter's user avatar
  • 9,935
17 votes
Accepted

3D models budget. What matters more number of triangles or vertices

Let's imagine a big grid mesh, like one we might use for terrain. We'll render n triangles worth of it, covering say half our 1080p screen, in a single draw call. ...
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
10 votes

What are normal, tangent and binormal vectors and how are they used?

I know this is old but i would like to add a little practical information. As stated by others but more specifically related to graphical programming. A Normal aka (a surface normal) is orthogonal to ...
WillMotil's user avatar
  • 101
9 votes

What is a vertex color?

Vertices can have colors, it's a property just like the normal of it. In 3d enviroments a triangle gets colored based on their vertices' color information. The closest fragments to vertex A get the ...
Bálint's user avatar
  • 14.9k
7 votes
Accepted

How does the following code generate a full screen quad?

it doesn't generate a quad, instead it generates a fullscreen triangle. The outputs end up as: ...
ratchet freak's user avatar
6 votes
Accepted

When does it make sense to use Index Buffers?

The example you use of a cube is a very specific, and somewhat contrived, one where indexing does not provide it's full benefit. For most real-world examples the constraints you mention do not exist, ...
Maximus Minimus'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

What is the purpose of tangent and bitangent vertex attributes?

Tangent and bitangent vectors are used for tangent space normal mapping / lighting and certain forms of displacement mapping. In a tangent space normal map, we store the per-pixel normal in the ...
DMGregory's user avatar
  • 135k
4 votes

Generating a UV map for a procedural mesh

If we take as the requirements: no distortion no constraints on seam placement OK to overlap faces then we can use a pretty simplistic approach, independently rotating each face into a 2D plane and ...
DMGregory's user avatar
  • 135k
4 votes

I want to cut a pizza slice out of a 2D circle using mouse input in Unity. What data structures and geometric formulas would be best for this?

In theory this isn't that complicated -- given a point a somewhere on the surface of the circle, project a ray from the center of the circle through that point of length r. The endpoint of that line ...
Acme Nerd Games's user avatar
3 votes

Easy way to edit vertex attributes

You could simply use multiple textures on the vertices, where each channel of each texture contains the value of some attribute. Then you can paint the attributes in any program that allows you to ...
user1118321's user avatar
  • 2,632
3 votes
Accepted

Easy way to edit vertex attributes

If you use weight painting instead of vertex colors, you could export the model in any format that supports skeletal animation.
Jimmy's user avatar
  • 9,029
3 votes

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 ...
EvilTak's user avatar
  • 932
3 votes
Accepted

What does 'vertex splitting' mean?

As described in the two answers I linked in the comments, each vertex we send to the GPU is one unique combination of {position, normal, texture coordinate 1, texture coordinate 2, tangent, vertex ...
DMGregory's user avatar
  • 135k
3 votes

What is the use of multiple vertex color sets

Vertex colours are just arbitrary extra data you can pack into a mesh - you don't have to use them as literal colours when rendering. So frequently, these get used as control weights for a variety of ...
DMGregory's user avatar
  • 135k
2 votes

Point welding on generated terrain

Shouldn't your adjacent function be like this: ...
Fredrik Lundvall's user avatar
2 votes
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: ...
Alex V-P's user avatar
2 votes

Loading non-skeletal animation to opengl via assimp

It is actually easier than you think. The way this works is really simple, it is a lot like video. So, when you watch a video(I am sure you know this already but just as a reminder) you are not ...
J22o's user avatar
  • 482
2 votes

3D models budget. What matters more number of triangles or vertices

Neither. Unless you're talking truly massive numbers of tris (millions), what you care about is: Number of rendered pixels Cost of fragment shader Number of draw calls (with the limit strongly ...
Peter's user avatar
  • 9,935
2 votes
Accepted

Matrix transformations vs manipulating vertex data directly

It's usually faster to use matrices and keep the vertices the same for multiple reasons: The GPU makes optimizations based on the fact, that the vertices don't change. There are ways to make OpenGL ...
Bálint's user avatar
  • 14.9k
2 votes

OpenGL NDC initial values

In whatever coordinate system you want. It doesn't matter for OpenGL, it only needs to receive them in NDC at the end. For example, if you want an ortographic projection, where 1 unit equals 1 pixel ...
Bálint's user avatar
  • 14.9k
2 votes

Why is the depth test not done on geometry before rasterization?

You can determine if a triangle is behind another triangle. However, that's not the operation you would need to do if you wanted to do culling at the triangle level. You would have to determine if ...
Cort Ammon's user avatar
  • 1,237
2 votes
Accepted

How can I sort vertices efficiently in a specific direction (CW/CCW)?

Iterate over the vertices and store a running average of their positions to compute an estimated centroid position. Take your cutting plane and use it to form a ...
DMGregory's user avatar
  • 135k

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