Thin Film Fresnel effect
A physically inspired shader that simulates the thin-film Fresnel effect, producing realistic iridescent colors like those seen on soap bubbles, oil slicks, or coated glass.
Includes both a physically-based interference mode and a simplified two-color override mode.
Installation
Simply drag the unity package into the file brovser of your project.
The file will be added under: Assets/Kokos/Shaders/Thin Film Fresnel
Properties
Property | Type | Description | Default |
---|---|---|---|
Color (_Color ) | Color | Tint color applied to the overlay texture | Black |
Transparency (_Transparency ) | Range(0–1) | Controls surface alpha blending | 0.3 |
Smoothness (_Glossiness ) | Range(0–1) | Surface glossiness / smoothness | 0.5 |
Metallic (_Metallic ) | Range(0–1) | Metallic factor | 0.0 |
Overlay (_MainTex ) | 2D Texture | Overlay texture applied on top of the surface | White |
Overlay Panning Speed (_MainTexSpeed ) | Vector2 | Scroll speed of overlay texture (XY) | (0,0) |
Film Thickness (_FilmThickness ) | 50–600 (nm) | Thickness of the thin film (affects interference colors) | 200 |
Iridescence Strength (_IridescenceStrength ) | Range(0–1) | Blends interference colors into final result | 0.5 |
Thickness Noise (_NoiseTex ) | 2D Texture | Noise texture to vary thickness across surface | Gray |
Noise Panning Speed (_NoiseTexSpeed ) | Vector2 | Scroll speed of thickness noise | (0,0) |
Noise Strength (_ThicknessNoiseStrength ) | Range(0–1) | Blends noise into thickness variation | 0.0 |
Wavelength R/G/B (_WavelengthR/G/B ) | Range(380–750) (nm) | Wavelengths used for interference calculation | R=680, G=550, B=440 |
Override colors (_UseCenterEdge ) | Toggle | Switch between physically correct interference and artistic override | Off |
Center Color (_CenterColor ) | Color | Used when Override colors mode is enabled | Cyan |
Edge Color (_EdgeColor ) | Color | Used when Override colors mode is enabled | Orange |
Modes
Physically Correct Interference
- Uses wavelength-dependent Fresnel equations.
- Produces rainbow-like iridescence based on thickness and view angle.
- Thickness can vary using a noise texture for more organic effects.
- Waven lengths can be changed to create different color combinations
Two-Color Override Mode
- Ignores physics.
- Simply blends between Edge Color and Center Color depending on the viewing angle.
- Useful for stylized rendering.
Some shader properties are not available in the Override Mode, since this mode uses an appoximation for the original effect which mapps the 2 colors instead of calculating the interference.
This shader relies on Unity’s reflection probes for accurate reflections.
Without a reflection probe or lighting in the scene, reflections and colors may appear incorrect, overly dark, or be missing entirely.
Examples
4 ready-to-use example materials are included in the Examples
folder.
These show different combinations of settings.
- Default Thin Film – standard iridescence with medium film thickness Example 1
- Noisy Iridescence – uses a noise texture to create varying thickness across the surface Example 2
- Dual Color Mode – center/edge color override for a stylized effect Example 3
- Overlay Variant – combines overlay texture with iridescence Example 4
The Thin Film Fresnel Demo prefab contains all 4 examples. Simply drag it into your scene.