module Graphics.Rendering.Ombra.OutBuffer (
GBuffer,
DepthBuffer,
BufferPair,
GBufferInfo,
DepthBufferInfo,
GBufferSampler,
DepthBufferSampler,
sampleGBuffer,
sampleDepthBuffer,
floatGBufferInfo,
byteGBufferInfo,
depthBufferInfo,
depthStencilBufferInfo,
bufferPair,
gBuffer,
depthBuffer,
bufferSize,
toTextureSampler,
fromTextureSampler
) where
import Graphics.Rendering.Ombra.OutBuffer.Types
import Graphics.Rendering.Ombra.Shader
import Graphics.Rendering.Ombra.Shader.Types
import Graphics.Rendering.Ombra.Texture.Types
bufferPair :: GBuffer o -> DepthBuffer -> Maybe (BufferPair o)
bufferPair g d | bufferSize g == bufferSize d = Just $ BufferPair g d
| otherwise = Nothing
gBuffer :: BufferPair o -> GBuffer o
gBuffer (BufferPair buf _) = buf
depthBuffer :: BufferPair o -> DepthBuffer
depthBuffer (BufferPair _ buf) = buf
sampleGBuffer :: GBufferSampler o -> GVec2 -> o
sampleGBuffer (GBufferSampler samplers) st =
fromGVec4s $ map (flip sample st) samplers
sampleDepthBuffer :: DepthBufferSampler -> GVec2 -> GFloat
sampleDepthBuffer (DepthBufferSampler sampler) st =
let GVec4 x _ _ _ = sample sampler st in x
fromTextureSampler :: TextureSampler -> GBufferSampler GVec4
fromTextureSampler sampler = GBufferSampler [sampler]
toTextureSampler :: GBufferSampler GVec4 -> TextureSampler
toTextureSampler (GBufferSampler (sampler : _)) = sampler
floatGBufferInfo :: FragmentShaderOutput o => TextureParameters -> GBufferInfo o
floatGBufferInfo = EmptyFloatGBuffer
byteGBufferInfo :: FragmentShaderOutput o => TextureParameters -> GBufferInfo o
byteGBufferInfo = EmptyByteGBuffer
depthBufferInfo :: TextureParameters -> DepthBufferInfo
depthBufferInfo = EmptyDepthBuffer
depthStencilBufferInfo :: TextureParameters -> DepthBufferInfo
depthStencilBufferInfo = EmptyDepthStencilBuffer