EntityLightmapReason$ ( entity )

Parameters

entity - entity handle

Description

Says why an entity takes part in bakes as it does.

The words finish the sentence "because...": "it is static", "it is small", "it moves: it has a dynamic body, collisions or animation", "it is animated", "it glows (fullbright), so it needs no lightmap", "it has hand-made levels of detail", "it is invisible (alpha 0)", "it is drawn behind or over everything (EntityOrder), as skies are", "it is a terrain", or "EntityLightmap set it". Show it in your own level tools beside EntityLightmapMode, as the World Editor does, so a wrong guess is easy to spot before baking.

See also: EntityLightmapMode, EntityLightmap, BakeLighting.

Example

; EntityLightmap Example
; ----------------------

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

camera=CreateCamera()
PositionEntity camera,0,2.5,-5
RotateEntity camera,20,0,0

AmbientLight 10,10,16

; The floor and a red wall are static scenery: they bake into lightmaps
ground=CreateCube()
ScaleEntity ground,3,0.1,3
wall=CreateCube()
ScaleEntity wall,0.1,1.5,3
PositionEntity wall,-2.5,1.5,0
EntityColor wall,230,40,30

; A crate the player can push must not be baked, or its shadow would stay
; behind when it moves: light probes light it instead
crate=CreateCube()
ScaleEntity crate,0.4,0.4,0.4
PositionEntity crate,0,0.5,0
EntityColor crate,200,170,120
EntityLightmap crate,LIGHTMAP_OFF

; A small bolt on the wall casts baked shadows but probes light it
bolt=CreateSphere(8)
ScaleEntity bolt,0.08,0.08,0.08
PositionEntity bolt,-2.35,1.5,-1
EntityLightmap bolt,LIGHTMAP_CONTRIBUTE

; A warm lamp, fully baked, so the crate takes its light from the probes
lamp=CreateLight(2)
PositionEntity lamp,0.5,2.5,0
LightRange lamp,3
LightColor lamp,255,220,170
LightBakeMode lamp,LIGHT_BAKED

; Probes a unit apart through the room, and closer together over the floor,
; where the crate goes
LightProbeSpacing 1
LightProbeVolume 0,0.75,0,6,1.5,6

LightBakeQuality 0
bake=BakeLighting()
While LightBakeState(bake)=LIGHT_BAKE_RUNNING
    RenderWorld
    Text 0,0,"Baking: "+(LightBakeProgress(bake)/10)+"%"
    Flip
Wend
FreeLightBake bake

probes=True

While Not KeyDown(1)

    ; The crate slides to and fro; near the red wall its probes turn it red
    PositionEntity crate,Sin(MilliSecs()/20.0)*1.8,0.5,0

    ; Space switches the crate's probe lighting off and on
    If KeyHit(57) Then
        probes=Not probes
        EntityLightProbes crate,probes
    EndIf

    ; 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: crate's probes on/off   Esc: exit"
    Text 0,20,"Wall: mode "+EntityLightmapMode(wall)+" because "+EntityLightmapReason(wall)
    Text 0,40,"Crate: mode "+EntityLightmapMode(crate)+" because "+EntityLightmapReason(crate)
    Text 0,60,"Bolt: mode "+EntityLightmapMode(bolt)+" because "+EntityLightmapReason(bolt)
    Text 0,80,"EntityLightProbes crate,"+probes

    Flip

Wend

End

Index