Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4084

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>

-->
<head>
<title>Crystal Space 1.2.1: 5.9.3 Shading</title>

<meta name="description" content="Crystal Space 1.2.1: 5.9.3 Shading">
<meta name="keywords" content="Crystal Space 1.2.1: 5.9.3 Shading">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="g_t3D-Sprites-Example-3"></a>
<a name="0"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="3D-Sprites-Example-2.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="ViewMesh.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="3D-Sprites.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Internals.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<hr size="1">
<h3 class="subsection"> 5.9.3 Shading </h3>

<p>Separating the ends of the cylinder sprite for texturing
(see section <a href="3D-Sprites-Example-2.html#0">Texturing</a>) has a fortunate side effect.  It separates the
surface normals of the vertices as well as the texture coordinates.
</p>
<p>Surface normals are used for shading the sprite.  Light colors each vertex
based on the average normal of all of the triangles that share that vertex.
When all of the vertices in our sprite are shared, all of the edges look
smooth&mdash;even the edges between the sides and the ends of the cylinder.
With the ends separated, that edge is now sharply defined.
</p>
<p><img src="content/sprites/unseamly.jpg" alt="content/sprites/unseamly">
</p>
<p>Unfortunately, we have also split one edge of the cylinder's sides, which
creates a sharply defined edge where we don't want it.  We could reconnect
the shared vertices along that edge, but then we would have to texture the
sides differently&mdash;the sides would either curve ackwardly or overlap.
</p>
<p>We are stuck with an unwanted edge or a difficult texturing job until we
can find a way to connect vertex normals without connecting skin vertices.
One way we might be able to do this is by interfering with vertex normal
calculation.  We would simply mark certain vertices as needing to be blended
together during or after vertex normal calculation.  We would still have
98 vertex normals, but two pairs of them would be averaged together.
</p>
<p>One way we might mark which vertices should be blended this way, would be
to create a special frame in the 3D Sprite where all of the blended vertices
are touching.  In the case of our cylinder, the ends would be pulled away
from the sides but the sides would form a complete loop so that vertices we
split for texturing would be blended for shading.
</p>
<p><img src="content/sprites/split.jpg" alt="content/sprites/split">
</p>

<p>The simplest way to apply the blending would be by averaging the vertex
normals after vertex normal calculation. It would probably be more accurate
to re-calculate the vertex normal by averaging the normals of all of the
triangles connected to both vertices.  Vertex normals can be pre-calculated&mdash;
especially if you are using pre-calculated vertex animation anyway.  So
the blending effect might only have to be applied once.
</p>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="3D-Sprites-Example-2.html#0" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="ViewMesh.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="3D-Sprites.html#0" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="Internals.html#0" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
 </font>
 <br>

</p>
</body>
</html>