lambdacube-engine-0.1.1: Graphics/LambdaCube/TextureUnitState.hs
module Graphics.LambdaCube.TextureUnitState where
import Graphics.LambdaCube.Types
import Graphics.LambdaCube.Common
import Graphics.LambdaCube.BlendMode
import Graphics.LambdaCube.PixelFormat
import Graphics.LambdaCube.Texture
{-| Definition of the broad types of texture effect you can apply to a texture unit.
@note
Note that these have no effect when using the programmable pipeline, since their
effect is overridden by the vertex / fragment programs.
-}
data TextureEffectType
= ET_ENVIRONMENT_MAP -- ^ Generate all texture coords based on angle between camera and vertex
| ET_PROJECTIVE_TEXTURE -- ^ Generate texture coords based on a frustum
| ET_UVSCROLL -- ^ Constant u/v scrolling effect
| ET_USCROLL -- ^ Constant u scrolling effect
| ET_VSCROLL -- ^ Constant u/v scrolling effect
| ET_ROTATE -- ^ Constant rotation
| ET_TRANSFORM -- ^ More complex transform
deriving Eq
{-| Enumeration to specify type of envmap.
@note
Note that these have no effect when using the programmable pipeline, since their
effect is overridden by the vertex / fragment programs.
-}
data EnvMapType
= ENV_PLANAR -- ^ Envmap based on vector from camera to vertex position, good for planar geometry
| ENV_CURVED -- ^ Envmap based on dot of vector from camera to vertex and vertex normal, good for curves
| ENV_REFLECTION -- ^ Envmap intended to supply reflection vectors for cube mapping
| ENV_NORMAL -- ^ Envmap intended to supply normal vectors for cube mapping
{-| Useful enumeration when dealing with procedural transforms.
@note
Note that these have no effect when using the programmable pipeline, since their
effect is overridden by the vertex / fragment programs.
-}
data TextureTransformType
= TT_TRANSLATE_U
| TT_TRANSLATE_V
| TT_SCALE_U
| TT_SCALE_V
| TT_ROTATE
{-| Texture addressing modes - default is TAM_WRAP.
@note
These settings are relevant in both the fixed-function and the
programmable pipeline.
-}
data TextureAddressingMode
= TAM_WRAP -- ^ Texture wraps at values over 1.0
| TAM_MIRROR -- ^ Texture mirrors (flips) at joins over 1.0
| TAM_CLAMP -- ^ Texture clamps at 1.0
| TAM_BORDER -- ^ Texture coordinates outside the range [0.0, 1.0] are set to the border colour
deriving Eq
-- | Texture addressing mode for each texture coordinate.
data UVWAddressingMode
= UVWAddressingMode
{ amU :: TextureAddressingMode
, amV :: TextureAddressingMode
, amW :: TextureAddressingMode
}
deriving Eq
-- | Enum identifying the frame indexes for faces of a cube map (not the composite 3D type.
data TextureCubeFace
= CUBE_FRONT
| CUBE_BACK
| CUBE_LEFT
| CUBE_RIGHT
| CUBE_UP
| CUBE_DOWN
{-
= ET_ENVIRONMENT_MAP -- ^ Generate all texture coords based on angle between camera and vertex
-- EnvMapType
| ET_PROJECTIVE_TEXTURE -- ^ Generate texture coords based on a frustum
| ET_UVSCROLL -- ^ Constant u/v scrolling effect
-- speedX speedY
| ET_ROTATE -- ^ Constant rotation
-- speed
| ET_TRANSFORM -- ^ More complex transform
xform info:
- anim type (scroll,rotate,scale)
- wave type (sine,triangle,square,sawtooth,inversesawtooth)
- base
- frequency
- phase
- amplitude
-}
-- | Internal structure defining a texture effect.
data TextureEffect
= TextureEffect
{ teType :: TextureEffectType
, teSubType :: Int
, teArg1 :: FloatType
, teArg2 :: FloatType
, teWaveType :: WaveformType
, teBase :: FloatType
, teFrequency :: FloatType
, tePhase :: FloatType
, teAmplitude :: FloatType
}
deriving Eq
-- | The type of unit to bind the texture settings to.
data BindingType
= BT_FRAGMENT -- ^ Regular fragment processing unit - the default.
| BT_VERTEX -- ^ Vertex processing unit - indicates this unit will be used for
-- a vertex texture fetch.
deriving Eq
-- | Enum identifying the type of content this texture unit contains.
data ContentType
= CONTENT_NAMED -- ^ Normal texture identified by name
| CONTENT_SHADOW -- ^ A shadow texture, automatically bound by engine
deriving Eq
-------------------------------------------------
{-| Class representing the state of a single texture unit during a Pass of a
Technique, of a Material.
@remarks
Texture units are pipelines for retrieving texture data for rendering onto
your objects in the world. Using them is common to both the fixed-function and
the programmable (vertex and fragment program) pipeline, but some of the
settings will only have an effect in the fixed-function pipeline (for example,
setting a texture rotation will have no effect if you use the programmable
pipeline, because this is overridden by the fragment program). The effect
of each setting as regards the 2 pipelines is commented in each setting.
@par
When I use the term 'fixed-function pipeline' I mean traditional rendering
where you do not use vertex or fragment programs (shaders). Programmable
pipeline means that for this pass you are using vertex or fragment programs.
-}
data Texture t => TextureUnitState t
= TextureUnitState
{ tusAnimDuration :: Maybe FloatType -- ^ Duration of animation in seconds
, tusCubic :: Bool -- ^ is this a series of 6 2D textures to make up a cube?
, tusTextureType :: TextureType
, tusDesiredFormat :: PixelFormat
, tusTextureSrcMipmaps :: TextureMipmap -- ^ Request number of mipmaps
, tusTextureCoordSetIndex :: Int
, tusAddressMode :: UVWAddressingMode
, tusBorderColour :: ColourValue
, tusColourBlendMode :: LayerBlendModeEx
, tusColourBlendFallbackSrc :: SceneBlendFactor
, tusColourBlendFallbackDest :: SceneBlendFactor
, tusAlphaBlendMode :: LayerBlendModeEx
-- mutable bool mTextureLoadFailed;
-- , tusTextureLoadFailed :: Bool
, tusIsAlpha :: Bool
, tusHwGamma :: Bool
-- mutable bool mRecalcTexMatrix;
, tusUMod :: FloatType
, tusVMod :: FloatType
, tusUScale :: FloatType
, tusVScale :: FloatType
, tusRotate :: FloatType
-- mutable Matrix4 mTexModMatrix;
, tusMinFilter :: FilterOptions -- ^ Texture filtering - minification
, tusMagFilter :: FilterOptions -- ^ Texture filtering - magnification
, tusMipFilter :: FilterOptions -- ^ Texture filtering - mipmapping
, tusMaxAniso :: Int -- ^ Texture anisotropy
, tusMipmapBias :: FloatType -- ^ Mipmap bias
-- bool mIsDefaultAniso;
-- bool mIsDefaultFiltering;
, tusBindingType :: BindingType -- ^ Binding type (fragment or vertex pipeline)
, tusContentType :: ContentType -- ^ Content type of texture (normal loaded texture, auto-texture)
, tusFrameNames :: [String]
, tusFrames :: Maybe [t]
, tusName :: String -- ^ optional name for the TUS
, tusTextureAlias :: String -- ^ optional alias for texture frames
, tusEffects :: [TextureEffect]
--------------------------------------
-- typedef multimap<TextureEffectType, TextureEffect>::type EffectMap;
-- EffectMap mEffects;
}
deriving Eq