Metlivi Studio

How to Give Instanced Cubes Sampled Colors While Keeping Their Procedural Material in Blender

To give each instanced cube a sampled color while preserving its procedural material, store the sampled color on the instancing points, then read that attribute inside the cube’s existing shader. Connect it to the material’s color branch while keeping the roughness, bump, coat, and shader output connections intact.

This walkthrough uses Blender 4.5 LTS node names. It covers one color per cube—for example, a block mosaic that follows the colored regions of a striped storage box while retaining a shared textured plastic finish.

Decide Which Parts of the Material Should Stay Procedural

Start by finding the connection that currently supplies the cube material’s Base Color. Keep the rest of the material graph available: a procedural texture driving roughness or bump can continue doing so while a sampled attribute supplies the color. The Principled BSDF exposes separate inputs for base color, roughness, normal, and coat properties. Blender Manual: Principled BSDF

There are two useful choices. For a recognizable sampled palette, replace only the existing base-color input. To retain procedural color variation as well, combine the sampled color with the existing color branch. This second choice changes the sampled colors; decide whether matching the source palette or retaining the old colored pattern matters more.

A cube can have one sampled base color and still show different brightness across its faces under lighting. The intended result is a consistent color assignment per cube, with the existing surface finish still visible.

Prepare a Source That Actually Contains Color Data

You need three scene components: a source mesh carrying accessible color data, a geometry stream containing the cube-placement points, and a cube prototype with the procedural material assigned. If you already have a working cube distribution, keep it and insert the attribute-transfer steps below.

For the main workflow, assume the source mesh has a color attribute named source_color. Substitute your actual attribute name wherever that name appears. In Geometry Nodes, a Named Attribute node reads an attribute in the context where its output is evaluated; its Exists output can help confirm that the attribute is present. Blender Manual: Named Attribute Node

If the source’s colors come from an image instead, reproduce the image lookup in Geometry Nodes: connect a Named Attribute node set to Vector, using the source’s UV-map name, to an Image Texture node’s Vector input. Select the source image and use its Color output as the sampling value in the next section. Connect the UV coordinates explicitly: the Geometry Nodes image texture otherwise defaults to position coordinates. Blender Manual: Image Texture Node

Do not assume that retrieving a mesh also retrieves its finished shader appearance. Sample Nearest Surface evaluates a supplied field on the source mesh. The practical consequence is that you must provide the color attribute, image lookup, or other reproducible color field you want transferred; the node does not offer an input for sampling a complete rendered material. Blender Manual: Sample Nearest Surface Node

Sample the Source at Each Cube’s Placement Point

In the Geometry Nodes modifier that generates the cubes, add an Object Info node targeting the colored source mesh. Turn off As Instance so the sampling node receives mesh geometry. Set its transform space to Relative to bring the source into the modified object’s coordinate space while retaining its placement in the scene. Blender Manual: Object Info Node

Add Sample Nearest Surface and set its data type to Color. Build these connections:

  1. Source Object Info → Geometry connects to Sample Nearest Surface → Mesh.
  2. A Named Attribute node, set to Color with name source_color, connects its Attribute output to the sampler’s Value input. For an image source, use the image-color branch described above instead.
  3. A Position node connects to Sample Position.
  4. Leave the group inputs at their matching defaults unless you deliberately use sampling groups.

The sampler evaluates the color field on the source mesh and finds the closest surface location for each supplied position. It interpolates non-face attributes across the surface, so a source gradient can produce intermediate colors. Loose vertices and edges are ignored because this node samples mesh surfaces. Blender Manual: Sample Nearest Surface Node

For a voxel-like arrangement, this means an interior cube receives the color of the nearest exterior surface. On a thin object, a nearby opposite face may supply the color. That follows the chosen nearest-surface rule; if you require colors projected from one direction, this sampling method needs to change.

Store the Color Before Creating the Instances

Insert Store Named Attribute into the placement-point geometry stream immediately before Instance on Points. Use Color as the data type, Point as the domain, and cube_sample_color as the name. Leave Selection enabled for every point, and connect the sampler’s color output to Value. The node writes the evaluated field onto the geometry passing through it. Blender Manual: Store Named Attribute Node

The geometry path should now read: placement points → Store Named Attribute → Instance on Points → Group Output. Connect the stored geometry to the instancer’s Points input, and your material-bearing cube prototype to its Instance input.

Placement is important here. Store the attribute on the geometry that provides the placement points, rather than on the shared prototype cube. Blender makes attributes on the input points available on the generated instance domain, which carries the individual color assignments into the instances. Blender Manual: Instance on Points Node

This arrangement also defines when sampling happens. If you move the points before storing the attribute, their new positions determine their sampled colors. If you move the resulting instances afterward, they retain the colors already assigned. Choose the order according to whether the cubes should carry their colors or pick up colors at their final locations.

Read the Sampled Color Inside the Existing Cube Material

Open the material assigned to the prototype cube in the Shader Editor. Add an Attribute node, set its attribute type to Instancer, and enter cube_sample_color exactly. Use its Color output for the material’s color input. The Instancer lookup explicitly searches Geometry Nodes instance attributes. Blender Manual: Attribute Node

For the first check, connect Attribute → Color directly to the existing Principled BSDF’s Base Color. Keep the existing roughness, bump, and coat connections, along with the BSDF connection to Material Output. You are editing the color input within the material that already produces the desired finish.

Once the transfer works, restore any desired procedural color modulation with a Mix node set to the Color data type. Ordinary Mix blends the old procedural color and sampled color according to Factor. Alternatively, use Multiply with a neutral gray-to-white procedural pattern to add darker variation to the sampled palette. Blender’s color-mixing node provides both these blending modes. Blender Manual: Mix Color Node

For an illustrative starting point, multiply the sampled color by a procedural pattern ranging from 0.8 gray to white, with Factor set to 1.0. This introduces modest dark variation. Multiplying by a strongly colored old pattern also changes the resulting hues, so use the direct connection when evaluating whether sampling is correct.

Handle Realized Cubes Without Losing Their Colors

Keep the cubes as instances if your remaining workflow supports that. Instancing references shared geometry instead of duplicating it, while realization creates actual geometry and can increase processing costs. Blender Manual: Instance on Points Node, Blender Manual: Realize Instances Node

If a later operation requires real meshes, add Realize Instances after Instance on Points, then change the shader’s Attribute type from Instancer to Geometry. Named instance attributes propagate onto the realized geometry, where the geometry lookup can read them. Avoid creating cube_sample_color on the prototype itself: when the same attribute exists on both the prototype geometry and the instance, the prototype’s values take precedence during realization. Blender Manual: Realize Instances Node, Blender Manual: Attribute Node

Store the color before realization to preserve the intended one-sample-per-cube assignment. Evaluating a fresh position-based sample on the realized cube vertices would instead allow different vertices of one cube to receive different colors.

Check the Result in Three Controlled Passes

Use a small patch of cubes before evaluating the entire arrangement. The following diagnostic sequence separates attribute transport, source sampling, and material appearance. It is a proposed check for your scene, rather than a claim of a completed render.

  1. Check transport. Temporarily disconnect the sampled field from Store Named Attribute → Value and choose a saturated orange color there. With the shader attribute connected directly to Base Color, every generated cube should receive orange.
  2. Check sampling. Reconnect the sampled field. Compare cubes near two visibly different source regions. Their base colors should follow those regions, with possible intermediate colors where the source attribute is interpolated.
  3. Check the finish. Inspect the cubes in Material Preview or a lit render. Look for the original roughness variation, bump detail, and coat highlights. Then enable any optional procedural color mixing.
Visible problem First check
Cubes stay black during the constant-orange check Confirm the attribute name, shader lookup type, and material assigned to the prototype.
Constant orange works, but source colors do not Check the source attribute name, source mesh connection, and UV lookup if using an image.
Colors appear spatially offset Check source transform space and the point positions used for sampling.
One cube contains unwanted color gradients Check whether sampling was evaluated on realized mesh vertices.
Colors change after realization Switch the shader lookup to Geometry and check for a same-name prototype attribute.
Sampled hues become muddy Bypass the procedural color blend and inspect the direct sampled color.

For the striped storage-box example, the target is straightforward: cubes near each stripe receive that stripe’s color, while their shared material continues to show the same textured plastic finish. Once that small comparison works, apply the same connections to the full distribution. The useful division is consistent throughout: Geometry Nodes assigns the color per cube, and the existing shader determines how that colored surface responds to light.

Sources