Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias v0, pos
- alias v1, uv
- alias v2, lvt
- alias v3, norm
- alias fc0, zero
- alias fc1, one
- alias fc2, half
- alias fc3, two
- alias fc4, lightDir
- alias fc5, solidColor
- alias fc6, lightPos
- alias fc7.x, lightIntensity
- alias fc7.y, exposure
- alias fc7.z, e
- alias ft0, color
- alias ft1, light
- alias ft2, ta
- // Surface vector
- alias ft3, sv
- alias fs0, normalMap
- #define PARALLEL_LIGHT 0
- #define DIRECTIONAL_LIGHT 0
- #define DIRECTIONAL_LIGHT_NORMALMAP 1
- // Solid color
- color = solidColor
- ft3 = tex<2d,linear,linear>(v1, fs0)
- #if PARALLEL_LIGHT
- dp3 light, lightDir, norm
- max light, light, zero
- #elif DIRECTIONAL_LIGHT
- light = zero
- // Angle of view to surface in ft1
- ta = lightPos-pos
- nrm light.xyz, ta
- dp3 light, light, norm
- // Clamp to 0
- max light, light, zero
- // Distance of surface from light
- // Distance^2
- dp3 ta, ta, ta
- // Inverse of distance squared
- ta = lightIntensity / ta
- // Mix above two together
- light = light*ta
- #elif DIRECTIONAL_LIGHT_NORMALMAP
- light = one
- sv = sv-half
- sv = sv*two
- dp3 ta, sv, lvt
- // Distance of surface from light ^2
- //dp3 ta, ta, ta
- // Inverse of distance squared
- //ta = lightIntensity / ta
- // Mix above two together
- light = light*ta
- #else
- light = e
- #endif
- // Exposure
- light = light * exposure
- pow light.x, e, light.x
- pow light.y, e, light.y
- pow light.z, e, light.z
- light = one-light
- color = color*light
- oc = color
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement