Closed NCrashed closed 8 years ago
Due to a type inference bug in the 0.4 release the fragment shader type must be explicitly written. It will be fixed in the following releases. (in the 0.7 release we plan to represent tuples as heterogeneous lists, which will fix the problem) The following code passes the position and uv coordinates to the fragment shader:
makeFrame (projmat :: Mat 4 4 Float)
(vertexstream :: PrimitiveStream Triangle (Vec 4 Float,Vec 2 Float))
= imageFrame (emptyDepthImage 1, emptyColorImage navy)
`overlay` fragments
where
fragments =
vertexstream
& mapPrimitives (\(x,uv) -> (scale 0.5 (projmat *. x), x, uv))
& rasterizePrimitives (TriangleCtx CullNone PolygonFill NoOffset LastVertex) (Smooth,Smooth)
& mapFragments ((\(x,uv) -> x) :: (Vec 4 Float,Vec 2 Float) -> Vec 4 Float)
& accumulateWith (DepthOp Less True, ColorOp NoBlending (V4 True True True True))
main = renderFrame $
makeFrame (Uniform "MVP")
(fetch_ "stream4" (Attribute "position4", Attribute "vertexUV"))
Thank you! That saved my day.
Hi, I cannot find example with several attributes passed to fragment shader. All my own attempts failed.
Could you give modified
Cube.lc
example where, for instance, normals are passed to fragment shader along with color info?