Render bezier curves using distance fields

This commit is contained in:
jgk
2021-03-14 00:13:29 +01:00
parent 3aefb8319d
commit b0c8c10658
6 changed files with 51 additions and 37 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ import Data.Traversable
data RenderType
= RenderPoly [(Point3,Point4)]
| RenderBezQ [(Point3,Point4,Point3)]
| RenderBezQ [(Point3,Point4,Point4)]
| RenderText [(Point3,Point4,Point3)]
| RenderArc (Point3,Point4,Point4)
| RenderLine [(Point3,Point4)]
@@ -75,7 +75,7 @@ data Picture
= Blank
| Text Int String
| Polygon Int [Point2]
| BezierQuad Int [(Point2,RGBA,Point2,Float)]
| BezierQuad Int [(Point2,RGBA,Point2,Point2)]
| PolygonCol Int [(Point2,RGBA)]
| Circle Int RGBA RGBA Float
| ThickArc Int Float Float Float Float
+4 -2
View File
@@ -50,7 +50,7 @@ preloadRender = do
"data/texture/charMap.png"
bezierQuadShader
<- makeShader "bezierQuad" [vert,geom,frag] [(0,3),(1,4),(2,3)] Triangles pokeBezQStrat
<- makeShader "bezierQuad" [vert,frag] [(0,3),(1,4),(2,4)] TriangleStrip pokeBezQStrat
--the following vbo is set up to contain one fixed vertex
dummyvbo <- genObjectName
@@ -84,7 +84,9 @@ cleanUpRenderPreload pd = do
{-# INLINE pokeBezQStrat #-}
pokeBezQStrat :: RenderType -> [[[Float]]]
pokeBezQStrat (RenderBezQ vs) = fmap (\((x,y,z),(r,g,b,a),(s,t,v)) -> [[x,y,z],[r,g,b,a],[s,t,v]]) vs
pokeBezQStrat (RenderBezQ vs) = fmap (\((x,y,z),(r,g,b,a),(s,t,u,v)) -> [[x,y,z],[r,g,b,a],[s,t,u,v]]
)
vs
pokeBezQStrat _ = []
{-# INLINE pokeTriStrat #-}
+1 -1
View File
@@ -20,7 +20,7 @@ picToLTree mx (PolygonCol i vs)
picToLTree mx (BezierQuad i vs)
= filtB mx i $ LLeaf $ RenderBezQ $ zip3 (map zeroZ ps) cols rs
where (ps,cols,offps,rads) = unzip4 vs
rs = zipWith (\(x,y) z -> (x,y,z)) offps rads
rs = zipWith (\(x,y) (z,w) -> (x,y,z,w)) offps rads
picToLTree mx (Circle i colC colE r)
= filtB mx i $ LLeaf $ RenderEllipse [( (-r, r,0), colC)