Products › BaseNode Packs › Smart Materials › Tutorial: Smart crate

Smart crate

A painted steel crate, worn by the years: chipped edges, dents, rivets, rust run down from under its lid and from its rivets, paint run down its walls, dust on top. Nothing here is written from scratch. Every effect is a ready-made group of the standard library; this tutorial only shows how to put them together.

A blue steel crate under a riveted lid, its edges chipped to bare steel, thin rust streaks running down from under the lid
Where we are going. Five steps, each one a few lines more.

Before you start

You need Blender 5 and the Base Node add-on, version 0.12.1 or later, and the Smart Materials pack: it carries the three modules this tutorial assembles (mesh_maps, generators, mesh_effects). The steps below are free; the modules they call are not.

ModuleKindWhat it gives
mesh_mapsgeometryComputes the maps a texture painter bakes, live: curvature, ambient occlusion, thickness, sky… and stores them on the mesh.
generatorsshaderMasks made from those maps, after Substance 3D Painter's generators: metal_edge_wear, dirt, dust, dripping_rust…
mesh_effectsgeometry and shaderWhat a painter can only fake, made in the mesh: dents, rivets, chip_edges, streaks, drips, dust_scatter. Each stores where it acted, and mesh_effects_read gives it back to the material.

Every block below is a complete .bn file, its code beside the nodes it builds. Two ways to try a step:

The pictures are rendered from these exact files by render.py.

Two halves

A smart material here is two things that work together:

The geometry measures, the material paints: the masks of the material read what the effects stored on the mesh. Adding wear is adding a line to the pipe, a layer to the stack, or both.

1. A painted crate

A box and a lid that overhangs it, both Cubes with enough vertices for the effects to come: 1.5 cm apart. The material is plain paint for now.

step1_crate.bn: smart_crate, crate_steel, CrateSteel

A plain blue crate under a lid
Step 1. Paint, and nothing else.

2. The maps, and two layers

One line in the pipe, |> mesh_maps(…), and the mesh knows where its edges and its corners are. Two layers in the material use it:

step2_maps.bn: crate_steel, smart_crate

  1. Bare steel. metal_edge_wear is a mask, 1 on the edges that wear; Mix lays steel over paint there.
  2. Grime. dirt is a mask, 1 in the corners the mesh occludes; Mix lays grime over the layer before.
  3. The surface. The same masks make the steel metallic and the grime rough.

The order of the layers is the order of the Mixes: each one's a is the layer before.

The blue crate with thin lines of bare steel along its edges
Step 2. Worn edges, from the curvature mesh_maps stored.

3. Dents, rivets and chips

Three lines more, before the maps: the mesh is dented, riveted and chipped for real. In the material, one change: the bare steel takes e.chip too, where the mesh was chipped.

step3_effects.bn: smart_crate, crate_steel

The crate dented, with rows of rivets along its edges and chips of bare steel
Step 3. A row of rivets along each edge, dents in the walls, chips knocked off the edges.

4. Rust

Rust runs down with the rain: from under the lid, from the top of the walls, from the rivets, never from the middle of a wall. streaks traces those runs on the mesh and stores them; a rust layer paints them.

step4_rust.bn: smart_crate, crate_steel

The crate with thin rust streaks running down its walls from under the lid
Step 4. Streaks from under the lid and from the rivets, fading as they run down.

5. Paint runs and dust

Two lines to finish: drips, paint run down the walls, and dust_scatter, specks on what faces up. In the material, a dust layer, and no edge wear on the paint runs.

step5_finish.bn: smart_crate, crate_steel

Close to a corner of the lid: rivets, rust streaks from under it, a thin paint run, dust on top
Step 5, close to a corner of the lid.

The knobs

Every effect has its inputs; every layer its colour. A few to start with:

WhereInputWhat it does
crate_steelpaint, rust, grime…The colour of each layer, on the group node in the material.
crate_steelwearHow far the bare steel spreads from the edges.
streaksdensity, length, rivetsHow many runs of rust, how far they go, how many rivets bleed.
dripsdensity, radius, length, dropHow many runs of paint, how wide, how long, how big the drop at their end.
chip_edgeswear, widthHow much of the edges is chipped, and how far in.

Try: on step 5, set drop of drips to 0, then to 2. Set rivets of streaks to 1: every rivet rusts.

To wear your own model, use your mesh instead of body + lid: the pipe and the material stay as they are. Mind the density of its vertices: the effects work on them, so a model with large faces needs a SubdivideMesh first.

Take it to Blender

The finished crate, in one file. Drag the card onto empty space in Blender's 3D Viewport and keep Instantiate the Example: a new object carries smart_crate. A click on the card downloads the file.

The steps before it, to start again from any of them:

The files, with the script that renders this page's pictures, are in examples/tutorials/smart_crate/.