Iridescent Chrome Shader
ridescent Chrome Shader is a Godot 4.3 shader that creates a dynamic iridescence effect — simulating the rainbow-like color shifts you see on materials like soap bubbles, oil slicks, or holographic metal. The color changes in real time based on the view angle, giving your 3D surfaces a vibrant, shifting appearance.
This is a fully procedural shader that doesn’t require any textures, making it lightweight and flexible. It’s ideal for sci-fi assets, magical items, alien materials, or any surface that needs a stylish, colorful polish.
Parameters:
-
roughness
Controls how smooth or matte the surface looks. Low values (0.0) make it shiny and reflective, high values (1.0) make it dull and diffuse. -
metallic
Determines how metallic the material is. Set to 1.0 for a full metal look, 0.0 for non-metallic surfaces. For this shader, 1.0 is recommended. -
iridescence_scale
Adjusts how many color bands appear across the surface. Higher values produce more color shifts, lower values create a smoother gradient. -
iridescence_intensity
Controls how strong the iridescent effect is. At 0.0 the surface looks pure white, at 1.0 it shows full rainbow hues.
Shader code
shader_type spatial;
render_mode specular_schlick_ggx;
uniform float roughness : hint_range(0.0, 1.0) = 0.1;
uniform float metallic : hint_range(0.0, 1.0) = 1.0;
uniform float iridescence_scale : hint_range(0.0, 10.0) = 3.0;
uniform float iridescence_intensity : hint_range(0.0, 1.0) = 0.5;
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0/3.0, 1.0/3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
vec3 iridescent_color(float angle) {
float hue = fract(angle * iridescence_scale);
return hsv2rgb(vec3(hue, 1.0, 1.0));
}
void fragment() {
vec3 view_dir = normalize(-NORMAL);
float angle = dot(NORMAL, VIEW);
vec3 rainbow = iridescent_color(angle);
vec3 base_color = mix(vec3(1.0), rainbow, iridescence_intensity);
ALBEDO = base_color;
METALLIC = metallic;
ROUGHNESS = roughness;
EMISSION = base_color * 0.2;
}
