ombra-0.1.1.0: Render engine.

Safe HaskellSafe
LanguageHaskell2010

Graphics.Rendering.Ombra.Shader.Language.Functions

Synopsis

Documentation

class (Base a aBase, Base b bBase) => Mul aBase bBase a b result | a b -> result, b -> aBase bBase, a -> aBase bBase, result -> aBase bBase #

Types that can be multiplied.

Instances

(Arithmetic aBase bBase a b result, Base a aBase, Base b bBase) => Mul aBase bBase a b result # 
Mul Float Float Mat4 Vec4 Vec4 # 
Mul Float Float Mat3 Vec3 Vec3 # 
Mul Float Float Mat2 Vec2 Vec2 # 
Mul Float Float Vec4 Mat4 Vec4 # 
Mul Float Float Vec3 Mat3 Vec3 # 
Mul Float Float Vec2 Mat2 Vec2 # 

class (ShaderType a, Base a Float) => FloatVec a #

class ShaderType a => GenType a #

Floats or vectors.

Instances

type family GenTypeFloatConstr a b where ... #

(*) :: (Mul aBase bBase a b c, ShaderType a, ShaderType b, ShaderType c) => a -> b -> c infixl 7 #

(/) :: (Arithmetic aBase bBase a b c, ShaderType a, ShaderType b, ShaderType c) => a -> b -> c infixl 7 #

(+) :: (Arithmetic aBase bBase a b c, ShaderType a, ShaderType b, ShaderType c) => a -> b -> c infixl 6 #

(-) :: (Arithmetic aBase bBase a b c, ShaderType a, ShaderType b, ShaderType c) => a -> b -> c infixl 6 #

(^) :: (ShaderType a, GenType a) => a -> a -> a infixr 8 #

(&&) :: Bool -> Bool -> Bool infixr 3 #

(||) :: Bool -> Bool -> Bool infixr 2 #

(==) :: ShaderType a => a -> a -> Bool infix 4 #

(/=) :: ShaderType a => a -> a -> Bool infix 4 #

(>=) :: ShaderType a => a -> a -> Bool infix 4 #

(<=) :: ShaderType a => a -> a -> Bool infix 4 #

(<) :: ShaderType a => a -> a -> Bool infix 4 #

(>) :: ShaderType a => a -> a -> Bool infix 4 #

lessThan :: VecOrd a => a -> a -> Bool #

lessThanEqual :: VecOrd a => a -> a -> Bool #

greaterThan :: VecOrd a => a -> a -> Bool #

greaterThanEqual :: VecOrd a => a -> a -> Bool #

equal :: VecEq a => a -> a -> Bool #

notEqual :: VecEq a => a -> a -> Bool #

anyB :: BoolVector a => a -> Bool #

allB :: BoolVector a => a -> Bool #

notB :: BoolVector a => a -> Bool #

negate :: GenType a => a -> a #

not :: GenType a => a -> a #

class (ShaderType a, Base a a) => Num a where #

Minimal complete definition

fromInteger

Methods

fromInteger :: Integer -> a #

Instances

Num Int # 

Methods

fromInteger :: Integer -> Int #

Num Float # 

Methods

fromInteger :: Integer -> Float #

radians :: GenType a => a -> a #

degrees :: GenType a => a -> a #

sin :: GenType a => a -> a #

cos :: GenType a => a -> a #

tan :: GenType a => a -> a #

asin :: GenType a => a -> a #

acos :: GenType a => a -> a #

atan :: GenType a => a -> a #

atan2 :: GenType a => a -> a -> a #

exp :: GenType a => a -> a #

log :: GenType a => a -> a #

exp2 :: GenType a => a -> a #

log2 :: GenType a => a -> a #

sqrt :: GenType a => a -> a #

inversesqrt :: GenType a => a -> a #

abs :: GenType a => a -> a #

sign :: GenType a => a -> a #

floor :: GenType a => a -> a #

ceil :: GenType a => a -> a #

fract :: GenType a => a -> a #

mod :: GenTypeFloat a b => a -> b -> a #

min :: GenTypeFloat a b => a -> b -> a #

max :: GenTypeFloat a b => a -> b -> a #

clamp :: GenTypeFloat a b => a -> b -> b -> a #

mix :: GenTypeFloat a b => a -> a -> b -> a #

step :: GenTypeFloat a b => b -> a -> a #

smoothstep :: GenTypeFloat a b => b -> b -> a -> a #

length :: GenType a => a -> Float #

(!) :: (ShaderType t, KnownNat n) => Array n t -> Int -> t #

distance :: GenType a => a -> a -> Float #

dot :: GenType a => a -> a -> Float #

cross :: Vec3 -> Vec3 -> Vec3 #

normalize :: GenType a => a -> a #

faceforward :: GenType a => a -> a -> a -> a #

reflect :: GenType a => a -> a -> a #

refract :: GenType a => a -> a -> Float -> a #

class ShaderType a => Matrix a #

Instances

matrixCompMult :: (Matrix a, Matrix b, Matrix c) => a -> b -> c #

store :: ShaderType a => a -> a #

Avoid evaluating the expression of the argument more than one time. Conditionals and loops imply it.

ifThenElse :: ShaderType a => Bool -> a -> a -> a #

Rebound if. You don't need to use this function, with -XRebindableSyntax.

loop #

Arguments

:: ShaderType a 
=> Int

Maximum number of iterations (should be as low as possible, must be an integer literal)

-> a

Initial value

-> (Int -> a -> (a, Bool))

Iteration -> Old value -> (Next, Stop)

-> a 

position :: Vec4 #

The position of the vertex (only works in the vertex shader).

fragData :: Array 16 Vec4 #

The data of the fragment (only works in the fragment shader).

fragCoord :: Vec4 #

The coordinates of the fragment (only works in the fragment shader).

fragFrontFacing :: Bool #

If the fragment belongs to a front-facing primitive (only works in the fragment shader).

class ShaderType t => ToInt t #

Instances

int :: ToInt t => t -> Int #

class ShaderType t => ToBool t #

Instances

bool :: ToBool t => t -> Bool #

class ShaderType t => ToFloat t #

Instances

float :: ToFloat t => t -> Float #

class ToVec2 t where #

Minimal complete definition

vec2

Methods

vec2 :: t -> Vec2 #

Instances

((<=) (Components Vec2) n, ToCompList t n) => ToVec2 t # 

Methods

vec2 :: t -> Vec2 #

ToVec2 Float # 

Methods

vec2 :: Float -> Vec2 #

class ToVec3 t where #

Minimal complete definition

vec3

Methods

vec3 :: t -> Vec3 #

Instances

((<=) (Components Vec3) n, ToCompList t n) => ToVec3 t # 

Methods

vec3 :: t -> Vec3 #

ToVec3 Float # 

Methods

vec3 :: Float -> Vec3 #

class ToVec4 t where #

Minimal complete definition

vec4

Methods

vec4 :: t -> Vec4 #

Instances

((<=) (Components Vec4) n, ToCompList t n) => ToVec4 t # 

Methods

vec4 :: t -> Vec4 #

ToVec4 Float # 

Methods

vec4 :: Float -> Vec4 #

class ToIVec2 t where #

Minimal complete definition

ivec2

Methods

ivec2 :: t -> IVec2 #

Instances

((<=) (Components IVec2) n, ToCompList t n) => ToIVec2 t # 

Methods

ivec2 :: t -> IVec2 #

ToIVec2 Float # 

Methods

ivec2 :: Float -> IVec2 #

class ToIVec3 t where #

Minimal complete definition

ivec3

Methods

ivec3 :: t -> IVec3 #

Instances

((<=) (Components IVec3) n, ToCompList t n) => ToIVec3 t # 

Methods

ivec3 :: t -> IVec3 #

ToIVec3 Float # 

Methods

ivec3 :: Float -> IVec3 #

class ToIVec4 t where #

Minimal complete definition

ivec4

Methods

ivec4 :: t -> IVec4 #

Instances

((<=) (Components IVec4) n, ToCompList t n) => ToIVec4 t # 

Methods

ivec4 :: t -> IVec4 #

ToIVec4 Float # 

Methods

ivec4 :: Float -> IVec4 #

class ToBVec2 t where #

Minimal complete definition

bvec2

Methods

bvec2 :: t -> BVec2 #

Instances

((<=) (Components BVec2) n, ToCompList t n) => ToBVec2 t # 

Methods

bvec2 :: t -> BVec2 #

ToBVec2 Float # 

Methods

bvec2 :: Float -> BVec2 #

class ToBVec3 t where #

Minimal complete definition

bvec3

Methods

bvec3 :: t -> BVec3 #

Instances

((<=) (Components BVec3) n, ToCompList t n) => ToBVec3 t # 

Methods

bvec3 :: t -> BVec3 #

ToBVec3 Float # 

Methods

bvec3 :: Float -> BVec3 #

class ToBVec4 t where #

Minimal complete definition

bvec4

Methods

bvec4 :: t -> BVec4 #

Instances

((<=) (Components BVec4) n, ToCompList t n) => ToBVec4 t # 

Methods

bvec4 :: t -> BVec4 #

ToBVec4 Float # 

Methods

bvec4 :: Float -> BVec4 #

class ToMat2 t where #

Minimal complete definition

mat2

Methods

mat2 :: t -> Mat2 #

Instances

((<=) (Components Mat2) n, ToCompList t n) => ToMat2 t # 

Methods

mat2 :: t -> Mat2 #

ToMat2 Float # 

Methods

mat2 :: Float -> Mat2 #

class ToMat3 t where #

Minimal complete definition

mat3

Methods

mat3 :: t -> Mat3 #

Instances

((<=) (Components Mat3) n, ToCompList t n) => ToMat3 t # 

Methods

mat3 :: t -> Mat3 #

ToMat3 Float # 

Methods

mat3 :: Float -> Mat3 #

class ToMat4 t where #

Minimal complete definition

mat4

Methods

mat4 :: t -> Mat4 #

Instances

((<=) (Components Mat4) n, ToCompList t n) => ToMat4 t # 

Methods

mat4 :: t -> Mat4 #

ToMat4 Float # 

Methods

mat4 :: Float -> Mat4 #

data CompList count where #

Useful type for constructing vectors and matrices from scalars, vectors and matrices.

Constructors

CL :: (1 <= Components t, ShaderType t) => t -> CompList (Components t) 
CLAppend :: CompList x -> CompList y -> CompList (x + y) 

Instances

ToCompList (CompList n) n # 

Methods

toCompList :: CompList n -> CompList n #

class ToCompList x n | x -> n where #

Minimal complete definition

toCompList

Methods

toCompList :: x -> CompList n #

Instances

((<=) 1 n, ShaderType t, (~) Nat n (Components t)) => ToCompList t n # 

Methods

toCompList :: t -> CompList n #

ToCompList (CompList n) n # 

Methods

toCompList :: CompList n -> CompList n #

(#) :: (ToCompList x xn, ToCompList y yn) => x -> y -> CompList (xn + yn) infixr 5 #

You can call *vec* and mat* with a single scalar or with a CompList containing enough components. This function helps you create CompLists.

Examples:

vec2 0
mat2 $ Vec2 2 4 # Vec2 1 3
vec4 $ mat2 (0 # 1 # vec2 2) # 9  -- 9 is discarded
mat4 $ 5 # vec2 5 # Vec3 1 2 3 # Mat2 (vec2 0) (Vec2 1 2) # mat3 0
vec4 $ 1 # vec2 0 -- Not enough components, fails with "Couldn't match type
                  -- ‘'Prelude.False’ with 'Prelude.True’" (because
                  -- Components Vec4 <=? 3 ~ False).

op1 :: (ShaderType a, ShaderType b) => String -> a -> b #

op2 :: (ShaderType a, ShaderType b, ShaderType c) => String -> a -> b -> c #

fun1 :: (ShaderType a, ShaderType b) => String -> a -> b #

fun2 :: (ShaderType a, ShaderType b, ShaderType c) => String -> a -> b -> c #

fun3 :: (ShaderType a, ShaderType b, ShaderType c, ShaderType d) => String -> a -> b -> c -> d #

funCompList :: (ToCompList cl n, ShaderType r) => String -> cl -> r #