diff options
author | Joe Crayne <joe@jerkface.net> | 2019-04-29 16:04:24 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-04-29 16:04:24 -0400 |
commit | edbc09c280c1699933c443795686394c1e9e8de5 (patch) | |
tree | 533a2849f8a9ebe4a86d3efa5dd7062c27f73b07 /hello_obj2.lc | |
parent | 3af8c040637d4289e39577c04fc8b68f8d868f05 (diff) |
mainObj.hs: Slower animation, more straight-forward grid calculation.
Diffstat (limited to 'hello_obj2.lc')
-rw-r--r-- | hello_obj2.lc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/hello_obj2.lc b/hello_obj2.lc index 5a95ad7..d0fc35b 100644 --- a/hello_obj2.lc +++ b/hello_obj2.lc | |||
@@ -7,7 +7,8 @@ blendplane = -- NoBlending -- BlendLogicOp Xor | |||
7 | ((OneBF,SrcAlpha),(DstAlpha,DstAlpha)) | 7 | ((OneBF,SrcAlpha),(DstAlpha,DstAlpha)) |
8 | (V4 0 0 0 0) | 8 | (V4 0 0 0 0) |
9 | 9 | ||
10 | makeFrame (cam :: Mat 4 4 Float) | 10 | makeFrame (cameraPosition :: Vec 3 Float) |
11 | (cam :: Mat 4 4 Float) | ||
11 | (color :: Vec 4 Float) | 12 | (color :: Vec 4 Float) |
12 | (texture :: Texture) | 13 | (texture :: Texture) |
13 | (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) | 14 | (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) |
@@ -22,21 +23,17 @@ makeFrame (cam :: Mat 4 4 Float) | |||
22 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) | 23 | & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) |
23 | `overlay` | 24 | `overlay` |
24 | plane | 25 | plane |
25 | & mapPrimitives (\((p)) -> (coordmap cam p, p%xy )) | 26 | & mapPrimitives (\((p)) -> let p' = coordmap cam p in (p', p%xz)) |
26 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) | 27 | & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) |
27 | -- & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) | 28 | & mapFragments (\((uv)) -> let c = mixB zero one (fract uv >= (one *! (0.95::Float))) |
28 | -- & mapFragments (\((uv)) -> ((V4 uv%x uv%y 0 1))) -- ((rgb 1 0 0))) | 29 | r = V4 1 1 1 0 *! (max c%x c%y) |
29 | & mapFragments (\((uv)) -> let k=cos(g *! (8 * pi / 4)) | ||
30 | g=uv -- *! (1 + sqrt (abs (t%x * t%y))) | ||
31 | t=normalize uv | ||
32 | c=k -- *! ( t%x * t%y) -- /! ((k%x + k%y) / k%x) | ||
33 | r = V4 1 1 1 0 *! smoothstepS 0.99 1.0 (max c%x c%y) | ||
34 | in ((r + V4 0 0 0 (0.8)))) | 30 | in ((r + V4 0 0 0 (0.8)))) |
35 | & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) | 31 | & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) |
36 | 32 | ||
37 | 33 | ||
38 | main = renderFrame $ | 34 | main = renderFrame $ |
39 | makeFrame (Uniform "cam") | 35 | makeFrame (Uniform "CameraPosition") |
36 | (Uniform "ViewProjection") | ||
40 | (Uniform "diffuseColor") | 37 | (Uniform "diffuseColor") |
41 | (Texture2DSlot "diffuseTexture") | 38 | (Texture2DSlot "diffuseTexture") |
42 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) | 39 | (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) |