module-GodRaysShader.html 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>GodRaysShader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">GodRaysShader</h1>
  13. <section>
  14. <header>
  15. </header>
  16. <article>
  17. <h2 class="subsection-title">Import</h2>
  18. <p><span translate="no">GodRaysShader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  19. <pre><code class="language-js">import * as GodRaysShader from 'three/addons/shaders/GodRaysShader.js';</code></pre>
  20. <div class="container-overview">
  21. </div>
  22. <h2 class="subsection-title">Properties</h2>
  23. <div class="member">
  24. <h3 class="name" id="~GodRaysCombineShader" translate="no">.<a href="#~GodRaysCombineShader">GodRaysCombineShader</a><span class="type-signature"> : <a href="ShaderMaterial.html#~Shader">ShaderMaterial~Shader</a></span> <span class="type-signature">(inner, constant) </span></h3>
  25. <div class="description">
  26. <p>Additively applies god rays from texture tGodRays to a background (tColors).
  27. fGodRayIntensity attenuates the god rays.</p>
  28. </div>
  29. </div>
  30. <div class="member">
  31. <h3 class="name" id="~GodRaysDepthMaskShader" translate="no">.<a href="#~GodRaysDepthMaskShader">GodRaysDepthMaskShader</a><span class="type-signature"> : <a href="ShaderMaterial.html#~Shader">ShaderMaterial~Shader</a></span> <span class="type-signature">(inner, constant) </span></h3>
  32. <div class="description">
  33. <p>God-rays (crepuscular rays)</p>
  34. <p>Similar implementation to the one used by Crytek for CryEngine 2 [Sousa2008].
  35. Blurs a mask generated from the depth map along radial lines emanating from the light
  36. source. The blur repeatedly applies a blur filter of increasing support but constant
  37. sample count to produce a blur filter with large support.</p>
  38. <p>My implementation performs 3 passes, similar to the implementation from Sousa. I found
  39. just 6 samples per pass produced acceptable results. The blur is applied three times,
  40. with decreasing filter support. The result is equivalent to a single pass with
  41. 6<em>6</em>6 = 216 samples.</p>
  42. <p>References:</p>
  43. <ul>
  44. <li><a href="http://www.crytek.com/sites/default/files/GDC08_SousaT_CrysisEffects.ppt" target="_blank" rel="noopener">Sousa2008, Crysis Next Gen Effects, GDC2008</a>.</li>
  45. </ul>
  46. </div>
  47. </div>
  48. <div class="member">
  49. <h3 class="name" id="~GodRaysFakeSunShader" translate="no">.<a href="#~GodRaysFakeSunShader">GodRaysFakeSunShader</a><span class="type-signature"> : Object</span> <span class="type-signature">(inner, constant) </span></h3>
  50. <div class="description">
  51. <p>A dodgy sun/sky shader. Makes a bright spot at the sun location. Would be
  52. cheaper/faster/simpler to implement this as a simple sun sprite.</p>
  53. </div>
  54. </div>
  55. <div class="member">
  56. <h3 class="name" id="~GodRaysGenerateShader" translate="no">.<a href="#~GodRaysGenerateShader">GodRaysGenerateShader</a><span class="type-signature"> : <a href="ShaderMaterial.html#~Shader">ShaderMaterial~Shader</a></span> <span class="type-signature">(inner, constant) </span></h3>
  57. <div class="description">
  58. <p>The god-ray generation shader.</p>
  59. <p>First pass:</p>
  60. <p>The depth map is blurred along radial lines towards the &quot;sun&quot;. The
  61. output is written to a temporary render target (I used a 1/4 sized
  62. target).</p>
  63. <p>Pass two &amp; three:</p>
  64. <p>The results of the previous pass are re-blurred, each time with a
  65. decreased distance between samples.</p>
  66. </div>
  67. </div>
  68. <h2 class="subsection-title">Source</h2>
  69. <p>
  70. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/shaders/GodRaysShader.js" translate="no" target="_blank" rel="noopener">examples/jsm/shaders/GodRaysShader.js</a>
  71. </p>
  72. </article>
  73. </section>
  74. <script src="../scripts/linenumber.js"></script>
  75. <script src="../scripts/page.js"></script>
  76. </body>
  77. </html>
粤ICP备19079148号