Medium MeshAnimated

Hologram

A cyan hologram: strong rim glow, faint body and scrolling scanlines.

The target picture for the shader challenge "Hologram"
Recreate this picture. You pass at a 99% match, then try to write it in fewer characters than the par.

About the Hologram shader

A cyan hologram: strong rim glow, faint body and scrolling scanlines. Vertex and fragment shaders on real 3D meshes: moving vertices, lighting, toon shading, holograms and dissolves, as used in Unity, Unreal and Godot.

How this challenge works

You write a fragment shader that draws the picture above, live in your browser. A match bar shows how close you are, and the score combines accuracy, code size (the par is 221 characters in Unity (Built-in)) and GPU speed. Work in HLSL, GLSL, WGSL, Metal or Godot and export the result when you are done.

What it is built from

Fresnel
f = pow(1.0 - saturate(dot(i_normal, i_viewDir)), 2.0)
Scanlines
? + ? * sin(i_worldPos.y * ? - time * ?)
Color
float3(0.2, 0.9, 1.0) * (f * ? + ?) * scanlines

The exact numbers are left out (shown as ?), but every colour is given. Measure the rest with the pixel readout on both pictures and Diff.

How to make a hologram shader

  1. i_worldPos.y changes with height: use it as the scanline coordinate.

Techniques used

  • Fresnel: surfaces are more reflective at grazing angles, which makes rims glow.
  • Sine waves: smooth oscillation for waves, pulses and motion over time.

Hologram shader code, explained step by step

Try to build it yourself first, because that is how it sticks. When you want to check your work or you are stuck, this is a complete working solution cut into parts, with the idea behind each part. The parts are in HLSL (Unity and Unreal); the full code below comes in every language.

Part 1: Return the result

Inside float4 frag(float2 uv)

float f = pow(1.0 - saturate(dot(i_normal, i_viewDir)), 2.0);
float scan = 0.7 + 0.3 * sin(i_worldPos.y * 60.0 - time * 5.0);
return float4(float3(0.2, 0.9, 1.0) * (f * 1.5 + 0.15) * scan, 1.0);
  • Putting time inside sin or cos makes the value swing back and forth, which is what animates the effect.
  • time is the number of seconds since the shader started, so anything that uses it moves.
  • The dot product of the surface normal and the light direction is the diffuse light: bright where the surface faces the light, dark where it faces away.
  • pow(x, k) reshapes a value: a high power keeps only the brightest part, which makes small sharp highlights.
  • The shader returns the final colour: red, green, blue, and an alpha of 1 (fully opaque).

The full code

HLSL Unity, Unreal
float4 frag(float2 uv)
{
    float f = pow(1.0 - saturate(dot(i_normal, i_viewDir)), 2.0);
    float scan = 0.7 + 0.3 * sin(i_worldPos.y * 60.0 - time * 5.0);
    return float4(float3(0.2, 0.9, 1.0) * (f * 1.5 + 0.15) * scan, 1.0);
}
GLSL three.js, Shadertoy, OpenGL
vec4 frag(vec2 uv)
{
    float f = pow(1.0 - clamp(dot(i_normal, i_viewDir), 0.0, 1.0), 2.0);
    float scan = 0.7 + 0.3 * sin(i_worldPos.y * 60.0 - time * 5.0);
    return vec4(vec3(0.2, 0.9, 1.0) * (f * 1.5 + 0.15) * scan, 1.0);
}

Open it in the editor and change it

Solve it in your language

Unity (Built-in), Unity (URP), Unreal, Shadertoy / WebGL, OpenGL (LWJGL, raylib), three.js, GameMaker, LÖVE (Lua), Godot, Apple (iOS, macOS), WebGPU / Bevy.

Start coding

Questions about this shader

How do I make a hologram shader?

A cyan hologram: strong rim glow, faint body and scrolling scanlines. A good first step: i_worldPos.y changes with height: use it as the scanline coordinate. In ShaderBattle you build it in the browser with a live match bar, so you see how close you are after every change.

What techniques does the hologram shader use?

It is built from fresnel, sine waves. Each one is a small idea you can reuse in other effects.

Does this hologram shader work in Unity, Unreal, Godot and Shadertoy?

Yes. The idea is the same in every shader language. ShaderBattle shows the code in HLSL (Unity, Unreal), GLSL (Shadertoy, three.js, OpenGL), WGSL (WebGPU), Metal and Godot, and exports a ready-to-paste version.