module Graphics.Rendering.Ombra.Shader.Default2D (
Uniforms,
Geometry2D,
Image(..),
Depth(..),
Transform2(..),
View2(..),
Position2(..),
UV(..),
vertexShader,
fragmentShader
) where
import Graphics.Rendering.Ombra.Shader
type Uniforms = '[View2, Image, Depth, Transform2]
type Geometry2D = '[Position2, UV]
data Image = Image GSampler2D deriving Generic
data Depth = Depth GFloat deriving Generic
data Transform2 = Transform2 GMat3 deriving Generic
data View2 = View2 GMat3 deriving Generic
data Position2 = Position2 GVec2 deriving Generic
vertexShader :: VertexShader '[Transform2, View2, Depth]
'[Position2, UV]
'[UV]
vertexShader (Transform2 trans :- View2 view :- Depth z :- N)
(Position2 pos :- uv@(UV _) :- N) =
let GVec3 x' y' _ = view .*. trans .* (pos ^| 1)
in Vertex (GVec4 x' y' z 1) :- uv :- N
fragmentShader :: FragmentShader '[Image] '[UV]
fragmentShader (Image sampler :- N) (UV (GVec2 s t) :- N) =
Fragment (texture2D sampler (GVec2 s $ 1 t)) :- N