Blitz3D+ Command Reference

BSPLighting bsp,use_lightmaps

Parameters

bsp - BSP entity handle returned by LoadBSP

use_lightmaps - True to light the level with its baked lightmaps (default), False to draw it fullbright

Description

Switches a BSP level's baked lightmap lighting on or off.

A Quake 3 level ships with lightmaps - textures of pre-calculated light and shadow that the renderer multiplies over the level's surfaces. They are what give a BSP its atmosphere, and they are on from the moment LoadBSP returns.

Pass False and the lightmaps are dropped: every surface draws fullbright with just its plain texture, evenly lit everywhere. That is handy in a level editor or debug fly-through where you want to see the raw textures and geometry clearly, without dark corners hiding anything - and it is also the honest "my lightmaps look wrong, what is underneath?" switch. Pass True to restore the baked lighting.

Gotcha: with lightmaps off the level ignores BSPAmbientLight too - fullbright surfaces take no light from anywhere, so the toggle is all-or-nothing.

See also: LoadBSP, BSPAmbientLight, AmbientLight.

Example

; BSPLighting Example
; -------------------

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

camera=CreateCamera()
PositionEntity camera,0,2,-10

light=CreateLight()
RotateEntity light,45,45,0

; BSPLighting needs a loaded BSP level. No .bsp ships with
; Blitz3D+, so supply your own file to see the toggle in action.
bsp=LoadBSP("media/level.bsp",0)
use_lmaps=1

If bsp=0
    ; Honest fallback: a placeholder arena built from primitives
    arena=CreatePlane()
    EntityColor arena,60,70,90
    For i=0 To 7
        pillar=CreateCylinder()
        ScaleEntity pillar,0.6,3,0.6
        PositionEntity pillar,Cos(i*45)*6,3,Sin(i*45)*6
        EntityColor pillar,120,130,160
    Next
EndIf

; A spinning marker so something always moves
marker=CreateSphere()
ScaleEntity marker,0.5,0.5,0.5
PositionEntity marker,0,1,0
EntityColor marker,255,200,0

While Not KeyDown(1)

    ; Space toggles the level's baked lightmaps on and off
    If KeyHit(57)
        If bsp<>0
            use_lmaps=1-use_lmaps
            BSPLighting bsp,use_lmaps
        EndIf
    EndIf

    TurnEntity marker,0,3,0

    ; 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

    If bsp=0
        Text 0,0,"Arrow keys: move camera   Esc: exit"
        Text 0,20,"No BSP file found - BSPLighting is skipped this run."
        Text 0,40,"Copy any Quake 3 .bsp to media/level.bsp and run again"
        Text 0,60,"to toggle its lightmaps with Space."
    Else
        Text 0,0,"Space: toggle lightmaps   Arrows: camera   Esc: exit"
        Text 0,20,"BSPLighting bsp,"+use_lmaps
    EndIf

    Flip

Wend

End

Index