4
$\begingroup$

I've created this complex mesh, but I don't know how to assign colors to the single faces of the mesh. One face is blue, another red and another green etc. I've seen people using the color ramp, but it doesn't work. How can I make it work? enter image description here

$\endgroup$

2 Answers 2

6
$\begingroup$

There are many ways to go about it, depending on your project's needs, but here's one simple trick:

Enter into Edit Mode, select all with A, unwrap your geometry with U > Lightmap Pack. Then, make the shader below. To get the "rainbow" look of the ColorRamp in my example, you can set both colors to something red-ish, and choose the HSV/Far mode. Or you can prepare a ramp with colors you want.

enter image description here

This tends to clump similar colors into relatively large groups, but you can play with the UVs as you wish:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Thank you very much, i was searching this method for days... $\endgroup$
    – Dorek
    Commented Feb 27, 2022 at 23:09
  • $\begingroup$ This is a neat trick! $\endgroup$
    – Blunder
    Commented Feb 28, 2022 at 2:05
13
$\begingroup$

Here is a solution that uses Geometry Nodes (requires Blender 3.0).

random colored faces with geo nodes

In the Geometry Nodes Editor, a random value is assigned to each face. It's a custom attribute named face_random in this example. In the side panel (N) of the Geometry Nodes Editor, you need to switch the Attribute Domain to Face to assign the value to the faces. The Name value here (Face RNG) is just the label for the attribute as shown in the Geometry Nodes modifier settings.

In the Geometry Nodes modifier settings, you specify the actual name of the random value attribute. Set Output Attributes > Face RNG to face_random. This value here should also appear as a column in the Spreadsheet. Usually, it's the last one.

In the Shader Editor, enter this value (face_random) for the Attribute node to get each face's random number. With a ColorRamp node you can convert the random value to a color.

$\endgroup$
2
  • $\begingroup$ This is gold, thank you so much! Is there a way to randomize duplicate objects so they don't have the same random patterns? $\endgroup$
    – Gary G.
    Commented Nov 6, 2023 at 0:49
  • 1
    $\begingroup$ You're welcome :) For different objects, just create a group input slot for the Seed of the Random Value node (drag the input to the empty group input slot). Then you can assign every object a different Seed value in the modifier settings that will create different random values. $\endgroup$
    – Blunder
    Commented Nov 6, 2023 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .