Stability | experimental |
---|---|
Maintainer | conal@conal.net |
Lighting/shading. Adapted from Vertigo.
- data LightInfo = LI {}
- type Light = R3E -> LightInfo
- data View = View {
- viewAmbient :: Color
- viewEye :: R3E
- viewLights :: [Light]
- data SurfInfo = SurfInfo {}
- type Lighter a = View -> SurfInfo -> a
- type LLighter a = LightInfo -> Lighter a
- ambient :: Lighter Color
- eye :: Lighter R3E
- lights :: Lighter [Light]
- surfP :: Lighter R3E
- surfN :: Lighter Dir3E
- intrinsic :: Lighter Color
- colorL :: LLighter Color
- dirL :: LLighter R3E
- illuminance :: (AdditiveGroup a, IfB BoolE a) => LLighter a -> Lighter a
- diffuse :: Lighter Color
- ambDiff :: (Color, Color) -> Lighter Color
- eyeDir :: Lighter Dir3E
- eyeLight :: LLighter Dir3E
- reflection :: LLighter Dir3E
- specularG :: LLighter FloatE -> FloatE -> Lighter Color
- specularRV :: FloatE -> Lighter Color
- specularNH :: FloatE -> Lighter Color
- type BasicSh = (Color, Color, Color, FloatE) -> Lighter Color
- basic :: LLighter FloatE -> BasicSh
- basicRV :: BasicSh
- basicNH :: BasicSh
- class Liftable k f where
- lift :: k -> f
- type Dir3E = R3E
- dirLight :: Color -> Dir3E -> Light
- pointLight :: Color -> R3E -> Light
- stdViewPos :: R3E
- stdView :: R3E -> [Light] -> View
- view1 :: R3E -> View
- ma :: Color
- md :: Color
- ms :: Color
- msh :: FloatE
- basicStd :: Lighter Color
Documentation
Info about how one light affects a given point. The surface lighter
decides what to do with the light info. Attenuation and relation of
light position (if finitely distant) to surface position are already
accounted for. liDir
is the direction to the light (normalized).
type Light = R3E -> LightInfoSource
A light is something that provides light info to every point in space (though to some points it provides blackness), independent of obstructions. Should probably also take an atmosphere argument.
Viewing environment: ambient, eye, lights
View | |
|
Info about a surface at a point: position, normal, color
illuminance :: (AdditiveGroup a, IfB BoolE a) => LLighter a -> Lighter aSource
Combine contributions from multiple lights. Patterned after
Renderman's illuminance
construct.
The Stanford rtsl version, with ambient and weights:
surface float4 lightmodel_diffuse (float4 ka, float4 kd) { perlight float diffuse = dot(N,L); perlight float4 fr = kd * select(diffuse > 0, diffuse, 0); return ka * Ca + integrate(fr * Cl); }
Direction from surface point to eye
reflection :: LLighter Dir3ESource
Reflection vector (CGPP p 730)
specularG :: LLighter FloatE -> FloatE -> Lighter ColorSource
Pure specular. Ignores intrinsic surface color. There are different ways to compute the power base.
specularRV :: FloatE -> Lighter ColorSource
specularNH :: FloatE -> Lighter ColorSource
Or the N.H model:
type BasicSh = (Color, Color, Color, FloatE) -> Lighter ColorSource
surface floatv lightmodel_specular (floatv s, floatv e, float sh) { perlight float diffuse = dot(N,DIRL); perlight float specular = pow(max(dot(N,H),0),sh); perlight floatv fr = select(diffuse > 0, s * specular, Zero); return integrate(fr * Cl) + e; }
basic :: LLighter FloatE -> BasicShSource
Combine intrinsic, ambient, diffuse and specular, with weightings
class Liftable k f whereSource
surface float4 lightmodel (float4 a, float4 d, float4 s, float4 e, float sh) { perlight float diffuse = dot(N,DIRL); perlight float specular = pow(max(dot(N,H),0),sh); perlight float4 fr = d * max(diffuse, 0) + s * select(diffuse > 0, specular, 0); return a * Ca + integrate(fr * Cl) + e; }
dirLight :: Color -> Dir3E -> LightSource
Directional light, given the direction from the light (opposite dirL
)
pointLight :: Color -> R3E -> LightSource
Point light
stdView :: R3E -> [Light] -> ViewSource
View with white ambient light and given eye position and lights
View with white ambient light, one directional light, and given eye position. For now, light position is like eye position but more so.