Blitz3D+ Command Reference

CreateSkyBox ( texture[,parent] )

Parameters

texture - 2:1 equirectangular sky image

parent (optional) - parent entity

Description

Creates a sky that surrounds the whole scene.

Give it an ordinary 2:1 equirectangular panorama and it draws behind everything else, effectively at infinite distance - moving the camera never brings the sky closer. It renders full-bright, ignores fog, and neither casts nor receives shadows, so it behaves like a backdrop should without any extra setup.

It is still a normal entity: rotate it with RotateEntity for a drifting or day-cycle sky, swap its image with SkyBoxTexture, dim it with SkyBoxIntensity, and remove it with FreeEntity.

The sky is display only. For the scene's materials to be lit and to reflect the same panorama, also pass the texture to BrushEnvironmentMap on your Standard brushes - the two are deliberately independent. An invalid texture raises a runtime error.

For the full story, see environments and skyboxes in the shader guide.

Requires Extended mode.

See also: SkyBoxTexture, SkyBoxIntensity, BrushEnvironmentMap, FreeEntity.

Example

; CreateSkyBox Example
; --------------------
; Requires Extended mode.

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

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

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

; Draw a tiny 2:1 equirectangular sky: gradient, horizon and sun
sky_texture=CreateTexture(128,64,1+8+32)
SetBuffer TextureBuffer(sky_texture)
For y=0 To 63
    Color 30+y*2,80+y,180+y
    Line 0,y,127,y
Next
Color 255,235,150
Oval 90,8,14,14,True
SetBuffer BackBuffer()

; Wrap the image around the whole scene
sky=CreateSkyBox(sky_texture)

; A ground slab shows that the sky sits behind everything
ground=CreateCube()
ScaleEntity ground,4,0.1,4
PositionEntity ground,0,-1,2
EntityColor ground,60,110,50

While Not KeyDown(1)

    ; Drift the sky slowly - a skybox rotates like any entity
    TurnEntity sky,0,0.03,0

    ; Arrow keys move the camera - look around to see the sky follow
    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,"Arrow keys: move camera   Esc: exit"
    Text 0,20,"sky=CreateSkyBox(sky_texture)   The sky follows the camera"

    Flip

Wend

End

Index