Retro Reflection Map Shader

This is a reflection shader that allows Meshes to have a primitive reflection map on top of it, just like in an old N64/PS2/GameCube/Xbox game. If you’ve played Zelda: Ocarina of Time, or played an early sixth gen. era game on the PS2 (for reference, I based it upon tower reflections from both True Crime: Streets of LA and the Spider-Man movie game), then this kind of reflection is very familar.

To make it work in Godot, apply it to a Mesh as a shader material, then add a diffuse texture, then add a reflection map (has to be a black & white blobby looking image, Ocarina of Time used a similar image, so did Majora’s Mask and the GameCube startup screen, but you’d should probably find or create a similar texture for copyright related reasons.)

After applying both textures, you can adjust the scale of the reflection, and the intensity.

If you’d want to fork my code and improve on it or do anything with it, your free to do so.

Shader code
shader_type spatial;

uniform sampler2D diffuse_texture : source_color;
uniform sampler2D reflection_map : hint_default_white;
uniform vec4 reflection_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float reflection_strength = 0.5;
uniform float specular_strength : hint_range(0.0, 1.0) = 0.0;
uniform float metallic_strength : hint_range(0.0, 1.0) = 0.0;
uniform float roughness_value : hint_range(0.0, 1.0) = 1.0;

// UV variables for controlling reflection map movement and scale
uniform vec2 reflection_offset = vec2(0.0, 0.0);
uniform vec2 reflection_scale = vec2(1.0, 1.0);

void fragment() {
    // Sample the base diffuse texture
    vec4 diffuse = texture(diffuse_texture, UV);

    // Calculate reflection UV coordinates
    vec3 view_normal = normalize(VIEW * NORMAL);
    vec2 reflection_uv = vec2(
        view_normal.x * 0.5 + 0.5,
        view_normal.y * 0.5 + 0.5
    );

    // Apply reflection scale and offset
    reflection_uv = reflection_uv * reflection_scale + reflection_offset;

    // Sample the reflection map
    vec4 reflection = texture(reflection_map, reflection_uv);

    // Combine diffuse and reflection
    vec3 final_color = mix(
        diffuse.rgb,
        diffuse.rgb + reflection.rgb * reflection_color.rgb,
        reflection.r * reflection_strength
    );

    // Output the final color
    ALBEDO = final_color;

    // Apply the adjustable material properties
    SPECULAR = specular_strength;
    METALLIC = metallic_strength;
    ROUGHNESS = roughness_value;
}
Tags
gamecube, PS2, reflection, retro
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.

Related shaders

Universal Screen Space Reflection(SSR)屏幕空间反射 use ray marching

Sprite Water Reflection Pixel Art Pokémon Style

Simple Splat-map Shader for 3D Terrain (uses Vertex colors as splatmap)

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments