diff options
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r-- | hello_obj2.lc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc index b68a04d..7e7defc 100644 --- a/hello_obj2.lc +++ b/hello_obj2.lc | |||
@@ -19,7 +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 | (points :: PrimitiveStream Line (Vec 3 Float, Vec 3 Float)) | 22 | (lines :: PrimitiveStream Line (Vec 3 Float, Vec 3 Float)) |
23 | (points :: PrimitiveStream Point (Vec 3 Float, Vec 3 Float)) | ||
23 | (plane_mat :: Mat 4 4 Float) | 24 | (plane_mat :: Mat 4 4 Float) |
24 | 25 | ||
25 | = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) | 26 | = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) |
@@ -46,6 +47,17 @@ makeFrame (cubemap :: TextureCube) | |||
46 | in ((r + V4 0 0 0 (0.8)))) | 47 | in ((r + V4 0 0 0 (0.8)))) |
47 | & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) | 48 | & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) |
48 | `overlay` | 49 | `overlay` |
50 | lines | ||
51 | & mapPrimitives (\(p,c) -> let p' = coordmap cam $ point p | ||
52 | w = p'%w | ||
53 | yellowish = normalize c `dot` V3 1 1 0 | ||
54 | p2 = if yellowish >= 0.9*sqrt 2 | ||
55 | then V4 p'%x p'%y 0.1 w | ||
56 | else V4 p'%x p'%y 0.11 w | ||
57 | in (p2, point c)) | ||
58 | |||
59 | & renderPoints cam (LineCtx 1.0 LastVertex) | ||
60 | `overlay` | ||
49 | points | 61 | points |
50 | & mapPrimitives (\(p,c) -> let p' = coordmap cam $ point p | 62 | & mapPrimitives (\(p,c) -> let p' = coordmap cam $ point p |
51 | w = p'%w | 63 | w = p'%w |
@@ -55,16 +67,17 @@ makeFrame (cubemap :: TextureCube) | |||
55 | else V4 p'%x p'%y 0.11 w | 67 | else V4 p'%x p'%y 0.11 w |
56 | in (p2, point c)) | 68 | in (p2, point c)) |
57 | 69 | ||
58 | & renderPoints cam | 70 | & renderPoints cam (PointCtx (PointSize 5.0) 1.0 LowerLeft) |
59 | 71 | ||
60 | renderPoints :: | 72 | renderPoints :: |
61 | Mat 4 4 Float | 73 | Mat 4 4 Float |
62 | -> PrimitiveStream Line (Vec 4 Float, Vec 4 Float) | 74 | -> RasterContext (Vec 4 Float, Vec 4 Float) pr |
75 | -> PrimitiveStream pr (Vec 4 Float, Vec 4 Float) | ||
63 | -> ( (FragmentOperation Depth, FragmentOperation (Color (VecScalar 4 Float))) | 76 | -> ( (FragmentOperation Depth, FragmentOperation (Color (VecScalar 4 Float))) |
64 | , FragmentStream 1 ((Vec 4 Float)) ) | 77 | , FragmentStream 1 ((Vec 4 Float)) ) |
65 | renderPoints cam points = | 78 | renderPoints cam ctx points = |
66 | points | 79 | points |
67 | & rasterizePrimitives (LineCtx 1.0 LastVertex) ((Flat)) | 80 | & rasterizePrimitives ctx ((Flat)) |
68 | & mapFragments (\((c)) -> ((c))) | 81 | & mapFragments (\((c)) -> ((c))) |
69 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | 82 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) |
70 | 83 | ||
@@ -78,5 +91,6 @@ main = renderFrame $ | |||
78 | (Texture2DSlot "diffuseTexture") | 91 | (Texture2DSlot "diffuseTexture") |
79 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) | 92 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) |
80 | (fetch "plane" ((Attribute "position"))) | 93 | (fetch "plane" ((Attribute "position"))) |
94 | (fetch "Curve" (Attribute "position", Attribute "color")) | ||
81 | (fetch "Points" (Attribute "position", Attribute "color")) | 95 | (fetch "Points" (Attribute "position", Attribute "color")) |
82 | (Uniform "PlaneModel") | 96 | (Uniform "PlaneModel") |