Blitz3D+ Command Reference

BrushIridescence brush,factor#[,ior#][,minimum_thickness#][,maximum_thickness#]

Parameters

brush - brush handle

factor# - strength of the effect from 0 (none) to 1 (full)

ior# (optional) - index of refraction of the thin film; 1.3 (default)

minimum_thickness# (optional) - thinnest film in nanometres; 100 (default)

maximum_thickness# (optional) - thickest film in nanometres; 400 (default)

Description

Adds soap-bubble colour shifts to a Standard material.

Iridescence is the shifting rainbow tint you see on soap bubbles, oil on a wet road, beetle shells and the back of a CD. It comes from light interfering inside a microscopically thin film, so the colour changes with viewing angle - which is exactly what this approximation reproduces.

The thickness range, in nanometres, chooses which colours appear: a narrow range gives a consistent tint, a wide range cycles through more of the rainbow. The film's IOR shifts the palette. Set factor 0 to remove the layer.

Imported glTF models with the KHR_materials_iridescence extension arrive with this layer already set. Calling this command attaches the Standard material to the brush automatically.

Requires Extended mode.

See also: BrushClearcoat, BrushAnisotropy, BrushPBR, BrushStandard.

Example

; BrushIridescence Example
; ------------------------
; Requires Extended mode.

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,0,-5

light=CreateLight()
RotateEntity light,35,-30,0

; A smooth dark sphere shows the thin-film colours well
brush=CreateStandardBrush(70,90,130)
BrushPBR brush,0,0.2
sphere=CreateSphere(32)

factor#=1.0
max_thickness#=500

While Not KeyDown(1)

    ; Press [ / ] to change the iridescence factor
    If KeyDown(26) And factor>0 Then factor=factor-0.01
    If KeyDown(27) And factor<1 Then factor=factor+0.01

    ; Press Z / X to change the maximum film thickness (nanometres)
    If KeyDown(44) And max_thickness>100 Then max_thickness=max_thickness-5
    If KeyDown(45) And max_thickness<800 Then max_thickness=max_thickness+5

    ; Add the soap-bubble film and repaint the sphere
    BrushIridescence brush,factor,1.3,100,max_thickness
    PaintEntity sphere,brush

    ; Arrow keys move the camera - the colours shift with view angle
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Color 255,255,255
    Text 0,0,"[ / ] : factor   Z / X : max thickness   Arrow keys: move camera   Esc: exit"
    Text 0,20,"BrushIridescence brush,"+factor+",1.3,100,"+max_thickness

    Flip

Wend

FreeBrush brush
End

Index