initModel :: (MonadIO m,MonadLogger m,Photon m) => m App
initModel = do
cube <- loadSpawn "cube" -- Mesh
cubeMat <- loadSpawn "redMaterial" -- Material
blueLight <- loadSpawn "blueLight" -- Light
redLight <- loadSpawn "redLight" -- Light
useMaterial cube cubeMat
yCorrection <- loadSpawn "yCorrection" -- PostFX
ssao <- loadSpawn "ssao" -- PostFX
return (App cube blueLight redLight yCorrection ssao)
render :: (MonadIO m,Photon m) => App -> m ()
render (App cube blueLight redLight yCorrection ssao) = do
-- accum is the first phase of the render. In that phase, each render is
-- done in a frame, and when the clustered renders (per light) are done, the
-- resulting frame is blended (accumulated) into another one. The accumulated
-- frame is then available for the next phases.
accum Additive One One $ do
withLight blueLight (renderMesh cube)
withLight redLight (renderMesh cube)
-- post-process phase in which we can apply a list of PostFX
--
-- Note:
-- sequence_ . map postfx = postProcess
sequence_ (map postfx [ssao,yCorrection])
-- final phase of the render, we simply display the resulting frame on
-- screen. We could also have used screenshot path or the frame function
-- that gets back the frame.
display