summaryrefslogtreecommitdiff
path: root/hello_obj2.lc
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-17 03:55:38 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-17 03:55:38 -0400
commitb5d68cc4aba82fec53e156a6c0c2d2726ee6ff46 (patch)
tree4fe1a29265412abc09dc20887a17d378322c08a2 /hello_obj2.lc
parentf5d4a74e9a4b23917b97f48bde529cb21e3ec152 (diff)
Point primitive stream based ring buffer.
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r--hello_obj2.lc21
1 files changed, 4 insertions, 17 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc
index 8e9bbe0..1181943 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -19,8 +19,7 @@ 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) 22 (points :: PrimitiveStream Point ((Vec 3 Float)))
23 (pointsStart :: Int)
24 23
25 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) 24 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1))
26 `overlay` 25 `overlay`
@@ -46,23 +45,12 @@ makeFrame (cubemap :: TextureCube)
46 in ((r + V4 0 0 0 (0.8)))) 45 in ((r + V4 0 0 0 (0.8))))
47 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) 46 & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True))
48 `overlay` 47 `overlay`
49 zipCount (fetch "Points" ((Attribute "position")) :: PrimitiveStream Point ((Float))) 48 points
50 & mapPrimitives (\(n,_) -> {- let nn = 0.2 * fromInt n :: Float 49 & mapPrimitives (\((p)) -> let p' = point p -- coordmap cam $ point p
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)) 50 in (p', V4 1 1 0 1 :: Vec 4 Float))
62 51
63 & renderPoints cam 52 & renderPoints cam
64 53
65
66renderPoints :: 54renderPoints ::
67 Mat 4 4 Float 55 Mat 4 4 Float
68 -> PrimitiveStream Point (Vec 4 Float, Vec 4 Float) 56 -> PrimitiveStream Point (Vec 4 Float, Vec 4 Float)
@@ -86,6 +74,5 @@ main = renderFrame $
86 (Texture2DSlot "diffuseTexture") 74 (Texture2DSlot "diffuseTexture")
87 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) 75 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))
88 (fetch "plane" ((Attribute "position"))) 76 (fetch "plane" ((Attribute "position")))
89 (Uniform "PointsMax") 77 (fetch "Points" ((Attribute "position")))
90 (Uniform "PointsStart")
91 78