Skip to main content

Decals

A decal is a picture stuck onto a surface: a bullet hole in a wall, blood on the floor, a scorch mark after an explosion, a footprint in the mud. It bends around bumps and corners, and it rides along with the object it was put on.

There are two kinds:

  • a Decal Projector, placed in the editor like any object: a crack on a wall, a puddle, a road arrow, graffiti, a soft shadow under a character;
  • decals placed while the game runs, from an event or a script: bullet holes, splats, footprints.

Decal Projectors: a scorch over two crates (the sides fade out), a road arrow tiled twice on a ramp, a crack on a ball, a shiny puddle with ripples, overlapping splats and a splat on a block that slides under its projector

Decal Projector​

Unity's Decal Projector (URP). It projects a picture onto the surfaces inside its box, along the object's forward (−Z, the way a spotlight shines); the picture's top is the object's +Y. The box starts at the object and reaches Projection Depth forward.

+ Add → Decal Projector puts one half a metre above the surface in the middle of the view, pointing straight down. Move it, turn it and scale it like any object; the green box shows where it reaches.

SettingWhat it does
ImageThe picture (from Files), with see-through parts. None: the built-in Look.
LookWithout an image: Scorch, Splat, Crack, Bullet hole or Footprint, tinted by the Color.
ColorA tint over the picture.
Opacity0 … 1.
Normal map / Normal scaleBumps for the picture (ripples in a puddle, cracks with depth).
Roughness0 shiny (wet), 1 matte.
Width / HeightThe box's size across, in metres (the object's scale multiplies it).
Projection DepthHow far forward the box reaches. Everything in it gets the picture, so keep it short to miss what is below.
Tiling / OffsetRepeat and shift the picture across the box.
Angle Fade Start / EndDegrees between a surface and the projector: full picture below Start, none past End. With 70 … 90 a floor decal stays off the walls beside it.
Draw Distance / Start FadeNot drawn farther than Draw Distance from the camera; it fades out from Start Fade (a part of the distance, 0.9 = the last tenth).
OrderWhere decals overlap, a higher order draws on top.

Good to know:

  • It lands on opaque surfaces: shapes, models, terrain. Not on see-through ones (sprites, water, glass) or animated characters.
  • It moves with nothing: the picture stays where the box is. When a surface moves through the box (a door, a moving platform) the picture is projected again each frame, so it slides over it.
  • Each projector costs one draw. It is projected again only when the projector or a surface in its box moves.
  • From events, Set component setting changes any of its settings while playing (fade a puddle out with Opacity).

Placed while the game runs​

From an event​

Use Graphics → Place decal. In a collision event, the defaults already put it where the hit happened (hitX, hitY, hitZ) facing away from the surface (hitNormalX, hitNormalY, hitNormalZ).

On Bullet collides with Wall → Place Bullet hole decal
SettingWhat it does
LookBullet hole, Splat, Scorch mark, Crack, Footprint, or My image (an image from Files, with see-through parts).
X / Y / ZWhere the surface is.
Normal X / Y / ZThe way the surface faces. Up for a floor: 0, 1, 0.
SizeWidth in meters. Default 0.4.
ColorA tint. Empty = the look's own color (dark for holes, red for splats).
LifetimeSeconds before it fades out. 0 keeps it for good. Default 20.

From a script​

game.addDecal(hit.point, hit.normal, { image: "bulletHole", size: 0.3 })
game.addDecal({ x: 0, y: 0, z: 0 }, { x: 0, y: 1, z: 0 }, { image: "Blood", lifetime: 60 })

image is a built-in look (bulletHole, splat, scorch, crack, footprint) or the name of an image in Files. Also color, lifetime and roll (turn on the surface in degrees; random if left out). It returns false when there is no surface at that point.

Good to know​

  • At most 60 decals exist at once. A new one removes the oldest.
  • A decal is put on the surface just under the point you give (it looks about 0.7 m against the normal).
  • Decals follow a moving object (a door, a crate). On an object stretched unevenly (a wall made by scaling a cube to 10 × 3 × 0.2 and turning it) the decal stays where it was put instead of following.
  • Animated characters (skinned models) don't take decals.
  • A decal goes with the object when that object is destroyed.