Pearlescent

A simulation of pearlescence, specifically the trait of materials which contain organic dielectric media squashed together at such proximity as to cause them to refract light, like a pearl does.

For true pearlescence, you would need to know the angle of the light at all times, which is infeasible for most games; this uses a “fake light” parameter, `light_direction`, which can be directed from a major source like the sun, to simulate this. You can update the `light_direction` for the base (non-unique) material at every frame to cut down on processing and memory costs.

Shader code
shader_type spatial;

uniform float fresnel_power = 3.0;
uniform float interference_frequency = 3.0;
uniform vec3 base : source_color = vec3(1.0, 0.8, 0.6);
uniform vec3 shift : source_color = vec3(0.2, 0.7, 1.0);

uniform float roughness = 0.3;
uniform float metallic = 0.7;
uniform vec3 light_direction = vec3(0.0, -1.0, 0.0);

float fresnel(vec3 view, vec3 normal) {
	return pow(1.0 - dot(view, normal), fresnel_power);
}

vec3 irridescence(vec3 view, vec3 normal, vec3 light) {
	float dot_view = dot(view, normal);
	float dot_light = dot(light, normal);

	float angle = abs(dot_view - dot_light);
	float interference = sin(angle * interference_frequency) * 0.5 + 0.5;

	return mix(base, shift, interference);
}

void fragment() {
	ALBEDO = mix(
		irridescence(VIEW, NORMAL, light_direction),
		vec3(1.0),
		fresnel(VIEW, NORMAL));
	ROUGHNESS = roughness;
	METALLIC = metallic;
}
Live Preview
Tags
pearl, pearlescence, pearlescent
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.

More from michael_macha

Comments 2

    1. Thank you, I noticed that recently! I'm going to be taking this on again at some point, and converting my fragment code to light code. It's a little slippery finding examples of light shaders, but it seems simple enough.

      1