|
preset (optional) - quality preset 0: off - no shadow maps are rendered 1: low - one 1024 shadow map 2: high - three 2048 cascades (default) 3: ultra - four 4096 cascades |
|
Selects an automatic shadow quality preset for each admitted source. ShadowLightLimit selects how many sources may cast. With several sources, the memory budget can reduce map resolution while preserving complete cascade/face sets. The preset picks shadow map resolution and cascade count in one go - the natural thing to wire to a Low/High/Ultra graphics option. Cascades concentrate resolution near the camera: with three or four of them, close shadows stay sharp while coverage still reaches into the distance, which is why preset 2 and up look so much better outdoors than preset 1's single map. The preset also gates local lights. Spot lights use one map at the preset's resolution. Point lights render six faces per update, so they only cast at preset 2 (1024 per face) or 3 (2048 per face) - at low quality they are excluded from selection rather than silently paying for six maps (see LightShadows). Preset 0 suppresses shadow rendering without touching the global Shadows switch, so an options menu can offer "shadows off" and back without re-running scene setup. Values outside 0 to 3 are clamped. See also: Shadows, ShadowDistance, ShadowBias, LightShadows. |
; ShadowQuality Example
; ---------------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
; Camera close to the action so shadow-edge detail is easy to judge
camera=CreateCamera()
PositionEntity camera,0,3,-5
RotateEntity camera,25,0,0
; A directional sun; the shadow system selects it automatically
sun=CreateLight(1)
AmbientLight 70,75,85
; Ground plane that receives the shadows
ground=CreateCube()
ScaleEntity ground,10,0.1,10
PositionEntity ground,0,-0.1,4
EntityColor ground,190,200,180
; A spiky windmill of thin blades makes crisp, detailed shadows
mill=CreatePivot()
PositionEntity mill,0,2,4
For i=0 To 3
blade=CreateCube(mill)
ScaleEntity blade,2.2,0.15,0.15
RotateEntity blade,0,0,i*45
EntityColor blade,210,150,80
Next
; Turn on the automatic shadow system
Shadows 1
preset=2
angle#=0
While Not KeyDown(1)
; Keys 0-3 select the shadow-map preset
If KeyHit(11) Then preset=0
If KeyHit(2) Then preset=1
If KeyHit(3) Then preset=2
If KeyHit(4) Then preset=3
; Pick the shadow-map resolution preset
ShadowQuality preset
If preset=0 Then label$="maps suppressed"
If preset=1 Then label="1024 map"
If preset=2 Then label="2048 map (default)"
If preset=3 Then label="4096 map"
; Spin the windmill so its blade shadows show edge quality
TurnEntity mill,0,0,0.5
; Swing the sun slowly
angle=angle+0.2
RotateEntity sun,55,angle,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,"0-3: quality preset Arrow keys: move camera Esc: exit"
Text 0,20,"ShadowQuality "+preset+" ("+label+")"
Text 0,40,"Watch the blade shadows sharpen at higher presets"
Flip
Wend
End