|
probe - reflection probe handle from CreateReflectionProbe width#, height#, depth# - the size of its box, centred on the probe |
|
Sets the box a reflection probe covers. Standard materials inside the box reflect the probe, and the reflection is projected onto the box, so make it the size of the room: a wall then appears in the floor where the wall really is, not where the probe saw it. Where boxes overlap, the smallest wins. It applies at the next bake. See also: CreateReflectionProbe, BakeLighting. |
; 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