Skip to main content

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.

Image

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

PropertyTypeDescriptionDefault
Color (_Color)ColorTint color applied to the overlay textureBlack
Transparency (_Transparency)Range(0–1)Controls surface alpha blending0.3
Smoothness (_Glossiness)Range(0–1)Surface glossiness / smoothness0.5
Metallic (_Metallic)Range(0–1)Metallic factor0.0
Overlay (_MainTex)2D TextureOverlay texture applied on top of the surfaceWhite
Overlay Panning Speed (_MainTexSpeed)Vector2Scroll 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 result0.5
Thickness Noise (_NoiseTex)2D TextureNoise texture to vary thickness across surfaceGray
Noise Panning Speed (_NoiseTexSpeed)Vector2Scroll speed of thickness noise(0,0)
Noise Strength (_ThicknessNoiseStrength)Range(0–1)Blends noise into thickness variation0.0
Wavelength R/G/B (_WavelengthR/G/B)Range(380–750) (nm)Wavelengths used for interference calculationR=680, G=550, B=440
Override colors (_UseCenterEdge)ToggleSwitch between physically correct interference and artistic overrideOff
Center Color (_CenterColor)ColorUsed when Override colors mode is enabledCyan
Edge Color (_EdgeColor)ColorUsed when Override colors mode is enabledOrange

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.
info

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.


Reflection Probe and lighting Required

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.

  1. Default Thin Film – standard iridescence with medium film thickness Example 1

Image

  1. Noisy Iridescence – uses a noise texture to create varying thickness across the surface Example 2

Image

  1. Dual Color Mode – center/edge color override for a stylized effect Example 3

Image

  1. Overlay Variant – combines overlay texture with iridescence Example 4

Image

The Thin Film Fresnel Demo prefab contains all 4 examples. Simply drag it into your scene.