What is vertex color

  In the rendering of 3D models, in addition to texture attributes, vertex color is also a common material attribute. Vertex color refers to defining the color of a model's surface by assigning color values ​​to its vertices.

  Vertex colors are usually stored as vertex data and correspond to position information for each vertex. During rendering, vertex colors are interpolated based on their position within the triangle, determining the color of each point within the entire triangle.

  Vertex colors are values ​​between 0 and 1 (or 0 and 255) that can be added to the vertices of the mesh. Supported by most tools and engines, including the FBX file format. I believe OBJ does not support vertex colors. Technically, you can have an "unlimited" number of these values. But common practice is to limit it to RGBA values, so 4 values ​​per vertex. Therefore, we call it vertex color.

  Let's take a cube as an example. It has 8 vertices. Each vertex has a number, which you don't see when you're just modeling, but it does need the number so that the 3D world and file format know what vertices are where and how everything is connected. Each vertex number adds a certain number of values, RGBA. We can then adjust these values ​​using our 3D tools. See below.

  • The left cube has no vertex color data, nor does the gray color (the default representation in Modo).
  • The middle cube does have vertex color data, but it's all black. So 0,0,0,0 on all vertices.
  • The cube on the right is also completely black. Except for the one in the corner, which is red. So 1,0,0,0.

2.  Application of vertex color

  You'll often see this masking method used with leaf and tree shaders. The red channel controls the wind swaying effect of the entire tree. The blue channel controls the swaying effect of the branches. Green channels control the trembling of leaves. However, vertex colors are also used for texture blending of floors and walls, creating shading gradient controls in shaders, VFX shader effects, creating cheap AO alternatives, etc.

Vertex Color - Tree Example

  In order to properly use vertex shading with shaders, you usually need some handy tools. Each 3D software tool has different methods, so you must understand how they apply to the 3D tool you choose. You will want to be able to do the following:

  • Fills the entire object with a color that also applies to the channel mask. So that it can be completely black.
  • Linear gradient, also works with channel masks. Like the tree example above, channel red.
  • Spherical or cylindrical gradient with channel mask. Just like the tree example above, channel green.
  • Use brushes that also support channel masks for regular painting.
  • Ability to adjust values ​​on individual vertices or group selected vertices. For those moments when you need exact numbers.

  The GLTF editor  is an online GLTF model editing tool that integrates functions such as online viewing, material modification, model size modification, model material attribute modification, reset origin, model batching, etc. You can set the model vertex color by modifying the model material attributes.

  In the GLTF editor , the model color is set by filling the entire object with the color of the channel mask. The effect of the vertex color setting is to make the model completely black. As shown below:

3. Advantages and Disadvantages of Vertex Color

There are several advantages to using vertex color as a material attribute:

  1. High operating efficiency: Compared with texture attributes, using vertex colors during the rendering process can save memory and computing resources. Because there is no need to load and parse additional texture files, and there is no need to perform mapping calculations of texture coordinates.
  2. Strong flexibility: Using vertex color as a material attribute can directly control the color of each vertex, allowing us to draw more precise and detailed color changes. This is useful for specific drawing needs or dynamic shading effects.
  3. Good real-time rendering support: The use of vertex colors is ideal for real-time rendering engines because it can render models with high efficiency and real-time.

  Vertex color is usually defined by assigning red, green, blue, and (optional) transparency values ​​to each vertex. These values ​​can represent various colors in the RGB color space. For example, the vertex color (1, 0, 0) represents pure red, (0, 1, 0) represents pure green, and (0, 0, 1) represents pure blue.

  To create vertex colors, you need to specify the corresponding color value for each vertex. During rendering, the engine automatically calculates and renders additional color values ​​based on interpolation between vertices.

  Overall, vertex color is a flexible and efficient material property that can be used to achieve a variety of real-time rendering effects and provide better performance and control.

Original link: What is vertex color (mvrlink.com)

Guess you like

Origin blog.csdn.net/ygtu2018/article/details/132999312