Blitz3D+ Command Reference

BrushTransmission brush,factor#[,ior#]

Parameters

brush - brush handle

factor# - how much light passes through, from 0 (opaque) to 1 (fully transmissive)

ior# (optional) - index of refraction, from 1 to 3; 1.5 (default). At 1 there is no dielectric interface reflection or bend.

Description

Makes a Standard material show the opaque scene through a glass-like surface.

Use transmission for windows, bottles, ice and display cases. Transmission controls the share of light passing through the material; brush alpha controls surface coverage independently. Leave alpha at 1 for a solid glass pane. The captured background keeps its existing lighting, while the surface adds its own reflection and highlights. The default IOR of 1.5 is typical glass; water is about 1.33.

Use BrushVolume with a positive thickness to bend the image and optionally absorb light. Thickness 0 leaves the background undistorted and unabsorbed. Thickness is an authored optical distance, not a measurement through the mesh.

The refracted image comes from a capture taken before transparent objects. Overlapping glass uses that same opaque image; glass and other transparent objects cannot refract one another. Objects outside the current view cannot appear in the refraction. Distortion that reaches a foreground object or leaves the viewport falls back to the undistorted background. This is a screen-space approximation, with no ray-traced interior or frosted-glass blur.

Set factor 0 to switch the layer off again. While a brush's transmission is 0 the renderer skips the scene-capture cost entirely, so opaque Standard brushes pay nothing for this feature. Add BrushVolume for coloured, thickness-based absorption. Imported glTF models using KHR_materials_transmission and KHR_materials_ior arrive with this set. Calling this command attaches the Standard material automatically.

Requires Extended mode.

See also: BrushVolume, BrushPBR, BrushAlphaMode, BrushStandard.

Example

; BrushTransmission 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

; Striped panels behind the sphere make refraction easy to see
For stripe=0 To 8
    panel=CreateCube()
    ScaleEntity panel,0.25,1.5,0.08
    PositionEntity panel,(stripe-4)*0.6,0,3
    If stripe Mod 2 Then EntityColor panel,30,115,230 Else EntityColor panel,245,100,35
Next

; A pale glass sphere
brush=CreateStandardBrush(220,245,255)
; An authored optical distance makes the IOR control visibly bend the stripes.
BrushVolume brush,0.8,0
sphere=CreateSphere(32)

transmission#=0.9
ior#=1.5

While Not KeyDown(1)

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

    ; Press Z / X to change the index of refraction
    If KeyDown(44) And ior>1 Then ior=ior-0.01
    If KeyDown(45) And ior<2.5 Then ior=ior+0.01

    ; Make the sphere transmit the scene behind it and repaint
    BrushTransmission brush,transmission,ior
    PaintEntity sphere,brush

    ; Arrow keys move the camera
    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,"[ / ] : transmission   Z / X : ior   Arrow keys: move camera   Esc: exit"
    Text 0,20,"BrushTransmission brush,"+transmission+","+ior

    Flip

Wend

FreeBrush brush
End

Index