luv

Workshop wiki

paint.lisp

mcclim/paint.lisp

system luv/mcclim · 27 definitions · on GitHub

Paint designs evaluated by the direct McCLIM GPU backend.

in-package#:mcluv
defclassrelief-design
design
albedo:initarg:albedo:readerrelief-albedo
height:initarg:height:readerrelief-height
:documentation

A paint carrying signed height above its presentation surface.

Positive heights are raised and negative heights are recessed. Ordinary McCLIM backends see ALBEDO; relief-aware backends may render the height.

defunmake-relief-design
albedoheight
check-typealbedodesign
check-typeheightreal
make-instance'relief-design:albedoalbedo:heightheight
defgenericdesign-height
design
:documentation

Return design's signed displacement in surface units.

defmethoddesign-height
designdesign
declare
ignoredesign
0
defmethoddesign-height
relief-heightdesign
defmethoddesign-ink
design-ink
relief-albedodesign
xy
defmethodtransform-region
transformation
make-relief-design
transform-regiontransformation
relief-albedodesign
relief-heightdesign
defclassgradient-design
design
start-color:initarg:start-color:readergradient-start-color
end-color:initarg:end-color:readergradient-end-color
:documentation

A two-stop analytical paint. Geometry and paint remain independent.

defclasslinear-gradient
x1:initarg:x1:readerlinear-gradient-x1
y1:initarg:y1:readerlinear-gradient-y1
x2:initarg:x2:readerlinear-gradient-x2
y2:initarg:y2:readerlinear-gradient-y2
defclassradial-gradient
center-x:initarg:center-x:readerradial-gradient-center-x
center-y:initarg:center-y:readerradial-gradient-center-y
radius:initarg:radius:readerradial-gradient-radius
defunmake-linear-gradient
x1y1x2y2start-colorend-color
make-instance'linear-gradient:x1x1:y1y1:x2x2:y2y2:start-colorstart-color:end-colorend-color
defunmake-radial-gradient
center-xcenter-yradiusstart-colorend-color
check-typeradius
real0*
make-instance'radial-gradient:center-xcenter-x:center-ycenter-y:radiusradius:start-colorstart-color:end-colorend-color
defunclamp-unit
value
min1.0
max0.0value
defgenericgradient-coordinate
gradientxy
:documentation

Return gradient's normalized coordinate at X,Y.

defmethodgradient-coordinate
xy
let*
dx
-
linear-gradient-x2gradient
linear-gradient-x1gradient
dy
-
linear-gradient-y2gradient
linear-gradient-y1gradient
length-squared
+
*dxdx
*dydy
if
zeroplength-squared
0.0
/
+
*
-x
linear-gradient-x1gradient
dx
*
-y
linear-gradient-y1gradient
dy
length-squared
defmethodgradient-coordinate
xy
let
radius
radial-gradient-radiusgradient
if
zeropradius
1.0
/
sqrt
+
expt
-x
radial-gradient-center-xgradient
2
expt
-y
radial-gradient-center-ygradient
2
radius
defgenericgradient-render-coordinate
gradientxy
:documentation

Return two interpolable shader coordinates and the gradient kind lane.

defmethodgradient-render-coordinate
xy
values0.00.0
defmethodgradient-render-coordinate
xy
let
radius
radial-gradient-radiusgradient
if
zeropradius
values1.00.01.0
values
/
-x
radial-gradient-center-xgradient
radius
/
-y
radial-gradient-center-ygradient
radius
1.0
defuninterpolate-gradient-ink
gradientcoordinate
let
amount
clamp-unitcoordinate
multiple-value-bind
r1g1b1a1
color-rgba
gradient-start-colorgradient
multiple-value-bind
r2g2b2a2
color-rgba
gradient-end-colorgradient
let
color
make-rgb-color
+r1
*amount
-r2r1
+g1
*amount
-g2g1
+b1
*amount
-b2b1
alpha
+a1
*amount
-a2a1
compose-incolor
make-opacityalpha
shader:define-shaderrelief-roundrect-vertex-specification
:stage:vertex:inputs
position:vec3:location0
local-coordinate:vec3:location1
half-size-radius:vec3:location2
color:vec3:location3
relief:vec3:location4
:outputs
clip-position:vec4:built-in:position
render-coordinate:vec2:location0
render-half-size-radius:vec3:location1
render-color:vec4:location2
render-height:float:location3
let*
shader:set-outputclip-position
shader:set-outputrender-coordinate
shader:swizzlelocal-coordinate:xy
shader:set-outputrender-half-size-radiushalf-size-radius
shader:set-outputrender-color
shader:vec4
*coloralpha
alpha
shader:set-outputrender-height
shader:define-shaderrelief-roundrect-fragment-specification
:stage:fragment:inputs
render-coordinate:vec2:location0
half-size-radius:vec3:location1
color:vec4:location2
height:float:location3
:outputs
color-output:vec4:location0
let*
distance
luv.analytic:roundrect-signed-distance
shader:swizzlerender-coordinate:x
shader:swizzlerender-coordinate:y
shader:swizzlehalf-size-radius:x
shader:swizzlehalf-size-radius:y
shader:swizzlehalf-size-radius:z
normal-length
max
sqrt
+
*distance-dxdistance-dx
*distance-dydistance-dy
/1.065536.0
edge-light
*-0.70710678
+
/distance-dxnormal-length
/distance-dynormal-length
absolute-height
rim-width
max1.0absolute-height
rim
shader:clamp
+1.0
/distancerim-width
0.01.0
direction
strength
shader:clamp
*absolute-height0.055
0.00.36
shade
+1.0
*edge-lightrimdirectionstrength
coverage
luv.analytic:roundrect-coveragerender-coordinatehalf-size-radius
shader:set-outputcolor-output
*coverage
shader:define-shadergradient-roundrect-vertex-specification
:stage:vertex:inputs
position:vec3:location0
local-coordinate:vec3:location1
half-size-radius:vec3:location2
paint-coordinate-kind:vec3:location3
start-color:vec3:location4
end-color:vec3:location5
paint-alphas:vec3:location6
:outputs
clip-position:vec4:built-in:position
render-coordinate:vec2:location0
render-half-size-radius:vec3:location1
render-paint-coordinate-kind:vec3:location2
render-start-color:vec3:location3
render-end-color:vec3:location4
render-paint-alphas:vec2:location5
let*
shader:set-outputclip-position
shader:set-outputrender-coordinate
shader:swizzlelocal-coordinate:xy
shader:set-outputrender-half-size-radiushalf-size-radius
shader:set-outputrender-paint-coordinate-kindpaint-coordinate-kind
shader:set-outputrender-start-colorstart-color
shader:set-outputrender-end-colorend-color
shader:set-outputrender-paint-alphas
shader:swizzlepaint-alphas:xy
shader:define-shadergradient-roundrect-fragment-specification
:stage:fragment:inputs
render-coordinate:vec2:location0
half-size-radius:vec3:location1
paint-coordinate-kind:vec3:location2
start-color:vec3:location3
end-color:vec3:location4
paint-alphas:vec2:location5
:outputs
color-output:vec4:location0
let*
paint-coordinate
shader:swizzlepaint-coordinate-kind:xy
kind
shader:swizzlepaint-coordinate-kind:z
linear-coordinate
shader:swizzlepaint-coordinate:x
radial-coordinate
sqrt
shader:dotpaint-coordinatepaint-coordinate
amount
shader:clamp
shader:mixlinear-coordinateradial-coordinate
0.01.0
alpha
shader:mix
shader:swizzlepaint-alphas:x
shader:swizzlepaint-alphas:y
amount
rgb
shader:mixstart-colorend-coloramount
coverage
shader:mix
luv.analytic:roundrect-coveragerender-coordinatehalf-size-radius
1.0
-1.0
shader:step-0.5
shader:swizzlehalf-size-radius:z
shader:set-outputcolor-output
*
shader:vec4
*rgbalpha
alpha
coverage
shader:define-shaderimage-roundrect-vertex-specification
:stage:vertex:inputs
position:vec3:location0
local-coordinate:vec3:location1
half-size-radius:vec3:location2
texture-coordinate-opacity:vec3:location3
:outputs
clip-position:vec4:built-in:position
render-coordinate:vec2:location0
render-half-size-radius:vec3:location1
render-texture-coordinate:vec2:location2
render-opacity:float:location3
let*
shader:set-outputclip-position
shader:set-outputrender-coordinate
shader:swizzlelocal-coordinate:xy
shader:set-outputrender-half-size-radiushalf-size-radius
shader:set-outputrender-texture-coordinate
shader:swizzletexture-coordinate-opacity:xy
shader:set-outputrender-opacity
shader:swizzletexture-coordinate-opacity:z
shader:define-shaderimage-roundrect-fragment-specification
:stage:fragment:inputs
render-coordinate:vec2:location0
half-size-radius:vec3:location1
texture-coordinate:vec2:location2
opacity:float:location3
:resources
image:texture-2d:binding0:sample-transfer:identity
texture-sampler:sampler:binding1
:outputs
color-output:vec4:location0
let*
u
shader:swizzletexture-coordinate:x
v
shader:swizzletexture-coordinate:y
inside-texture
texel
shader:sampleimagetexture-samplertexture-coordinate
coverage
shader:mix
luv.analytic:roundrect-coveragerender-coordinatehalf-size-radius
1.0
-1.0
shader:step-0.5
shader:swizzlehalf-size-radius:z
covered-alpha
*alphacoverageinside-texture

McCLIM image arrays store straight rgb and alpha. The render target's blend contract is premultiplied, exactly like the solid paint path.

shader:set-outputcolor-output
shader:vec4
*covered-alpha
covered-alpha