Advertisement
Guest User

Untitled

a guest
Dec 29th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. alias v0, pos
  2. alias v1, uv
  3. alias v2, lvt
  4. alias v3, norm
  5. alias fc0, zero
  6. alias fc1, one
  7. alias fc2, half
  8. alias fc3, two
  9. alias fc4, lightDir
  10. alias fc5, solidColor
  11. alias fc6, lightPos
  12. alias fc7.x, lightIntensity
  13. alias fc7.y, exposure
  14. alias fc7.z, e
  15. alias ft0, color
  16. alias ft1, light
  17. alias ft2, ta
  18. // Surface vector
  19. alias ft3, sv
  20. alias fs0, normalMap
  21.  
  22. #define PARALLEL_LIGHT              0
  23. #define DIRECTIONAL_LIGHT           0
  24. #define DIRECTIONAL_LIGHT_NORMALMAP 1
  25.  
  26. // Solid color
  27. color = solidColor
  28.  
  29. ft3 = tex<2d,linear,linear>(v1, fs0)
  30.  
  31. #if PARALLEL_LIGHT
  32.     dp3 light, lightDir, norm
  33.     max light, light, zero
  34.    
  35.    
  36. #elif DIRECTIONAL_LIGHT
  37.     light = zero
  38.    
  39.     // Angle of view to surface in ft1
  40.     ta = lightPos-pos
  41.     nrm light.xyz, ta
  42.     dp3 light, light, norm
  43.    
  44.     // Clamp to 0
  45.     max light, light, zero
  46.    
  47.     // Distance of surface from light
  48.    
  49.     // Distance^2
  50.     dp3 ta, ta, ta
  51.     // Inverse of distance squared
  52.     ta = lightIntensity / ta
  53.    
  54.     // Mix above two together
  55.     light = light*ta
  56.    
  57. #elif DIRECTIONAL_LIGHT_NORMALMAP
  58.     light = one
  59.    
  60.     sv = sv-half
  61.     sv = sv*two
  62.    
  63.     dp3 ta, sv, lvt
  64.    
  65.     // Distance of surface from light ^2
  66.     //dp3 ta, ta, ta
  67.     // Inverse of distance squared
  68.     //ta = lightIntensity / ta
  69.    
  70.     // Mix above two together
  71.     light = light*ta
  72.    
  73. #else
  74.     light = e
  75.  
  76. #endif
  77.  
  78. // Exposure
  79.     light = light * exposure
  80.     pow light.x, e, light.x
  81.     pow light.y, e, light.y
  82.     pow light.z, e, light.z
  83.     light = one-light
  84.  
  85.  
  86. color = color*light
  87.  
  88. oc = color
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement