Commits

Jason McKesson committed c82c1da

Issue #42: Added section on specular hardedge.

  • Participants
  • Parent commits f714b2a

Comments (0)

Files changed (8)

File Documents/Illumination/FalseEdge.png

Added
New image

File Documents/Illumination/LessFalseEdge.png

Added
New image

File Documents/Illumination/Tutorial 09.xml

                 These lighting models and rendering techniques can attempt to model cartoon styles
                 (typically called <quote>cel shading</quote>), paintbrush effects, pencil-sketch, or
                 other similar things. NPR techniques including lighting models, but they also do
-                other, non-lighting things, like drawing object silhouettes in an dark, ink
+                other, non-lighting things, like drawing object silhouettes in an dark, ink-like
                 color.</para>
             <para>Developing good NPR techniques is at least as difficult as developing good
                 photorealistic lighting models. For the most part, in this book, we will focus on

File Documents/Illumination/Tutorial 10.xml

                 </imageobject>
             </mediaobject>
         </figure>
-        <para>To toggle an indicator of the light's position, press the <keycap>y</keycap> key. The
-                <keycap>b</keycap> key will toggle rotation of the light. The <keycap>i</keycap> and
-                <keycap>k</keycap> keys move the light up and down respectively, while the
-                <keycap>j</keycap> and <keycap>l</keycap> will decrease and increase the light's
-            radius. Holding shift with these keys will move in smaller increments.</para>
+        <para>To toggle an indicator of the light's position, press the <keycap>Y</keycap> key. The
+                <keycap>B</keycap> key will toggle rotation of the light. The <keycap>I</keycap> and
+                <keycap>K</keycap> keys move the light up and down respectively, while the
+                <keycap>J</keycap> and <keycap>L</keycap> keys will decrease and increase the
+            light's radius. Holding shift with these keys will move in smaller increments.</para>
         <para>Most of the code is nothing we have not seen elsewhere. The main changes are at the top
             of the rendering function.</para>
         <example>

File Documents/Illumination/Tutorial 11.xml

                     </imageobject>
                 </mediaobject>
             </figure>
-            <para>The tutorial is controlled similarly to previous lighting tutorials. The
-                    <keycap>W</keycap>, <keycap>A</keycap>, <keycap>S</keycap>, and
-                    <keycap>D</keycap> keys control the orientation of the cylinder. Pressing the
-                    <keycap>T</keycap> key will swap between the scaled and unscaled cylinder. The
-                    <keycap>Y</keycap> key toggles the drawing of the light source. The
+            <para>The tutorial is controlled similarly to previous lighting tutorials. Clicking and
+                dragging with the right mouse button controls the orientation of the cylinder.
+                Pressing the <keycap>T</keycap> key will swap between the scaled and unscaled
+                cylinder. The <keycap>Y</keycap> key toggles the drawing of the light source. The
                     <keycap>B</keycap> key will toggle the light's rotation on/off. Pressing the
                     <keycap>Space Bar</keycap> toggles between drawing the uncolored cylinder and
                 the colored one.</para>
             In general, to produce a highlight the same size as a Phong one, you will need a larger
             Blinn exponent. Play around with the different exponents, to get a feel for what Blinn
             and Phong can and cannot achieve.</para>
+        <section>
+            <title>Hard Specular Edge</title>
+            <para>There are still a few artifacts in the rendering. For example, if you arrange the
+                light, object, and camera as follows, you can see this:</para>
+            <figure>
+                <title>Light Edge</title>
+                <mediaobject>
+                    <imageobject>
+                        <imagedata fileref="FalseEdge.png"/>
+                    </imageobject>
+                </mediaobject>
+            </figure>
+            <para>The cylinder looks like it has a very sharp corner. What causes this? It is caused
+                by this line in the shader:</para>
+            <programlisting language="glsl">blinnTerm = cosAngIncidence != 0.0 ? blinnTerm : 0.0;</programlisting>
+            <para>If the angle between the normal and the light direction is greater than 90
+                degrees, then we force the specular term to zero. The reason behind this is very
+                simple: we assume our surface is a closed object. Given that assumption, if the
+                normal at a location on the surface is facing away from the light, then this could
+                only happen if there is some other part of the surface between itself and the light.
+                Therefore, the surface cannot be directly illuminated by that light.</para>
+            <para>That is a reasonable assumption, and it certainly makes sense in reality. But
+                real-life objects don't have these kinds of hard specular lines. So what are we
+                missing in our model?</para>
+            <para>What we are missing is that point lights don't exist in the real world. Light
+                illumination does not come from a single, infinitely small location in space. Even
+                the size of the Sun relative to Earth has a significant area. So what this means is
+                that, for a given point on a surface, it could be in partial view of the light
+                source. Imagine Earth at sunset for an example: part of the sun is below the horizon
+                and part of it is not.</para>
+            <para>Since only part of the light is visible from that point on the surface, then only
+                part of the light contributes to the overall illumination. So at these places where
+                you might get hard specular boundaries, under more real lighting conditions, you
+                still get a semi-gentle fall-off.</para>
+            <para>That's all well and good, but modeling true area lights is difficult even for
+                simple cases. A much simpler way to resolve this is to not use such a low specular
+                exponent. This specular exponent is relatively small, leading to a very broad
+                specular highlight. If we restrict our use of a specular term to surfaces who's
+                specular exponent is reasonably large, we can prevent this artifact from
+                appearing.</para>
+            <para>Here is the same scene, but with a larger exponent:</para>
+            <figure>
+                <title>Improved Light Edge</title>
+                <mediaobject>
+                    <imageobject>
+                        <imagedata fileref="LessFalseEdge.png"/>
+                    </imageobject>
+                </mediaobject>
+            </figure>
+            <para>We could also adjust the specular reflectance, so that surfaces with a low
+                specular exponent also have a small specular reflectance.</para>
+        </section>
     </section>
     <section>
         <?dbhtml filename="Tut11 Gaussian.html" ?>

File Documents/Positioning/Tutorial 06.xml

                     <tbody>
                         <row>
                             <entry>Base Spin</entry>
-                            <entry><keycap>a</keycap></entry>
-                            <entry><keycap>d</keycap></entry>
+                            <entry><keycap>A</keycap></entry>
+                            <entry><keycap>D</keycap></entry>
                         </row>
                         <row>
                             <entry>Arm Raise</entry>
-                            <entry><keycap>w</keycap></entry>
-                            <entry><keycap>s</keycap></entry>
+                            <entry><keycap>W</keycap></entry>
+                            <entry><keycap>S</keycap></entry>
                         </row>
                         <row>
                             <entry>Elbow Raise</entry>
-                            <entry><keycap>r</keycap></entry>
-                            <entry><keycap>f</keycap></entry>
+                            <entry><keycap>R</keycap></entry>
+                            <entry><keycap>F</keycap></entry>
                         </row>
                         <row>
                             <entry>Wrist Raise</entry>
-                            <entry><keycap>t</keycap></entry>
-                            <entry><keycap>g</keycap></entry>
+                            <entry><keycap>T</keycap></entry>
+                            <entry><keycap>G</keycap></entry>
                         </row>
                         <row>
                             <entry>Wrist Spin</entry>
-                            <entry><keycap>z</keycap></entry>
-                            <entry><keycap>c</keycap></entry>
+                            <entry><keycap>Z</keycap></entry>
+                            <entry><keycap>C</keycap></entry>
                         </row>
                         <row>
                             <entry>Finger Open/Close</entry>
-                            <entry><keycap>q</keycap></entry>
-                            <entry><keycap>e</keycap></entry>
+                            <entry><keycap>Q</keycap></entry>
+                            <entry><keycap>E</keycap></entry>
                         </row>
                     </tbody>
                 </tgroup>

File Documents/Positioning/Tutorial 07.xml

                 <tbody>
                     <row>
                         <entry>Move camera target up/down</entry>
-                        <entry><keycap>e</keycap></entry>
-                        <entry><keycap>q</keycap></entry>
+                        <entry><keycap>E</keycap></entry>
+                        <entry><keycap>Q</keycap></entry>
                     </row>
                     <row>
                         <entry>Move camera target horizontally</entry>
-                        <entry><keycap>a</keycap></entry>
-                        <entry><keycap>d</keycap></entry>
+                        <entry><keycap>A</keycap></entry>
+                        <entry><keycap>D</keycap></entry>
                     </row>
                     <row>
                         <entry>Move camera target vertically</entry>
-                        <entry><keycap>w</keycap></entry>
-                        <entry><keycap>s</keycap></entry>
+                        <entry><keycap>W</keycap></entry>
+                        <entry><keycap>S</keycap></entry>
                     </row>
                     <row>
                         <entry>Rotate camera horizontally around target</entry>
-                        <entry><keycap>l</keycap></entry>
-                        <entry><keycap>j</keycap></entry>
+                        <entry><keycap>L</keycap></entry>
+                        <entry><keycap>J</keycap></entry>
                     </row>
                     <row>
                         <entry>Rotate camera vertically around target</entry>
-                        <entry><keycap>i</keycap></entry>
-                        <entry><keycap>k</keycap></entry>
+                        <entry><keycap>I</keycap></entry>
+                        <entry><keycap>K</keycap></entry>
                     </row>
                     <row>
                         <entry>Move camera towards/away from target</entry>
-                        <entry><keycap>u</keycap></entry>
-                        <entry><keycap>o</keycap></entry>
+                        <entry><keycap>U</keycap></entry>
+                        <entry><keycap>O</keycap></entry>
                     </row>
                 </tbody>
             </tgroup>

File Documents/Positioning/Tutorial 08.xml

                 </imageobject>
             </mediaobject>
         </figure>
-        <para>You can control the orientation of each gimbal separately. The <keycap>w</keycap> and
-                <keycap>s</keycap> keys control the outer gimbal, the <keycap>a</keycap> and
-                <keycap>d</keycap> keys control the middle gimbal, and the <keycap>q</keycap> and
-                <keycap>e</keycap> keys control the inner gimbal. If you just want to see (and
+        <para>You can control the orientation of each gimbal separately. The <keycap>W</keycap> and
+                <keycap>S</keycap> keys control the outer gimbal, the <keycap>A</keycap> and
+                <keycap>D</keycap> keys control the middle gimbal, and the <keycap>Q</keycap> and
+                <keycap>E</keycap> keys control the inner gimbal. If you just want to see (and
             affect) the orientation of the ship, press the <keycap>SpaceBar</keycap> to toggle
             drawing the gimbal rings.</para>
         <para>The first thing you discover when attempting to use the gimbals to orient the ship is