<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="/xslt/html.xsl"?>
<page 
	title="software - processing.org - depthshader"
	description="processing.org library"
	keywords="processing, processing.org, sketches, java, applets">
	<content>

		<paragraph title="Processing - DepthShader library">
			This is a simple library to shade according to ''screendepth''. Instead
			of simply using the Z-coordinate to shade an object, this library
			enables shading regardless of translation, rotation and/or scaling. In
			other words, it will enable you to shade an object according to its
			apparent depth on screen, regardless of transformations.
		</paragraph>
		<paragraph title="Usage">
			<ul>
				<li><link target="_self" url="dl/depthshader.zip">Download the
						.ZIP</link> and unpack it in the <i>libraries</i> folder of your
					Processing installation</li>
				<li>(re)start Processing</li>
				<li>Check out the example <link url="demo/">here</link></li>
			</ul>
		</paragraph>
		<paragraph title="How It Works">
			The DepthShader class keeps track of minimum and maximum values
			returned by the <link
				url="http://dev.processing.org/reference/core/javadoc/processing/core/PGraphics.html#screenZ(float,%20float,%20float)">.screenZ()</link>
			method and uses mappers (see below) to map each <code>x,y,z</code>
			triplet to fit between these extremities. By default, a simple linear
			mapper will be used.
		</paragraph>
		<paragraph title="How to make your own mapping class">
			Mappers are implementations of the interface <code>DepthMapper</code>,
			which contains a method with the signature <code>public float map(float
				value, float min, float max, float from, float to)</code>
		</paragraph>
		<paragraph>
			Description of parameters:
			<table border="0">
				<tr>
					<td><code>value</code></td><td>current depthvalue to consider</td>
				</tr>
				<tr>
					<td><code>min</code></td><td>minimum recorded depthvalue</td>
				</tr>
				<tr>
					<td><code>max</code></td><td>maximum recorded depthvalue</td>
				</tr>
				<tr>
					<td><code>from</code></td><td>lower end of range to map depthvalues to (passed as argument to constructor of DepthShader class)</td>
				</tr>
				<tr>
					<td><code>to</code></td><td>higher end of range to map depthvalues to (passed as argument to constructor of DepthShader class)</td>
				</tr>
			</table>
		</paragraph>
		<paragraph>
			Check out <link url="demo/DepthShaderDemo.pde">the demo code</link> for
			examples on how to implement a mapper.
		</paragraph>
		<paragraph title="Source">
			The sourcecode is included in the library .JAR file.
		</paragraph>
		<paragraph title="See also">
			<link target="_self" url="../lissajous3d">This sketch</link> also uses
			this library.
		</paragraph>

	</content>
</page>

