<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Volumetric light</title>
<meta name="Microsoft Theme" content="zero 111">
</head>

<body background="_themes/zero/zertxtr.gif" bgcolor="#000000" text="#FFFFFF" link="#669966" vlink="#6699CC" alink="#999999"><!--mstheme--><font face="Arial, Arial, Helvetica">


<div align="center">
  
  <!--msthemeseparator--><p align="center"><img src="_themes/zero/zerrulea.gif" width="600" height="10"></p>
  
  <h1><!--mstheme--><font color="#6699CC"><i>Volumetric light</i><!--mstheme--></font></h1>
  <!--msthemeseparator--><p align="center"><img src="_themes/zero/zerrulea.gif" width="600" height="10"></p>
  <p align="justify" style="line-height: 150%">&nbsp;</p>
  <p style="line-height: 150%">
  <img border="0" src="images/VolumetricLightSmall.jpg" width="256" height="247"></p>
  <p align="justify" style="line-height: 150%">&nbsp;</p>
  <p align="justify" style="line-height: 150%">The volumetric light effect is 
  based on a simple ray-casting equation. The light consists of a number of 
  rays. Each ray runs from the lights origin along its given direction until it 
  either hits an object or its intensity has fallen below a certain threshold. 
  In Meshuggah the object is a text on the x/y plane. It would be way to 
  computationally expensive to have actual geometry for the text. The 
  ray/triangle hit tests would take up too much time considering the number of 
  rays we're using and the number of triangles required for high quality text 
  glyphs. The text will be a bitmap mask instead, representing the rectangular 
  area [ ( -1, -1 ), ( 1, 1 ) ] of the x/y plane. This way we only need a ray/plane 
  hit test per ray.</p>
  <p align="justify" style="line-height: 150%">&nbsp;</p>
  <p style="line-height: 150%">
  <img border="0" src="images/VolumetricLightFig1.gif" alt="Simplified ray/plane hit test for x/y plane" width="249" height="199"></p>
  <p align="justify" style="line-height: 150%">&nbsp;</p>
  <p align="justify" style="line-height: 150%">If a ray hits the x/y plane 
  within [ ( -1, -1 ), ( 1, 1 ) ] then the corresponding pixel value from the 
  bitmap mask determines whether the ray hit a glyph or not.</p>
  <p align="justify" style="line-height: 150%">To solve z-sorting problems we 
  need to render the volumetric light effect in three steps.</p>
  <ol>
    <li>
  <p align="justify" style="line-height: 150%; margin-bottom:4">For each ray, 
  draw the part from the origin of the light to its intersection point with the 
  x/y plane. At the intersection point the ray's intensity is set to <i>one by traveled 
  ray length</i>. Another distance based attenuation function can be used as 
  well.</p>
    </li>
    <li>
  <p align="justify" style="line-height: 150%; margin-bottom:4">Blend the bitmap mask onto the 
  result of the last render step.</p>
    </li>
    <li>
  <p align="justify" style="line-height: 150%; margin-bottom:4">For each ray that didn't hit a 
  text glyph, draw the part from its intersection point with the x/y plane to <i>
  infinity.</i></p>
    </li>
  </ol>
  <p align="justify" style="line-height: 150%">Note that for the third step in 
  order to compensate sudden changes in the result of a ray/plane hit test we store eight bit values in our bitmap mask, zero being <i>ray hits</i> and 
  255 being <i>ray doesn't hit.</i> This allows us to gradually fade the ray 
  when it comes close to a glyph by multiplying this value to the ray's intensity. 
  Alpha blending is turned on when rendering the rays. Both source and 
  destination blend factor are set to one. Smooth ray edges can be achieved by 
  applying a 1D gradient texture (black - white - black).</p>
  <p align="justify" style="line-height: 150%">The vertex and pixel shader are 
  simple and straightforward. 1D texture coordinate and ray color (the intensity 
  is already pre-multiplied at this point) are copied in the vertex shader. In 
  the pixel shader the interpolated ray color is modulated on the color fetched 
  from the 1D gradient texture and set to the final output color register <i>r0.</i></p>
  <p align="justify" style="line-height: 150%">&nbsp;</p>
  <!--webbot bot="Include" U-Include="footer.htm" TAG="BODY" startspan --><!--msthemeseparator--><p align="center"><img src="_themes/zero/zerrulea.gif" width="600" height="10"></p>
<p></p>
<p></p>
  <dl>
    <div align="center">
      <center>
      <dt>Last update on
      2002-03-17</dt>
      </center>
    </div>
    <div align="center">
      <center>
      <dd>
      <p align="center">&nbsp;</dd>
      </center>
    </div>
    <div align="center">
      <center>
      <dt>Meshuggah Demo and Effect browser.</dt>
      </center>
    </div>
    <div align="center">
      <center>
      <dt>Copyright © 2001, 2002
      <a href="mailto:carsten.wenzel@gmx.net?subject=Meshuggah Demo and Effect browser">Carsten Wenzel</a>.</dt>
      </center>
    </div>
    <div align="center">
      <center>
      <dt>All rights reserved.</dt>
      </center>
    </div>
  </dl>

<!--webbot bot="Include" i-checksum="22998" endspan --></div>


<!--mstheme--></font></body>

</html>
