Three.js Hologram Shader Effect

Sci-fi hologram shader in Three.js combining a Fresnel rim glow, scanlines, a sweeping scan band, flicker and vertex-slice glitches, displayed above a projector with a light cone.

Key topics: three.js hologram, hologram shader, fresnel, scanlines, glitch effect, sci-fi

What this code does

- Fresnel Rim: opacity rises toward silhouettes, (1 − |N·V|)^p, which reads as a glowing projected shell.
- Additive Blending: no depth writes and additive color make it look like light, not a solid surface.
- Scanlines & Sweep: a sine of world height scrolls upward, and a brighter band periodically sweeps through.
- Glitches: occasional horizontal slices are shifted sideways in the vertex shader using a time hash.
- Flicker: brief brightness dips at random frames mimic an unstable projector.
- Controls: model, color, scanline density, Fresnel power, glitch, flicker and spin.

Continue Learning

JavaScript Implementation

ES6+
const hologram = new THREE.ShaderMaterial({
  uniforms: { uTime: { value: 0 }, uColor: { value: new THREE.Color(0x38e1ff) } },
  transparent: true,
  blending: THREE.AdditiveBlending,
  depthWrite: false,
  side: THREE.DoubleSide,
  vertexShader: `
    varying vec3 vNormal; varying vec3 vView; varying float vY;
    void main () {
      vec4 mv = modelViewMatrix * vec4(position, 1.0);
      vNormal = normalize(normalMatrix * normal); vView = -mv.xyz; vY = (modelMatrix * vec4(position, 1.0)).y;
      gl_Position = projectionMatrix * mv;
    }`,
  fragmentShader: `
    uniform float uTime; uniform vec3 uColor; varying vec3 vNormal; varying vec3 vView; varying float vY;
    void main () {
      float fresnel = pow(1.0 - abs(dot(normalize(vNormal), normalize(vView))), 2.2);
      float scan = 0.55 + 0.45 * sin(vY * 70.0 - uTime * 6.0);
      gl_FragColor = vec4(uColor * (0.6 + fresnel * 1.4), (fresnel * 1.2 + 0.08) * scan);
    }`
})
scene.add(new THREE.Mesh(new THREE.TorusKnotGeometry(0.6, 0.2, 220, 32), hologram))