Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

fog.inc

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.66 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // ======================================================================
  2. // inputs:
  3. //
  4. //   r11.w    = distance squared from vertex to camera
  5. //
  6. // outputs:
  7. //
  8. //   oFog
  9. //
  10. // ======================================================================
  11.  
  12. // ----------------------------------------------------------------------
  13. // calculate fog
  14.  
  15. // (distance)^2 * (density)^2 = (distance * density)^2
  16. mul r0.w, r11.w, cFog.w
  17. // log2(e) * (distance * density)^2
  18. mul r0.w, cLog2e, r0.w
  19. // 2^(log2(e) * (distance * density)^2) = (2^log2(e))^((distance * density)^2) = e^((distance * density)^2)
  20. exp r0.w, r0.w
  21. // 1 / (e^((distance * density)^2))
  22. rcp oFog, r0.w