summaryrefslogtreecommitdiff
path: root/hello_obj2.lc
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-14 13:32:37 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-14 13:32:37 -0400
commit07ea0fe2a37cab1e549c084f31d231632857b99f (patch)
tree4e884c2cdf509fa10d35842d5853063b7a56d995 /hello_obj2.lc
parent9f99af1750924a0be6e003842830aec93380dfdc (diff)
TextureBuffer-based ring buffer.
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r--hello_obj2.lc32
1 files changed, 32 insertions, 0 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc
index 991c3c2..8e9bbe0 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -19,6 +19,8 @@ makeFrame (cubemap :: TextureCube)
19 (texture :: Texture) 19 (texture :: Texture)
20 (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) 20 (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float))
21 (plane :: PrimitiveStream Triangle ((Vec 4 Float))) 21 (plane :: PrimitiveStream Triangle ((Vec 4 Float)))
22 (pointsMax :: Int)
23 (pointsStart :: Int)
22 24
23 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) 25 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1))
24 `overlay` 26 `overlay`
@@ -43,6 +45,34 @@ makeFrame (cubemap :: TextureCube)
43 r = V4 1 1 1 0 *! (max c%x c%y) 45 r = V4 1 1 1 0 *! (max c%x c%y)
44 in ((r + V4 0 0 0 (0.8)))) 46 in ((r + V4 0 0 0 (0.8))))
45 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) 47 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True))
48 `overlay`
49 zipCount (fetch "Points" ((Attribute "position")) :: PrimitiveStream Point ((Float)))
50 & mapPrimitives (\(n,_) -> {- let nn = 0.2 * fromInt n :: Float
51 p = V4 nn nn nn 1
52 p' = coordmap cam p
53 in (p', V4 1 1 0 1 :: Vec 4 Float)) -}
54 let i = mod (n + pointsStart) pointsMax
55 t = TextureBufferSlot "PointBuffer"
56 p = V4 (textureBuffer t i)
57 (textureBuffer t (i+1))
58 (textureBuffer t (i+2))
59 1
60 p' = coordmap cam p
61 in (p', V4 1 1 0 1 :: Vec 4 Float))
62
63 & renderPoints cam
64
65
66renderPoints ::
67 Mat 4 4 Float
68 -> PrimitiveStream Point (Vec 4 Float, Vec 4 Float)
69 -> ( (FragmentOperation Depth, FragmentOperation (Color (VecScalar 4 Float)))
70 , FragmentStream 1 ((Vec 4 Float)) )
71renderPoints cam points =
72 points
73 & rasterizePrimitives (PointCtx (PointSize 10.0) 1.0 LowerLeft) ((Flat))
74 & mapFragments (\((c)) -> ((c)))
75 & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True))
46 76
47textureCubeSlot s = TextureCubeSlot s 77textureCubeSlot s = TextureCubeSlot s
48 78
@@ -56,4 +86,6 @@ main = renderFrame $
56 (Texture2DSlot "diffuseTexture") 86 (Texture2DSlot "diffuseTexture")
57 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) 87 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))
58 (fetch "plane" ((Attribute "position"))) 88 (fetch "plane" ((Attribute "position")))
89 (Uniform "PointsMax")
90 (Uniform "PointsStart")
59 91