In Unity, you can apply decals (similar to stickers) to the shapes of 3D objects placed in your game. This feature is widely used in actual games.
Decal functionality allows for expressions similar to 3D object textures but is especially suited for representing effects and effects within scenes (imagine projecting an image onto a scene with a projector).
What You Can Express with Decals
The possibilities for decal expressions are endless, and the timing of decal appearances can be freely adjusted. Here are a few examples:
Hide seams between textures
Add accents to monotonous background objects
Represent spilled paint on the floor
Create cracks on walls or floors
Show raindrops falling on the water surface
Add carpets, scratches, dirt, graffiti, posters, etc.
Additionally, decals can help reduce the number of polygons in 3D models.
Usable in URP and HDRP Games
The example image for this article shows decals used with URP. However, decals cannot be applied to semi-transparent objects like glass.
In HDRP, you can display decals on semi-transparent objects as well. When using decals, you need to choose URP or HDRP based on the volume and expression of your game. (This article explains using URP for its lighter operation.)
Steps to Implement Decals
Introduce URP or HDRP to your project, or create a compatible project.
Add materials such as PNG images to Unity
To manage these easily, create a folder named “DECA” or similar in your assets to avoid confusion with other materials.
The imported image settings do not require special adjustments; keep the texture type as “Default” and the texture shape as “2D.”
Create a new material for decals, select “Shader Graphs/Decal” in the Inspector for Shader, and assign the previously added image to “Base Map” in Inputs.
With this, the preparation for decals is complete.
Create a Decal Projector in the Hierarchy.
Press “+” in the Hierarchy and select “Rendering” → “URP Decal Projector.” A game object named “Decal Projector” will be created, which you can rename as desired.
Assign the material you created earlier to the Decal Projector in the Inspector.
While assigning settings to the decal material and Decal Projector might seem complex, you only need to adjust the position and angle of the decals in the scene.
How to Apply Decals in the Scene
Select the Decal Projector created earlier from the Hierarchy or the scene. A white-framed object will be highlighted.
The thick part of the frame is the surface where the image is applied, and the thin lines indicate the decal range.
Decals displayed within the white frame can be adjusted in position, rotation, and angle using the Transform in the Inspector, just like general objects.
In URP Decal Projector, more detailed settings are available. You can adjust the decal’s size, range, position, and pivot, and use “Tiling” or “Offset” if you want to tile images continuously like fences. (Increasing the X value in Tiling arranges images horizontally, and increasing the Y value arranges them vertically.)
Applying Decals Across Multiple Objects and Considerations
Decals can automatically apply to multiple objects depending on the position and angle. However, there are some considerations:
When applying decals to objects like cubes, the image may stretch partially depending on the decal’s orientation.
For displaying images across multiple surfaces or objects, adjust the decal’s angle.
If the decal’s range is too large, it might appear on unintended backside surfaces. For thin walls or curved surfaces, adjusting the decal range or splitting the original image can improve the result.
This concludes the guide on using decals in Unity and their expressions. Utilize this feature to create more realistic and captivating game scenes.
Comments