2D Hologram Shader

This is a hologram shader that I made for the dialog portraits in an upcoming space game, Ari’s Journey. I wanted to share this here to save some time for the next person wanting a similar effect. This was originally based on the 2D waterfall shader, but I’ve since rewritten it and used some of that shader combined with a 3D hologram shader I found here.

  • baseColor – sets the tint of the hologram. The alpha will adjust how strong the tint is. Leave at alpha 0 to not add any tint
  • speed – how quickly the lines move
  • linesColor – the color of the artifact lines that will scroll across the image. The alpha will effect how strong the color tint is. Set to 0 to have the artifact lines make the texture tranparent in places
  • linesColorIntensity – use to adjust the brightness of the lines. Used to make the lines more prominent
  • hologramTextureTiling – how many times the hologramTexture should be repeated in each direction across the base texture
  • hologramTexture – the texture that will be sampled to create the artifacts. Use the attached black & white hologram_lines image as a starting point

The screenshot and video attached are using a TextureRect, but it should work fine with a Sprite without any issues.

Shader code
shader_type canvas_item;

uniform vec4 baseColor: hint_color = vec4(0.3058, 0.835, 0.960, 1.);
uniform float speed = 0.5;
uniform vec4 linesColor: hint_color = vec4(0.633232, 0.910156, 0.555693, 1.);
uniform float linesColorIntensity = 5.;
uniform sampler2D hologramTexture;
uniform vec2 hologramTextureTiling = vec2(1., 5.);

vec2 tilingAndOffset(vec2 uv, vec2 tiling, vec2 offset) {
    return mod(uv * tiling + offset, 1);
}

void fragment() {
    vec2 offset = vec2(TIME * speed / 100.0);
    vec2 tiling = tilingAndOffset(UV, hologramTextureTiling, offset);
    
    vec4 noise = texture(hologramTexture, tiling);
    
    float fresnel = 0.71;
    vec4 colorLines = linesColor * vec4(vec3(linesColorIntensity), 1.0);
    vec4 emission = colorLines * fresnel * noise;
    
    vec4 albedo = baseColor;
    float alpha = dot(noise.rgb, vec3(1.0));
    vec4 hologram;
    hologram.rgb = emission.rgb + (1.0 - emission.rgb) * albedo.rgb * albedo.a;
    hologram.a = emission.a + (1.0 - emission.a) * alpha;
    hologram.a = hologram.a + (1.0 - hologram.a) * albedo.a;
    COLOR = texture(TEXTURE, UV);
    COLOR.rgb = COLOR.rgb + (1.0 - COLOR.rgb) * hologram.rgb;
    COLOR.a = min(COLOR.a, hologram.a);
}
Tags
future, hologram, sci-fi, space

Related shaders

SciFi Hologram

Half-Tone Comic Shader

PS1 Shader

The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Mmodream
Mmodream
7 months ago

thank you