module-Bayer.html 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Bayer - 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">Bayer</h1>
  13. <section>
  14. <header>
  15. </header>
  16. <article>
  17. <h2 class="subsection-title">Import</h2>
  18. <p><span translate="no">Bayer</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 { bayer16 } from 'three/addons/tsl/math/Bayer.js';</code></pre>
  20. <div class="container-overview">
  21. </div>
  22. <h2 class="subsection-title">Static Methods</h2>
  23. <h3 class="name name-method" id=".bayer16" translate="no">.<a href="#.bayer16">bayer16</a><span class="signature">( uv : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec2></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec4></span> </h3>
  24. <div class="method">
  25. <div class="description">
  26. <p>This TSL function can be used to sample a Bayer16 texture which is a 16x16 texture with a Bayer Matrix pattern.
  27. It can be used for dithering effects but also as an alternative to blue-noise. When used with Ray Marching
  28. specifically in <a href="VolumeNodeMaterial.html#offsetNode">VolumeNodeMaterial#offsetNode</a>, it reduces banding problem, thus being able to use
  29. fewer steps without affecting the visuals as much.</p>
  30. </div>
  31. <table class="params">
  32. <tbody>
  33. <tr>
  34. <td class="name">
  35. <strong translate="no">uv</strong>
  36. </td>
  37. <td class="description last">
  38. <p>The uv to sample the bayer16 texture.</p>
  39. </td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. <dl class="details">
  44. <dt class="tag-returns"><strong>Returns:</strong> The sampled bayer value.</dt>
  45. </dl>
  46. </div>
  47. <h3 class="name name-method" id=".bayerDither" translate="no">.<a href="#.bayerDither">bayerDither</a><span class="signature">( color : <span class="param-type"><a href="Node.html">Node</a>.&lt;vec3></span>, steps : <span class="param-type"><a href="Node.html">Node</a>.&lt;float></span> )</span><span class="type-signature"> : <a href="Node.html">Node</a>.&lt;vec3></span> </h3>
  48. <div class="method">
  49. <div class="description">
  50. <p>This TSL function applies Bayer dithering to a color input. It uses a 4x4 Bayer matrix
  51. pattern to add structured noise before color quantization, which helps reduce visible
  52. color banding when limiting color depth.</p>
  53. </div>
  54. <table class="params">
  55. <tbody>
  56. <tr>
  57. <td class="name">
  58. <strong translate="no">color</strong>
  59. </td>
  60. <td class="description last">
  61. <p>The input color to apply dithering to.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong translate="no">steps</strong>
  67. </td>
  68. <td class="description last">
  69. <p>The number of color steps per channel.</p>
  70. <p>Default is <code>32</code>.</p>
  71. </td>
  72. </tr>
  73. </tbody>
  74. </table>
  75. <dl class="details">
  76. <dt class="tag-returns"><strong>Returns:</strong> The dithered color ready for quantization.</dt>
  77. </dl>
  78. </div>
  79. <h2 class="subsection-title">Source</h2>
  80. <p>
  81. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/math/Bayer.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/math/Bayer.js</a>
  82. </p>
  83. </article>
  84. </section>
  85. <script src="../scripts/linenumber.js"></script>
  86. <script src="../scripts/page.js"></script>
  87. </body>
  88. </html>
粤ICP备19079148号