summaryrefslogtreecommitdiff
path: root/hello_obj2.lc
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-04-22 03:13:44 -0400
committerJoe Crayne <joe@jerkface.net>2019-04-22 03:36:23 -0400
commitac89ee199abfe893b03cdbb89a426cd0594e06c9 (patch)
treec3542c880eb610e9a2d5d863ec9ba518a32a0b02 /hello_obj2.lc
parent36bd8e7133eca5d4e04252c555ee0cc2cc78106e (diff)
objdemo: pass view matrix from haskell.
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r--hello_obj2.lc16
1 files changed, 6 insertions, 10 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc
index ebee807..7adf8b1 100644
--- a/hello_obj2.lc
+++ b/hello_obj2.lc
@@ -1,15 +1,11 @@
1deg30 = 0.5235987755982988 -- pi/6 1deg30 = 0.5235987755982988 -- pi/6
2 2
3coordmap (time::Float) (p::Vec 4 Float) 3coordmap (cam::Mat 4 4 Float) (p::Vec 4 Float)
4 = perspective 0.1 -- near plane 4 = perspective 0.1 -- near plane
5 100 -- far plane 5 100 -- far plane
6 deg30 -- y fov radians 6 deg30 -- y fov radians
7 1 -- aspect ratio w/h 7 1 -- aspect ratio w/h
8 *. lookat (V3 0 0 10) -- camera position 8 *. cam
9 (V3 0 0 0) -- target position
10 (V3 0 1 0) -- upward direction
11 *. rotMatrixX time -- time = radians
12 *. rotMatrixZ time -- time = radians
13 *. p 9 *. p
14 10
15blendplane = -- NoBlending -- BlendLogicOp Xor 11blendplane = -- NoBlending -- BlendLogicOp Xor
@@ -17,7 +13,7 @@ blendplane = -- NoBlending -- BlendLogicOp Xor
17 ((OneBF,SrcAlpha),(DstAlpha,DstAlpha)) 13 ((OneBF,SrcAlpha),(DstAlpha,DstAlpha))
18 (V4 0 0 0 0) 14 (V4 0 0 0 0)
19 15
20makeFrame (time :: Float) 16makeFrame (cam :: Mat 4 4 Float)
21 (color :: Vec 4 Float) 17 (color :: Vec 4 Float)
22 (texture :: Texture) 18 (texture :: Texture)
23 (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) 19 (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float))
@@ -26,13 +22,13 @@ makeFrame (time :: Float)
26 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) 22 = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1))
27 `overlay` 23 `overlay`
28 prims 24 prims
29 & mapPrimitives (\(p,n,uvw) -> ( coordmap time p, V2 uvw%x (1 - uvw%y) )) 25 & mapPrimitives (\(p,n,uvw) -> ( coordmap cam p, V2 uvw%x (1 - uvw%y) ))
30 & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth)) 26 & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth))
31 & mapFragments (\((uv)) -> ((color * texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) 27 & mapFragments (\((uv)) -> ((color * texture2D (Sampler PointFilter MirroredRepeat texture) uv )))
32 & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) 28 & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
33 `overlay` 29 `overlay`
34 plane 30 plane
35 & mapPrimitives (\((p)) -> (coordmap time p, p%xy )) 31 & mapPrimitives (\((p)) -> (coordmap cam p, p%xy ))
36 & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) 32 & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth))
37 -- & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) 33 -- & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv )))
38 -- & mapFragments (\((uv)) -> ((V4 uv%x uv%y 0 1))) -- ((rgb 1 0 0))) 34 -- & mapFragments (\((uv)) -> ((V4 uv%x uv%y 0 1))) -- ((rgb 1 0 0)))
@@ -46,7 +42,7 @@ makeFrame (time :: Float)
46 42
47 43
48main = renderFrame $ 44main = renderFrame $
49 makeFrame (Uniform "time") 45 makeFrame (Uniform "cam")
50 (Uniform "diffuseColor") 46 (Uniform "diffuseColor")
51 (Texture2DSlot "diffuseTexture") 47 (Texture2DSlot "diffuseTexture")
52 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) 48 (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw"))