blob: b174240d3d2aa7739880300aff6c329df80d7a9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
len2 v = v%x*v%x + v%y*v%y + v%z*v%z
makeFrame (time :: Float)
(vertexstream :: PrimitiveStream Triangle ((Vec 4 Float)))
= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay`
vertexstream
& mapPrimitives (\((x)) -> (scale 0.5 (projmat *. x), x))
& rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth))
& filterFragments ffilter
& accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
where
h = 0.25
projmat = perspective 0.1 100.0 30.0 1.0
.*. lookat (V3 3.0 1.3 0.3) (V3 0.0 0.0 0.0) (V3 0.0 1.0 0.0)
.*. rotMatrixY (pi / 24.0 * time)
ffilter ((v)) =
(v%y + v%x + v%z > 1 || abs (v%y - v%x + v%z - 1.0) > h)
&& (v%y + v%x - v%z > 1 || abs (v%y + v%x + v%z - 1.0) > h)
&& (v%y - v%x - v%z > 1 || abs (v%y + v%x - v%z - 1.0) > h)
&& (v%y - v%x + v%z > 1 || abs (v%y - v%x - v%z - 1.0) > h)
&& len2 v' > abs (3 * sin (1 * time))
where
v' = sin (v *! 20)
main = renderFrame $
makeFrame (Uniform "Time")
(fetch "stream4" (Attribute "position4"))
|