luv

Workshop wiki

cat-shaders.lisp

luvcraft/agent/cat-shaders.lisp

system luvcraft/agent-bodies · 22 definitions · on GitHub

The cat agent's analytic body. Like the gnome, a conservative billboard only launches rays; the visible animal is the zero set of this field.

in-package#:luvcraft.shaders
defparameter*cat-stature*0.82"World cells per cat figure unit; the sitting cat is 1.30 units high."
defparameter*cat-head-size*0.285"The cat's head radius in figure units."
defparameter*cat-ear-height*1.31"How high the ear tips stand above the cat's paws, in figure units."
defparameter*cat-tail-reach*0.54"How far the question-mark tail sweeps out from the cat's side."
defparameter*cat-eye-size*0.13"The angular radius of the cat's green eyes on its head."
defparameter*cat-stripe-frequency*31.0"The tabby coat's vertical stripe frequency in figure space."
defparameter*cat-stripe-strength*0.72"How strongly the tabby stripes darken the orange coat."
defparameter*cat-rim-light*0.11"The warm edge light separating the cat from the world behind it."
macrolet
define-cat-knob
nameplacequantityminimummaximumstepdocumentation
`
luvcraft:define-knob,name
:group:cat:quantity
:quantity,quantity:unit,
if
eqquantity:figure-extent
:cell:one
:minimum,minimum:maximum,maximum:step,step:documentation,documentation
,place
define-cat-knobcat-stature*cat-stature*:figure-proportion0.451.400.025"The cat agent's scale in world cells per figure unit."
define-cat-knobcat-head-size*cat-head-size*:figure-extent0.180.450.005"The radius of the cat's head."
define-cat-knobcat-ear-height*cat-ear-height*:figure-extent1.081.750.01"The height of the cat's pointed ear tips."
define-cat-knobcat-tail-reach*cat-tail-reach*:figure-extent0.320.900.01"How far the cat's curled tail reaches to the side."
define-cat-knobcat-eye-size*cat-eye-size*:figure-proportion0.070.220.005"The angular radius of the cat's green eyes."
define-cat-knobcat-stripe-frequency*cat-stripe-frequency*:figure-proportion8.052.01.0"How many narrow tabby bands cross the cat's coat."
define-cat-knobcat-stripe-strength*cat-stripe-strength*:figure-proportion0.01.00.025"How darkly the tabby bands mark the orange coat."
define-cat-knobcat-rim-light*cat-rim-light*:figure-proportion0.00.60.01"Warm outline around the cat's SDF silhouette."
define-shader-functioncat-capsule-distance
pointbeginningendradius
"Signed distance to the round segment from BEGINNING to END."
let*
offset
-pointbeginning
axis
-endbeginning
fraction
-
gnome-length
-offset
*axisfraction
radius
define-shader-functioncat-body-distance
point
"The sitting torso, chest, and paired haunches."
let*
torso
gnome-ellipsoid-distancepoint
vec30.00.52-0.06
vec30.310.430.28
chest
gnome-ellipsoid-distancepoint
vec30.00.520.17
vec30.230.340.19
mirrored
vec3
abs
swizzlepoint:x
swizzlepoint:y
swizzlepoint:z
haunch
gnome-ellipsoid-distancemirrored
vec30.240.28-0.10
vec30.250.270.28
gnome-smooth-union
gnome-smooth-uniontorsochest0.10
haunch0.09
define-shader-functioncat-head-distance
point
"The cat's round head."
gnome-ellipsoid-distancepoint
vec30.00.940.08
vec3cat-head-size
*cat-head-size0.8947368
*cat-head-size0.9298246
define-shader-functioncat-ear-distance
point
"Two compact tapered ears, mirrored around the face."
let*
ear-point
vec3
-
abs
swizzlepoint:x
0.17
swizzlepoint:y
-
swizzlepoint:z
0.045
gnome-round-cone-distanceear-point1.03cat-ear-height0.1350.012
define-shader-functioncat-muzzle-distance
point
"The paired pale pads and small chin projecting from the face."
let*
mirrored
vec3
abs
swizzlepoint:x
swizzlepoint:y
swizzlepoint:z
pad
gnome-ellipsoid-distancemirrored
vec30.0850.8650.285
vec30.1150.090.105
chin
gnome-ellipsoid-distancepoint
vec30.00.800.245
vec30.110.0750.09
gnome-smooth-unionpadchin0.035
define-shader-functioncat-paw-distance
point
"Two front paws planted together in front of the sitting body."
let*
mirrored
vec3
abs
swizzlepoint:x
swizzlepoint:y
swizzlepoint:z
gnome-ellipsoid-distancemirrored
vec30.1350.1050.205
vec30.1250.120.20
define-shader-functioncat-tail-distance
point
"A three-segment question-mark tail rising along the cat's left side."
let*
lower
cat-capsule-distancepoint
vec3-0.240.24-0.14
vec3
-cat-tail-reach
0.35-0.10
0.075
middle
cat-capsule-distancepoint
vec3
-cat-tail-reach
0.35-0.10
vec3
-cat-tail-reach
0.67-0.04
0.072
tip
cat-capsule-distancepoint
vec3
-cat-tail-reach
0.67-0.04
vec3
-
*cat-tail-reach0.74
0.860.04
0.068
define-shader-functioncat-distance
point
"The complete sitting cat, with soft joins but distinct silhouette parts."
define-shader-functioncat-normal
point
"The cat field's tetrahedral four-sample gradient."
let*
reach0.0015
a
vec31.0-1.0-1.0
b
vec3-1.0-1.01.0
c
vec3-1.01.0-1.0
d
vec31.01.01.0
normalize
+
+
*a
cat-distance
+point
*areach
*b
cat-distance
+point
*breach
+
*c
cat-distance
+point
*creach
*d
cat-distance
+point
*dreach
define-shader-functioncat-face-detail
pointalbedohead-weight
"Paint green eyes, slit pupils, and a rose nose onto the head surface."
let*
mirrored
vec3
abs
swizzlepoint:x
swizzlepoint:y
swizzlepoint:z
direction
normalize
-mirrored
vec30.00.940.08
eye-direction
normalize
vec30.390.160.86
eye-offset
-directioneye-direction
eye-distance
gnome-length
*eye-offset
vec30.801.150.80
eye
-1.0
smoothstep
-cat-eye-size0.025
+cat-eye-size0.025
eye-distance
pupil-distance
gnome-length
*eye-offset
vec33.40.820.82
pupil
-1.0
smoothstep
*cat-eye-size0.46
*cat-eye-size0.73
pupil-distance
glint
gnome-sphere-distancedirection
normalize
vec30.340.220.90
0.035
glint-mask
-1.0
smoothstep0.00.025glint
nose-direction
normalize
vec30.0-0.280.96
nose-distance
gnome-length
*
-directionnose-direction
vec30.651.550.80
nose
-1.0
smoothstep0.0850.125nose-distance
eyed
mixalbedo
vec30.310.680.30
*eyehead-weight
pupilled
mixeyed
vec30.0150.0120.010
*pupilhead-weight
lit
mixpupilled
vec30.950.980.86
*glint-mask
*eyehead-weight
nosed
mixlit
vec30.720.240.25
*nosehead-weight
nosed
define-shader-functioncat-albedo
point
"A warm tabby coat with pale chest, muzzle, and toes."
let*
grain
-
lattice-noise
*point
vec322.018.022.0
0.5
stripe-wave
sin
+
*
swizzlepoint:y
cat-stripe-frequency
*
swizzlepoint:x
*cat-stripe-frequency0.2580645
stripe
smoothstep0.480.88stripe-wave
coat
*
mix
vec30.480.170.045
vec30.160.0550.025
*stripecat-stripe-strength
+1.0
*grain0.18
cream
vec30.780.610.37
ear-color
vec30.580.190.16
near-head
stepheadbody
color-1
mixcoatcoatnear-head
distance-1
minbodyhead
near-ear
stepearsdistance-1
color-2
mixcolor-1ear-colornear-ear
distance-2
mindistance-1ears
near-muzzle
stepmuzzledistance-2
color-3
mixcolor-2creamnear-muzzle
distance-3
mindistance-2muzzle
near-paws
steppawsdistance-3
color-4
mixcolor-3creamnear-paws
distance-4
mindistance-3paws
near-tail
steptaildistance-4
color-5
mixcolor-4coatnear-tail
head-weight
-1.0
smoothstep0.00.040
-head
min
minbodyears
minmuzzle
minpawstail
cat-face-detailpointcolor-5head-weight
define-shader-functioncat-shaded-color
pointraysidewaysfacingsun-directionsun-colorambientcoverage
"Shade one confirmed cat surface hit behind the billboard hit guard."
let*
local-normal
normal
+
*sideways
swizzlelocal-normal:x
+
vec30.0
swizzlelocal-normal:y
0.0
*facing
swizzlelocal-normal:z
albedo
lambert
dotnormalsun-direction
wrapped
max0.0
/
+lambert0.38
1.38
sky
+0.56
*0.44
swizzlenormal:y
occlusion
clamp
+0.38
*0.62
smoothstep-0.080.42
swizzlepoint:y
0.381.0
view-facing
max0.0
dotnormal
*ray-1.0
rim
expt
-1.0view-facing
3.5
halfway
normalize
-sun-directionray
specular
*0.18
expt
max0.0
dotnormalhalfway
34.0
illumination
+
*ambient
*skyocclusion
*sun-color
+0.12
*wrapped1.12
radiance
+
+
*albedoillumination
*sun-color
*specularcoverage
*
vec30.950.630.32
*rimcat-rim-light
vec4
*radiancecoverage
coverage
define-shader-methodshader-specification-forcat-sdf-vertex-specification
role
eql:cat-sdf
stage
eql:vertex
:stage:vertex:inputs
quad-corner:vec3:location0
sphere-center-radius:vec4:location1
figure-facing:vec4:location2
:outputs
clip-position:vec4:built-in:position
proxy-world-position:vec3:location0
sphere-output:vec4:location1
facing-output:vec3:location2
:resources
frame-state:uniform-block:set0:binding2:members#.*frame-uniform-members*
let*
center
swizzlesphere-center-radius:xyz
radius
swizzlesphere-center-radius:w
camera
representation
swizzlecamera-vector:xyz
right
representation
swizzleright-vector:xyz
up
forward
representation
swizzleforward-vector:xyz
corner-x
-
*
swizzlequad-corner:x
2.0
1.0
corner-y
-
*
swizzlequad-corner:y
2.0
1.0
world-position
+center
+
*right
*corner-xradius
*up
*corner-yradius
relative
view-x
dotrelativeright
view-y
dotrelativeup
view-z
dotrelativeforward
x-scale
representation
swizzleprojection-vector:x
y-scale
representation
swizzleprojection-vector:y
z-scale
representation
swizzleprojection-vector:z
z-offset
representation
swizzleprojection-vector:w
set-outputclip-position
vec4
*view-xx-scale
-
*view-yy-scale
+
*view-zz-scale
z-offset
view-z
set-outputproxy-world-positionworld-position
set-outputsphere-outputsphere-center-radius
set-outputfacing-output
swizzlefigure-facing:xyz
define-shader-methodshader-specification-forcat-sdf-fragment-specification
role
eql:cat-sdf
stage
eql:fragment
:stage:fragment:inputs
proxy-world-position:vec3:location0
sphere-input:vec4:location1
facing-input:vec3:location2
:outputs
color-output:vec4:location0
:resources
frame-state:uniform-block:set0:binding2:members#.*frame-uniform-members*
let*
camera
representation
swizzlecamera-vector:xyz
center
swizzlesphere-input:xyz
radius
swizzlesphere-input:w
ray
normalize
-proxy-world-positioncamera
toward-eye
-cameracenter
facing
normalizefacing-input
sideways
vec3
swizzlefacing:z
0.0
-
swizzlefacing:x
local-camera
vec3
/
dottoward-eyesideways
cat-stature
+0.64
/
dottoward-eyefacing
cat-stature
local-ray
vec3
dotraysideways
swizzleray:y
dotrayfacing
figure-radius
to-center
-local-camera
vec30.00.640.0
half-way
-
dotto-centerlocal-ray
gap
-
dotto-centerto-center
*figure-radiusfigure-radius
discriminant
-
*half-wayhalf-way
gap
span
sqrt
maxdiscriminant0.0
entry
max
-half-wayspan
0.0
exit
+half-wayspan
initial-point
+local-camera
*local-rayentry
initial-distance
cat-distanceinitial-point
initial-state
vec3entryinitial-distance
max
-1.0
step0.0008initial-distance
step0.000001
-entryexit
march-state
counted-fold
march68.0stateinitial-state:until
>
swizzlestate:z
0.5
let*
next-distance
next-point
+local-camera
*local-raynext-distance
next-surface-distance
cat-distancenext-point
vec3next-distancenext-surface-distance
max
-1.0
step0.0008next-surface-distance
step0.000001
-next-distanceexit
travel
swizzlemarch-state:x
point
+local-camera
*local-raytravel
surface-distance
swizzlemarch-state:y
coverage
*
-1.0
step0.0035surface-distance
-1.0
step0.0
-discriminant
set-outputcolor-output
vec40.00.00.00.0
when
>coverage0.0
set-outputcolor-output
cat-shaded-colorpointraysidewaysfacing
representation
swizzlesun-vector:xyz
representation
swizzlesun-color-vector:xyz
representation
swizzleambient-vector:xyz
coverage