Tech Art • Shader Graph • Unity

Baggage Scanner Shader

Overview and introduction

Breakdown on how the shader works and how its made.

Introduction

This project started from the idea of a game where the player takes on the role of a TSA agent inspecting luggage. With that in mind my goal was to recreate the visual look of an airport baggage scanner in Unity using Shader Graph. The shader was designed to mimic the scanning process by revealing the contents inside a luggage, including internal objects, different material types, and thickness. To achieve this i combined transparency, fresnel effects, thickness maps and material ID textures.

Textures and effects used

Here is a breakdown of the material on each object.

  • Thickness Map: Texture to illustrate the objects thickness
  • Material Map: Material Map to map a color to each part of the object
  • Fresnel Effect: Fresnel effect to get a glowing edge around the object
  • Final Shader: Combinding all of the above to get the Baggage scan effect

Stencil and depth buffers

Breakdown of how the scanning effect works.

  • Occlusion Box: I use an invisible box to check when the bag is hidden behind other objects. When that happens, the scan effect turns on and the scan material is applied.
  • Stencil Mask: Once the bag is hidden. I use the stencil buffer to mark the area where the scan effect should be visible.
  • Content inside: The objects inside the bag are then rendered only within that marked area so they appear visible only while the scan is active.

Breakdown

Breakdown on how the shader works and how its made.

Thickness Texture

This texture was baked in Substance Painter as a thickness map. It generates grayscale values based on the depth of the mesh showing how thick different parts of the object are. Brighter values represent thinner areas while darker values represent thicker ones.

Material Texture

This texture was created to define different material types across the object. Using grayscale values different areas are assigned material categories and colors such as Organic (Orange), Non-Organic (Green), Metals (Blue), and Heavy Metals (Purple). In the shader these values are masked and remapped to the correct material colors.

Fresnel Effect

Fresnel is an effect that takes the camera view angle into account and becomes more visible along the edges of an object. In this shader i used it to create a glowing outline around the objects. The fresnel effect is combined with the material color and connected to the emissive input in the master stack which results in glowing edges.

Final Shader

So the final shader is a combination of all these effects and textures. The thickness texture is combined with the material texture to create a albedo map that is connected to the base map in the main shader stack. The Fresnel and material combination is added to the emissive output to create a glowing edge.

Occlusion and stencil buffer

The red box is the occluder an invisible helper object that checks when the bag is behind other geometry. When that happens i use the stencil buffer to mark the area where the scan effect should appear (White box). The white material is only there as a debug view. It shows the exact area where rendering is allowed. In the final version this area is replaced with the transparent X-ray material instead. Once the scan is active the shader material is applied to the bag and both the bag and the objects inside it are only rendered within the marked area. This helps create the illusion that the bag is being scanned.

Challenges

  • A large part of the work took place outside of Unity. There was a lot of preparation for each object. Fixing UV maps, baking thickness maps and creating material textures for every object. To make the pipeline smoother I created export presets for the thickness maps. For the material ID textures i made a grayscale color palette which made it easier to keep track of which color represented which material when working in Photoshop.
  • Another challenge was finding the right transparent look. The thickness information baked in Substance Painter did not always translate the same for each object so it took some testing and tweaking to get it to look good. I also tried a few different shader setups along the way such as comparing lit and unlit versions and testing the effect with and without the Fresnel. This helped me explore what worked best visually for the scan effect.

If i had more time

  • If I had more time i would have liked to explore the different baking settings in Substance Painter more. I knew there were several options to experiment with but i did not have enough time to test them properly.
  • It would also have been nice to spend more time polishing the visual look of the effect. I think there is potential for more interesting results by working further with how density values are translated into color. Which could help separate different organic materials more clearly from eachother. For example materials such as fruit, wood, or other dense objects could be given more distinct color differences.