luv

Workshop wiki

lighting.lisp

luft/render/lighting.lisp

system luft/renderer · 5 definitions · on GitHub

in-package#:luft.render

Lighting has identity at the frame boundary. The shader sees only the dense lanes packed from this object once per frame; fragments do not carry objects or dispatch through the lighting vocabulary.

defparameter+shadow-map-size+1024"Resolution of LUFT's single sun-shadow map."
defclasslight
name:initarg:name:readerlight-name
sun-direction:initarg:sun-direction:readerlight-sun-direction
sun-color:initarg:sun-color:readerlight-sun-color
sky-color:initarg:sky-color:readerlight-sky-color
ground-color:initarg:ground-color:readerlight-ground-color
shadow-half-extent:initarg:shadow-half-extent:readerlight-shadow-half-extent
shadow-depth-radius:initarg:shadow-depth-radius:readerlight-shadow-depth-radius
shadow-base-bias:initarg:shadow-base-bias:readerlight-shadow-base-bias
shadow-filter-radius:initarg:shadow-filter-radius:readerlight-shadow-filter-radius
:documentation

One inspectable environment light, packed into raw per-frame GPU lanes.

defvar*light*nil
setf*light*
ensure-semantic-instance*light*'light:name:late-afternoon:sun-direction:sun-color
2.451.300.480.92
:sky-color
0.330.521.021.0
:ground-color
0.500.240.321.0
:shadow-half-extent96.0:shadow-depth-radius160.0:shadow-base-bias0.00075:shadow-filter-radius5.0
defunlight-shadow-rows
lightcenter

Return a texel-stable orthographic world-to-shadow transform.

The first two rows map the square light plane to clip [-1,1]. The third maps the signed light depth around center to [0,1]. center is snapped in the light plane so camera translation cannot slide a shadow edge by a fraction of a texel.

let*
sun
light-sun-directionlight
forward
world-up
up
vec3:vec3-crossforwardright
extent
light-shadow-half-extentlight
depth-radius
light-shadow-depth-radiuslight
world-units-per-texel
center-right
*
round
/
vec3:vec3-dotcenterright
world-units-per-texel
world-units-per-texel
center-up
*
round
/world-units-per-texel
world-units-per-texel
center-forward
vec3:vec3-dotcenterforward
flet
row
axisscaleoffset
list
*
vec3:vec3-xaxis
scale
*
vec3:vec3-yaxis
scale
*
vec3:vec3-zaxis
scale
offset
append
rowright
/extent
-
/center-rightextent
rowup
/extent
-
/center-upextent
rowforward
/
*2.0depth-radius
-0.5
/center-forward
*2.0depth-radius
'
0.00.00.01.0
defunlight-uniform-data
lightcenter&optional

Return light's nine vec4 lanes for the frame uniform ABI.

flet
vec3-lane
valuefourth
list
vec3:vec3-xvalue
vec3:vec3-yvalue
vec3:vec3-zvalue
fourth
append
vec3-lane
light-sun-directionlight
0.0
coerce
light-sun-colorlight
'list
list
aref
light-sky-colorlight
0
aref
light-sky-colorlight
1
aref
light-sky-colorlight
2
exposure
coerce
light-ground-colorlight
'list
list
light-shadow-base-biaslight
light-shadow-filter-radiuslight