CreateReflectionProbe ( [parent] )

Parameters

parent (optional) - entity to attach the probe to; 0 for none (default)

Description

Creates a reflection probe, which bakes record the surroundings of for shiny surfaces.

A probe is a pivot entity: put it in the middle of a room. When the world is baked, it records what can be seen from there, lit by the bake, and Standard materials inside its box (ReflectionProbeBox, 10 units each way to start) reflect it: polished floors, metal and glass then show the room's walls, lamps and windows where they really are. Rougher materials reflect it more blurred. Materials outside every probe's box keep their own environment map.

Free a probe with FreeEntity.

Worlds keep reflection probes too: the World Editor's Reflection tile adds one, and a world loaded with LoadWorldAsync has its probes ready for its bake.

See also: ReflectionProbeBox, BakeLighting, CreateStandardBrush, BrushPBR.

Example

; CreateReflectionProbe Example
; -----------------------------

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

camera=CreateCamera()
PositionEntity camera,0,1.2,-3.2
RotateEntity camera,15,0,0

AmbientLight 20,20,24

; One wall of the hall: a flat box of its own colour
Function Wall(x#,y#,z#,width#,height#,depth#,red,green,blue)
    wall=CreateCube()
    ScaleEntity wall,width/2,height/2,depth/2
    PositionEntity wall,x,y,z
    EntityColor wall,red,green,blue
    Return wall
End Function

Wall -2,1.5,0,0.2,3,6,220,40,30
Wall 2,1.5,0,0.2,3,6,40,200,60
Wall 0,1.5,3,4,3,0.2,220,220,220
Wall 0,3,0,4,0.2,6,220,220,220
panel=Wall(0,2.85,0,1,0.05,1,255,250,235)
EntityFX panel,1

; A polished metal floor, which reflects the hall once it is baked
ground=CreateCube()
ScaleEntity ground,2,0.1,3
PositionEntity ground,0,-0.1,0
metal=CreateStandardBrush(210,210,210)
BrushPBR metal,1,0.15
PaintEntity ground,metal
FreeBrush metal

lamp=CreateLight(2)
PositionEntity lamp,0,2.5,0
LightRange lamp,4
LightBakeMode lamp,LIGHT_BAKED

; The reflection probe sees the hall from its middle; its box is the hall,
; so the floor reflects each wall where it really is
probe=CreateReflectionProbe()
PositionEntity probe,0,1.2,0
ReflectionProbeBox probe,4,3,6

LightBakeQuality 0
bake=BakeLighting()

While Not KeyDown(1)

    If bake<>0 Then
        If LightBakeState(bake)<>LIGHT_BAKE_RUNNING Then
            FreeLightBake bake
            bake=0
        EndIf
    EndIf

    ; Space bakes again; R clears the bake, reflections and all
    If KeyHit(57) And bake=0 Then bake=BakeLighting()
    If KeyHit(19) Then ClearBakedLighting

    ; 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

    Text 0,0,"Arrow keys: move camera   Space: bake   R: clear   Esc: exit"
    If bake<>0 Then
        Text 0,20,"Baking: "+(LightBakeProgress(bake)/10)+"%"
    Else
        Text 0,20,"ReflectionProbeBox probe,4,3,6   ("+BakedLightingStatus()+")"
    EndIf

    Flip

Wend

End

Index