Skip to content

💻 Vertex colors

This exercise uses a file exported from the ParaView scientific visualization package, and uses some of the workflow needed to get it into Blender.

X3D Importer

Check if you have a menu option to import X3D format. For this, go to File -> Import and check if there is an entry X3D Extensible 3D (.x3d/.wrl).

If you do NOT have the X3D import option then perform the following steps to enable the X3D add-on (otherwise continue to step 3):

  • Open the preferences window with Edit -> Preferences
  • Switch to the Add-ons tab
  • In the search field (with the little spyglass) enter "X3D", the list should get reduced to just one entry
  • Enable the checkbox left of "Import-Export: Web3D X3D/VRML2 format"
  • Close the preferences window (it saves the settings automatically)
  • Under File -> Import there should now be a new entry X3D Extensible 3D (.x3d/.wrl)
  1. Importing data always adds to the current scene. So start with an empty scene, i.e. delete all objects.

  2. Make sure Blender is set to use Cycles as the renderer. For this, switch to the Render tab in the properties area. Check the Render Engine drop-down, it should be set to Cycles.

  3. Import file glyphs.x3d using File > Import > X3D Extensible 3D, using the importer settings (on the right side of the window when selecting the file to import): Forward: Y Forward, Up: Z Up. The latter will make sure the imported model is oriented correctly.

  4. This X3D file holds a scene exported from ParaView. Check out the objects in the scene to get some idea of what it contains.

  5. Delete all the lights in the scene to clear everything up a bit. Add a single sun light in return.

Inspecting the vertex colors

This 3D model has so-called "vertex colors". This means that each vertex of the geometry has an associated RGB color, which is a common way to show data values in a (scientific) visualization.

There are a few ways to inspect if, and what, vertex colors a model has. First, there is the so-called Vertex Paint mode. In this mode vertex colors are shown when they are available and can even be edited ("painted").

To enable Vertex Paint mode:

  1. Select the 3D arrows in the scene (as the only single selected object)
  2. Open the Mode pie menu with Ctrl-TAB and switch to Vertex Paint. An alternative is to use the menu showing Object Mode in the upper-left of the 3D view header and select Vertex Paint there.
  3. The 3D View should now show the arrow geometry colored by its vertex colors. The colors shown are velocity values from a computational flow simulation, using the well-known rainbow color scale (low-to-high value range: blue → green → yellow → orange → red)

Altering vertex colors

You might have noticed two things have changed in the interface: 1) the cursor is now a circle, and 2) the tool shelf on the left now shows color operations (paint brush = Draw, drop = Blur, ...)

As this is Vertex Paint mode you can actually alter the vertex colors. This works quite similar to a normal paint program, like Photoshop or the GIMP, but in 3D. Although it may not make much sense to change colors that are based on simulation output (like these CFD results) it can still be interesting to clean up or highlight vertex-colored geometry in certain situations.

  1. Experiment with vertex painting: move the cursor over part of the arrow geometry, press and hold LMB and move the mouse. See what happens.
  2. Switch to the Tool settings tab in the properties area on the right-hand side of the window
  3. You can change the color you're painting with with the colored box directly right of the Draw in the bar at the top of the 3D view area (it's also shown and editable in the bar at the top of the 3D view). Click the color to bring up the color chooser. You can also change the radius and strength settings to influence the vertex painting.
  4. Change back to Object Mode using the Ctrl-TAB mode menu when you're done playing around. Note that the arrows no longer show the vertex colors.

Rendering

The second way to use vertex colors is to apply them during rendering.

  1. If you've screwed up the vertex colors really badly in the previous steps you might want to reimport the model...
  2. Make the 3D arrows in the scene the single selected object
  3. Switch to the Object Data tab in the properties
  4. Check that there is an entry "Col" in the list under Color Attributes. A model can have multiple sets of vertex colors, but this file has only one set called "Col", which has domain Face Corner and type Byte Color.

Now we will set up a material using the vertex colors stored in the "Col" layer.

  1. Go to the Material tab
  2. Select the material called "Material" in the drop-down list left of the New button. This set the (grey) material "Material" on the arrows geometry.
  3. Press F12 (or use interactive render) to get a rendered view of the current scene.

You'll notice that all the geometry is grey/white, i.e. no vertex colors are used. We'll now alter the material to use vertex colors.

  1. In the settings of the material there is a field called "Base Color" with a white area right of it. This setting controls the color of the geometry.
  2. Click the button left of the color area (it has a small yellow circle in it)
  3. Pick Attribute from the left-most column labeled Input. This specifies that the material color should be based on an attribute value.
  4. Base Color is now set to Attribute | Color. Directly below the entry there is a Name field. Pick "Col" from the list. This specifies that the attribute to use is called "Col" and comes from the mesh geometry (i.e. our vertex colors).
  5. Now render the scene again
  6. The rendered image should now be showing the arrow geometry colored by vertex colors


Last update: 22 April 2024 21:51:33