Blitz3D+ Command Reference

ShadowColor red#,green#,blue#,strength#

Parameters

red#, green#, blue# - shadow tint from 0 to 255; black (default)

strength# - maximum darkening from 0.0 to 1.0, clamped; 0.65 (default)

Description

Sets the colour and darkness of automatic shadows.

This is the artistic control. The default - black at strength 0.65 - removes 65 percent of the shadowed light for a natural look. Push strength towards 1 for harsh noon-desert shadows, or ease it down for the soft look of an overcast day. The tint colours what remains: a touch of deep blue reads as cool outdoor skylight, warm brown suits a lantern-lit interior.

Only direct light from the selected light is darkened - AmbientLight, image-based lighting and emissive surfaces are untouched. That is why shadows never crush to pure black at strength 1 unless your ambient light is very low; balance the two together when setting a scene's mood.

The setting is global to the world. Shadows must be enabled for it to show - see the chain on the Shadows page.

Requires Extended mode.

See also: Shadows, ShadowBias, EntityShadows, AmbientLight.

Example

; ShadowColor Example
; -------------------
; Requires Extended mode.

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

camera=CreateCamera()
PositionEntity camera,0,5,-9
RotateEntity camera,25,0,0

; A directional sun; the shadow system selects it automatically
sun=CreateLight(1)
AmbientLight 70,75,85

; Bright sandy ground so the shadow tint is easy to see
ground=CreateCube()
ScaleEntity ground,10,0.1,10
PositionEntity ground,0,-0.1,4
EntityColor ground,220,205,170

; A crate and a pillar to cast shadows
crate=CreateCube()
PositionEntity crate,-2.5,1,4
EntityColor crate,210,150,80

pillar=CreateCylinder()
ScaleEntity pillar,0.7,2,0.7
PositionEntity pillar,2.5,2,5
EntityColor pillar,120,160,220

; Turn on the automatic shadow system
Shadows 1

; Default tint is black at strength 0.65
red#=0
green#=0
blue#=0
strength#=0.65
mood$="1 classic black"
angle#=0

While Not KeyDown(1)

    ; Number keys pick an artistic tint; [ / ] set the darkness
    If KeyHit(2) Then
        red=0
        green=0
        blue=0
        mood="1 classic black"
    EndIf
    If KeyHit(3) Then
        red=30
        green=45
        blue=90
        mood="2 cool night blue"
    EndIf
    If KeyHit(4) Then
        red=90
        green=55
        blue=25
        mood="3 warm sepia"
    EndIf
    If KeyHit(5) Then
        red=110
        green=20
        blue=110
        mood="4 alien purple"
    EndIf
    If KeyDown(26) And strength>0 Then strength=strength-0.01
    If KeyDown(27) And strength<1 Then strength=strength+0.01

    ; Tint the shadows and set their maximum darkness
    ShadowColor red,green,blue,strength

    ; Swing the sun so the tinted shadows sweep the ground
    angle=angle+0.3
    RotateEntity sun,55,angle,0

    TurnEntity crate,0,1,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

    Text 0,0,"1-4: tint preset   [ ]: strength   Arrow keys: move camera   Esc: exit"
    Text 0,20,"ShadowColor "+red+","+green+","+blue+","+strength
    Text 0,40,"Preset: "+mood

    Flip

Wend

End

Index