diff options
author | Joe Crayne <joe@jerkface.net> | 2019-05-18 03:04:20 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-18 03:04:20 -0400 |
commit | a590439eef76c5fe1e8ec7fce28a3b194bfd6e8e (patch) | |
tree | e4112135a37e3fe0fcce3baa5468f304309b6d89 /hello_obj2.lc | |
parent | 1f1e8adb543a3338e85313b005b3213471600541 (diff) |
Allow alternate plane positions.
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r-- | hello_obj2.lc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc index 629bf59..fdf08d6 100644 --- a/hello_obj2.lc +++ b/hello_obj2.lc | |||
@@ -20,6 +20,7 @@ makeFrame (cubemap :: TextureCube) | |||
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 | (points :: PrimitiveStream Point ((Vec 3 Float))) | 22 | (points :: PrimitiveStream Point ((Vec 3 Float))) |
23 | (plane_mat :: Mat 4 4 Float) | ||
23 | 24 | ||
24 | = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) | 25 | = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) |
25 | `overlay` | 26 | `overlay` |
@@ -38,7 +39,7 @@ makeFrame (cubemap :: TextureCube) | |||
38 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | 39 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) |
39 | `overlay` | 40 | `overlay` |
40 | plane | 41 | plane |
41 | & mapPrimitives (\((p)) -> let p' = coordmap cam p in (p', p%xz)) | 42 | & mapPrimitives (\((p)) -> let p' = coordmap cam $ plane_mat *. p in (p', p%xz)) |
42 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) | 43 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) |
43 | & mapFragments (\((uv)) -> let c = mixB zero one (fract uv >= (one *! (0.95::Float))) | 44 | & mapFragments (\((uv)) -> let c = mixB zero one (fract uv >= (one *! (0.95::Float))) |
44 | r = V4 1 1 1 0 *! (max c%x c%y) | 45 | r = V4 1 1 1 0 *! (max c%x c%y) |
@@ -62,11 +63,9 @@ renderPoints cam points = | |||
62 | & mapFragments (\((c)) -> ((c))) | 63 | & mapFragments (\((c)) -> ((c))) |
63 | & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True)) | 64 | & accumulateWith (DepthOp Always False, ColorOp NoBlending (V4 True True True True)) |
64 | 65 | ||
65 | textureCubeSlot s = TextureCubeSlot s | ||
66 | |||
67 | main :: Output | 66 | main :: Output |
68 | main = renderFrame $ | 67 | main = renderFrame $ |
69 | makeFrame (textureCubeSlot "CubeMap") | 68 | makeFrame (TextureCubeSlot "CubeMap") |
70 | (fetch "SkyCube" ((Attribute "position"))) | 69 | (fetch "SkyCube" ((Attribute "position"))) |
71 | (Uniform "CameraPosition") | 70 | (Uniform "CameraPosition") |
72 | (Uniform "ViewProjection") | 71 | (Uniform "ViewProjection") |
@@ -75,4 +74,4 @@ main = renderFrame $ | |||
75 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) | 74 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) |
76 | (fetch "plane" ((Attribute "position"))) | 75 | (fetch "plane" ((Attribute "position"))) |
77 | (fetch "Points" ((Attribute "position"))) | 76 | (fetch "Points" ((Attribute "position"))) |
78 | 77 | (Uniform "PlaneModel") | |