Add normal maps to the floor
This commit is contained in:
@@ -3,8 +3,10 @@ module Shader.AuxAddition
|
||||
, vaddTextureNoFilter
|
||||
, addTextureArray
|
||||
, addUniforms
|
||||
, initTexture
|
||||
, tilesToLine -- ^ kept in case it is needed in the future
|
||||
) where
|
||||
import Data.Preload.Render
|
||||
import Unsafe.Coerce
|
||||
import Shader.Data
|
||||
import Control.Monad
|
||||
@@ -57,7 +59,24 @@ addTexture2D nlev minfilt magfilt texpath shad = do
|
||||
-- glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
|
||||
-- return $ shad & shadTex' ?~ ShaderTexture
|
||||
-- {_textureObject = texname }
|
||||
|
||||
initTexture
|
||||
:: GLint -- number of mipmap levels
|
||||
-> GLenum -- minfilter
|
||||
-> GLenum -- magfilter
|
||||
-> String -> IO TO
|
||||
initTexture nlev minfilt magfilt fp = do
|
||||
Right cmap <- readImage fp
|
||||
let texdata = convertRGBA8 cmap
|
||||
let wtex = fromIntegral $ imageWidth texdata
|
||||
htex = fromIntegral $ imageHeight texdata
|
||||
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D
|
||||
glTextureStorage2D texname nlev GL_RGBA8 wtex htex
|
||||
VS.unsafeWith (imageData texdata) $ \ptr -> do
|
||||
glTextureSubImage2D texname 0 0 0 wtex htex GL_RGBA GL_UNSIGNED_BYTE ptr
|
||||
glGenerateTextureMipmap texname
|
||||
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
|
||||
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
|
||||
return $ TO texname
|
||||
|
||||
-- | for transforming a 256x256 image containing 64 tiles of 16x16 pixels into
|
||||
-- an image that was directly readable by glTexSubImage3D, used the
|
||||
|
||||
Reference in New Issue
Block a user