-
Notifications
You must be signed in to change notification settings - Fork 11
Blinn phong
rookboom edited this page Nov 13, 2012
·
3 revisions
[<ReflectedDefinition>]
let surfaceColor (scene:SceneConstants) (mat:MaterialConstants) worldPos normal =
let lightVec = scene.Light - worldPos
let lightDir = normalize lightVec
let lightFallOff =
let lightVecSquared = (lightVec |> dot lightVec)
scene.LightRangeSquared/lightVecSquared
|> saturatef
let diffuse =
normal
|> dot lightDir
|> max 0.0f
|> mul mat.Diffuse
|> mul lightFallOff
|> saturate
let specular =
let viewer = scene.Eye - worldPos
|> normalize
let half_vector = (lightDir + viewer)
|> normalize
half_vector
|> dot normal
|> max 0.0f
|> pow mat.Shine
|> mul mat.Specular
|> mul lightFallOff
|> saturate
scene.AmbientLight + diffuse + specular
|> saturate
You can find the full source code here