packages feed

mischief-live-0.1.0.0: examples/shader/common/ShaderCommon.hs

module ShaderCommon where

import Mischief.Materials
import Mischief.Materials.Sprite (SpriteMaterial)
import Mischief.Materials.Sprite qualified as Sprite
import Mischief.Materials.Time (TimeMaterial)
import Prelude ()

data CustomMaterial

data Bindings f = Bindings deriving (Generic, Bindable)

instance Material CustomMaterial where
  type VI CustomMaterial = Sprite.VertexInput
  type VO CustomMaterial = Sprite.VertexOutput
  type B CustomMaterial = Bindings

  type Extends CustomMaterial = '[SpriteMaterial, TimeMaterial]

  vertex = liftExt . vertex @SpriteMaterial
  fragment = liftExt . fragment @SpriteMaterial
  fetch = FetchBindings (const $ pure ()) (const $ pure ()) (const $ const Bindings)

newtype Input = Input (VO SpriteMaterial GPU)

newtype Output = Output (Vec4 Float)

newtype ShaderOutput = ShaderOutput (Shader CustomMaterial Output)