coordmap (time::Float) (p::Vec 4 Float) = perspective 0.1 100 30 1 *. lookat (V3 0 0 5) (V3 0 0 0) (V3 0 1 0) *. rotMatrixX time *. rotMatrixZ time *. p blendplane = -- NoBlending -- BlendLogicOp Xor Blend (FuncAdd,FuncAdd) ((OneBF,SrcAlpha),(DstAlpha,DstAlpha)) (V4 0 0 0 0) makeFrame (time :: Float) (color :: Vec 4 Float) (texture :: Texture) (prims :: PrimitiveStream Triangle (Vec 4 Float, Vec 3 Float, Vec 3 Float)) (plane :: PrimitiveStream Triangle ((Vec 4 Float))) = imageFrame (emptyDepthImage 1, emptyColorImage (V4 0 0 0.4 1)) `overlay` prims & mapPrimitives (\(p,n,uvw) -> ( coordmap time p, V2 uvw%x (1 - uvw%y) )) & rasterizePrimitives (TriangleCtx CullBack PolygonFill NoOffset LastVertex) ((Smooth)) & mapFragments (\((uv)) -> ((color * texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) & accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True)) `overlay` plane & mapPrimitives (\((p)) -> (coordmap time p, p%xy )) & rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) ((Smooth)) -- & mapFragments (\((uv)) -> ((texture2D (Sampler PointFilter MirroredRepeat texture) uv ))) -- & mapFragments (\((uv)) -> ((V4 uv%x uv%y 0 1))) -- ((rgb 1 0 0))) & mapFragments (\((uv)) -> let k=cos(g *! (8 * pi / 4)) g=uv -- *! (1 + sqrt (abs (t%x * t%y))) t=normalize uv c=k -- *! ( t%x * t%y) -- /! ((k%x + k%y) / k%x) r = V4 1 1 1 0 *! smoothstepS 0.99 1.0 (max c%x c%y) in ((r + V4 0 0 0 (0.8)))) & accumulateWith (DepthOp Less True, ColorOp blendplane (V4 True True True True)) main = renderFrame $ makeFrame (Uniform "time") (Uniform "diffuseColor") (Texture2DSlot "diffuseTexture") (fetch "objects" (Attribute "position", Attribute "normal", Attribute "uvw")) (fetch "plane" ((Attribute "position")))