<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arbitrary Output</title>
	<atom:link href="http://sitexgraphics.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://sitexgraphics.com/blog</link>
	<description>rendering with SiTex Graphics Air</description>
	<lastBuildDate>Tue, 21 May 2013 18:09:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Air Stream for Maya 2014</title>
		<link>http://sitexgraphics.com/blog/?p=145</link>
		<comments>http://sitexgraphics.com/blog/?p=145#comments</comments>
		<pubDate>Tue, 21 May 2013 18:09:35 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Maya]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=145</guid>
		<description><![CDATA[The latest archive of the Air Stream plug-in for Maya includes builds for Maya 2014. Air Stream works well with the latest version of Maya, but you may need to perform one additional installation step if you wish Air Stream &#8230; <a href="http://sitexgraphics.com/blog/?p=145">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The latest archive of the Air Stream plug-in for Maya includes builds for Maya 2014.</p>
<p>Air Stream works well with the latest version of Maya, but you may need to perform one additional installation step if you wish Air Stream to automatically load when Maya starts:</p>
<p>Create an environment variable named MAYA_PLUG_IN_PATH and assign the full file path to the Air Stream plug-ins directory.  If the environment variable already exists, append the Air Stream plug-ins path to the list.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=145</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fake Carpet shader</title>
		<link>http://sitexgraphics.com/blog/?p=132</link>
		<comments>http://sitexgraphics.com/blog/?p=132#comments</comments>
		<pubDate>Mon, 08 Apr 2013 22:11:46 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Shaders]]></category>
		<category><![CDATA[renderman]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=132</guid>
		<description><![CDATA[Air 12.09 introduces a new FakeCarpet surface shader that turns a simple rectangle into a patch of fuzzy carpet.  The carpet effect is produced by ray tracing a virtual field of carpet fibers inside the surface shader; no additional geometry &#8230; <a href="http://sitexgraphics.com/blog/?p=132">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2013/04/fakecarpet_top.png"><img class="alignnone size-full wp-image-133" title="fakecarpet_top" src="http://sitexgraphics.com/blog/wp-content/uploads/2013/04/fakecarpet_top.png" alt="fake carpet shader sample" width="640" height="360" /></a></p>
<p>Air 12.09 introduces a new FakeCarpet surface shader that turns a simple rectangle into a patch of fuzzy carpet.  The carpet effect is produced by ray tracing a virtual field of carpet fibers inside the surface shader; no additional geometry is created in the scene.  This blog post provides a list of the required steps for creating fake carpet, followed by tips for tuning the shape, shading, and sampling parameters of the shader.</p>
<h3>Getting Started</h3>
<p>Here&#8217;s how to add carpet to a room model:</p>
<ul>
<li>Create a four-sided polygon and position it slightly above the floor.  The polygon should represent the top of the area to be covered by the carpet.  Make the polygon invisible to shadow rays.</li>
<li>Assign the FakeCarpet surface shader.  You will probably want to disable the material preview window in your application when tuning this shader because the preview render can take a long time.</li>
<li>Set the SizeX and SizeY parameters to the width and length of the carpet rectangle.  SizeX gives the size along the first texture coordinate axis, SizeY the size along the second texture coordinate axis.</li>
<li>Set StrandLength to the length of the carpet fibers, which should be less than or equal to the height of the polygon above the floor.</li>
</ul>
<p>That completes the the required steps to use the FakeCarpet shader.  You should then be able to render a test image of your scene and see some carpet.</p>
<h3>Carpet Shape</h3>
<p>The carpet is modeled as a grid of carpet fibers.  The geometric model of the fibers can be tuned using the following parameters:</p>
<p><em>StrandCount, StrandWidthFraction</em></p>
<p style="padding-left: 30px;">The overall density of the fibers is set with StrandCount, which gives the number of fibers per unit length.  The diameter of a fiber is given by the StrandWidthFraction parameter as a fraction of the fiber length.</p>
<p><em>StrandTiltAngle, StrandTiltVary, StrandTiltFrequency, StrandStiffness<br />
</em><em>StrandPolarAngle, StrandPolarVary, StrandPolarFrequency</em></p>
<p style="padding-left: 30px;">Individual fibers are represented as curved tubes.  StrandTiltAngle gives the average angle (in degrees) between the vertical direction and the tip of a fiber.  The tilt angle can be varied for each fiber using StrandTiltVary and StrandTiltFrequency.   StrandTiltFrequency is relative to the entire patch of carpet.  StrandStiffness controls how each fiber bends.  Higher values push the curve more toward the tip of each tube.</p>
<p style="padding-left: 30px;">The direction of tilt can be changed using the StrandPolar parameters, which control a rotation in degrees about the vertical axis.</p>
<p><em>StrandSegments, TraceTip, TraceJoint</em></p>
<p style="padding-left: 30px;">Each fiber is represented as a chain of tubular line segments.  StrandSegments gives the number of segments per fiber.  Each segment can be  capped with a sphere.  TraceTip controls whether a sphere is traced at  the tip of each fiber.  TraceJoints controls whether spheres are traced  at the joints between segments in a fiber.</p>
<h3>Carpet Shading</h3>
<p>The carpet is shaded using an empirical model that assumes some light is reflected from the front of each fiber and some is transmitted.</p>
<p><em>FrontScatter, BackScatter, ScatterPower</em></p>
<p style="padding-left: 30px;">FrontScatter gives the fraction of  light reflected from the front of a fiber.  BackScatter gives the amount  transmitted from behind.  Both are modulated based on the angle between the shading normal and the view direction such that more light is transmitted along the  fiber edges and less in the middle.  The ScatterPower parameter is an  exponent applied to the angle cosine used for this edge-based variation.</p>
<p><em>SelfShadowMax, ColorMapName, BaseColor, IndirectDiffuse<br />
</em></p>
<p style="padding-left: 30px;">SelfShadowMax gives the maximum self-shadowing of the carpet (the  shadowing effect of neighboring fibers).  Self-shadowing is greatest at the base of each fiber and smoothly attenuates to zero at the tip.</p>
<p>ColorMapName allows a color map to be applied to the fibers.</p>
<p>BaseColor gives the color of the &#8220;fabric&#8221; under the fibers, which is visible  where fibers are missing.</p>
<p style="padding-left: 30px;">IndirectDiffuse is a simple multiplier for the diffuse result returned  for indirect illumination.  The shader does not trace fibers for indirect  rays.</p>
<h3>Carpet Trace Controls</h3>
<p>The FakeCarpet shader performs ray tracing to determine which fibers are visible at each shading location.  The following parameters control this internal ray tracing process<em>:</em></p>
<p><em>SampleGridSize</em></p>
<p style="padding-left: 30px;">Because the carpet fibers will typically be much smaller than a pixel, the shader provides an option to trace multiple rays to produce a smoother, more accurate result.  SampleGridSize defines the size of an NxN grid of rays to trace at the current shading location.  The grid size is automatically reduced to 1 for reflection rays and IPR (interactive preview) rendering.</p>
<p><em>TraceMargin</em></p>
<p style="padding-left: 30px;">The FakeCarpet shader treats the rectangular polygon as a sort of window into a virtual grid of 3D fibers.  There can be artifacts along the edges if this &#8220;window&#8221; clips the carpet.  To help prevent those artifacts, the TraceMargin  parameter strips away a fraction of the fibers along the carpet border.   Larger values remove more rows of fibers.</p>
<p><em>TestForIntersection</em>s<em>, TraceBias</em></p>
<p style="padding-left: 30px;">TestForIntersections determines whether the shader checks  for objects intersecting the carpet (such as a chair leg).  If there are  no objects on the carpet, set this parameter to 0 to save some time and  potentially avoid some artifacts.  The TraceBias parameter gives an  offset used to avoid incorrect intersections in this test.</p>
<h3>Final Remarks</h3>
<p>The FakeCarpet surface is a fairly complicated shader, and you will likely need to experiment with the parameters to reproduce the appearance of a particular type of carpet.  An IPR session (utilizing TweakAir) can be used to interactively view the effects of parameter changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=132</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast spherical lights</title>
		<link>http://sitexgraphics.com/blog/?p=124</link>
		<comments>http://sitexgraphics.com/blog/?p=124#comments</comments>
		<pubDate>Fri, 28 Sep 2012 22:45:46 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Shaders]]></category>
		<category><![CDATA[lights]]></category>
		<category><![CDATA[massive]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=124</guid>
		<description><![CDATA[A spherical light source can provide more realistic illumination than a traditional point light because it gives the light an actual size and shape.  The usual way to render a sphere light is to use an area light shader with &#8230; <a href="http://sitexgraphics.com/blog/?p=124">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A spherical light source can provide more realistic illumination than a traditional point light because it gives the light an actual size and shape.  The usual way to render a sphere light is to use an area light shader with sphere geometry.  That approach works, but it has some drawbacks:</p>
<ul>
<li>Render time can be significantly slower because the area light shader must be evaluated at many different locations on the sphere to produce a smooth result.</li>
<li>Some software (such as Massive) does not provide an interface for area lights.</li>
</ul>
<p>To address those drawbacks we&#8217;ve put together a spherelight light shader that can be used to simulate the effect of a spherical light source using a standard point-type light.  Download the shader and sample scene files here:</p>
<p><a href="http://www.sitexgraphics.com/spherelight.zip" target="_blank">http://www.sitexgraphics.com/spherelight.zip</a></p>
<p>The shader is very similar to the pointlight shader included with Air.  There is a new lightradius parameter for the radius of the (virtual) spherical light source.  The shader uses the light radius in a couple computations that approximate the effects of a spherical source:</p>
<ol>
<li>Shadows are blurry close to the source and sharper farther away.  The shader simulates this effect by computing a shadow blur angle based on the distance to the light source and the light radius:
<pre>lenL=max(sqrt(L.L),radius);
blur = abs(atan(radius,sqrt(lenL*lenL-radius*radius)));
</pre>
</li>
<li>For locations close to the sphere surface, the light source no longer behaves as an idealized point light.  The shader accounts for this by supersampling the sphere surface (in the spherefactor() function) to account for the variation in incoming illumination from different parts of the sphere surface.</li>
</ol>
<p>The images below compare the results for a true spherical area light (top)  with 64 light samples and the spherelight shader (bottom) using 64 shadow rays.</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/09/arealight.png"><img class="alignnone size-full wp-image-125" title="arealight" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/09/arealight.png" alt="" width="640" height="440" /></a></p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/09/spherelight.png"><img class="alignnone size-full wp-image-126" title="spherelight" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/09/spherelight.png" alt="" width="640" height="440" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=124</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharp edges and smooth shading normals in Massive</title>
		<link>http://sitexgraphics.com/blog/?p=120</link>
		<comments>http://sitexgraphics.com/blog/?p=120#comments</comments>
		<pubDate>Mon, 20 Aug 2012 20:36:27 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Massive]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=120</guid>
		<description><![CDATA[The Problem A user wants to import an object with both sharp edges and smooth edges into Massive for rendering with Air.   This should be easy except that Massive only allows one shading normal per vertex, and Massive automatically smooths &#8230; <a href="http://sitexgraphics.com/blog/?p=120">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;">The Problem</span></p>
<p>A user wants to import an object with both sharp edges and smooth edges into Massive for rendering with Air.   This should be easy except that Massive only allows one shading normal per vertex, and Massive automatically smooths any vertex that is shared by more than one face.</p>
<p><span style="text-decoration: underline;">The Solution</span> (reported by Air and Massive user Charlie Peterson)</p>
<p>In Maya separate the faces into two objects, to be exported as two separate OBJ files.   All faces that should appear flat with sharp edges go in one file; all faces that should appear smooth go in another.  For faces with sharp edges, each vertex must be unique; i.e., not shared with any other face in the model.  In Maya this can be accomplished by using the Detach Component action in the Edit Mesh menu.  The two sets of faces can then be exported as OBJ files without shading normals or smoothing groups.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=120</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a background plate to a Massive crowd rendering</title>
		<link>http://sitexgraphics.com/blog/?p=114</link>
		<comments>http://sitexgraphics.com/blog/?p=114#comments</comments>
		<pubDate>Mon, 09 Jul 2012 21:48:08 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Massive]]></category>
		<category><![CDATA[massive]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=114</guid>
		<description><![CDATA[A user recently asked how to render a preview image with Air from Massive that included a background plate.   The Massive camera node includes an option to specify a background image, but that setting is not exported to rib for &#8230; <a href="http://sitexgraphics.com/blog/?p=114">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A user recently asked how to render a preview image with Air from Massive that included a background plate.   The Massive camera node includes an option to specify a background image, but that setting is not exported to rib for rendering with Air.  Hopefully Massive Software will add this feature in a future release; until then, here are a couple alternatives:</p>
<p>Option 1:  Use a small options file with an imager shader to add a background image:</p>
<ul>
<li>Create a small text file with the following imager declaration:</li>
</ul>
<blockquote>
<pre>Imager "VBackdrop" "string TextureName" "nameofbgimage.jpg"</pre>
</blockquote>
<ul>
<li>Enter the options rib file name as the &#8220;options rib include&#8221; entry in the &#8216;render parameters&#8217; tab of the renders dialog.</li>
<li>Drawback:  the imager shader will be included in the rib export for preview rendering and normal rendering.  If you do not wish to include the background image in final rendering, you&#8217;ll need to remove the options reference prior to exporting ribs for the final render.</li>
</ul>
<p>Option 2:  Use Air Show to view the rendered preview image with a background plate</p>
<ul>
<li>Air Show has an option to display a rendered image over a background plate, but that option is only available for images with an alpha channel.  Unfortunately, the Massive preview image is always &#8220;rgb&#8221; only, so again this is not as easy as one might hope.</li>
<li>A solution is to render the preview rib from a command shell and use Air&#8217;s command line options to override the output declaration to include an alpha channel.</li>
<li>When rendering a preview image with Air, Massive exports the rib files and other data to $TEMP/massive.  To render the preview rib from a command shell:</li>
</ul>
<blockquote>
<pre>cd $TEMP
cd massive
air -d -mode rgba massive.rib</pre>
</blockquote>
<ul>
<li>You can leave the command shell open and re-launch the last command for each preview.  Note that this means each preview will be rendered twice.  If the preview render takes more than a few seconds, you can use the red stop button in Air Show to abort the first preview render.</li>
<li>To load the background image in Air Show, select Load Background from the View menu.  Use the checkered toolbar button to enable or disabled display of the background for the current image.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=114</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Animated Ocean Waves</title>
		<link>http://sitexgraphics.com/blog/?p=103</link>
		<comments>http://sitexgraphics.com/blog/?p=103#comments</comments>
		<pubDate>Fri, 01 Jun 2012 22:06:48 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Shaders]]></category>
		<category><![CDATA[dso]]></category>
		<category><![CDATA[renderman]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=103</guid>
		<description><![CDATA[Air 11.08 and later includes a new set of shaders for rendering animated ocean waves based on Jerry Tessendorf&#8217;s paper &#8220;Simulating Ocean Water&#8221;.  The shaders are: OceanWaves &#8211; displacement shader for the waves OceanSurface &#8211; surface shader for deep ocean &#8230; <a href="http://sitexgraphics.com/blog/?p=103">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Air 11.08 and later includes a new set of shaders for rendering animated ocean waves based on Jerry Tessendorf&#8217;s paper &#8220;Simulating Ocean Water&#8221;.  The shaders are:</p>
<p style="padding-left: 30px;">OceanWaves &#8211; displacement shader for the waves<br />
OceanSurface &#8211; surface shader for deep ocean<br />
OceanSurfaceWithForm &#8211; surface shader for deep ocean with foam at wave peaks</p>
<p>The following images use the ocean surface shaders along with the physical sky environment shader.</p>
<p>The underlying wave algorithm can simulate a variety of ocean conditions from calm seas to stormy waves depending on the wind speed:</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind5.png"><img class="alignnone size-full wp-image-105" title="ocean_wind5" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind5.png" alt="ocean wind speed 5" width="640" height="360" /></a></p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind10.png"><img class="alignnone size-full wp-image-106" title="ocean_wind10" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind10.png" alt="" width="640" height="360" /></a></p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20.png"><img class="alignnone size-full wp-image-107" title="ocean_wind20" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20.png" alt="" width="640" height="360" /></a></p>
<p>The appearance of waves in windy conditions can be improved by adding chop, which sharpens wave peaks and stretches troughs by shifting the surface laterally:</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20_chop2.png"><img class="alignnone size-full wp-image-108" title="ocean_wind20_chop2" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20_chop2.png" alt="" width="640" height="360" /></a></p>
<p>Because the chop displacement shifts the surface in arbitrary directions, you&#8217;ll need to tell Air that the displacement is not strictly in the direction of the surface normal by applying the following attribute:</p>
<pre>Attribute "render" "normaldisplacement" [0]</pre>
<p>Note that too much chop can tear the surface apart.</p>
<p>Finally, the OceanSurfaceWithFoam surface shader allows foam to be rendered near wave peaks.  In order for the foam to appear in the proper location, the common parameters between the OceanWaves and OceanSurfaceWithFoam shaders must be set to the same values.</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20_chop2_foam.png"><img class="alignnone size-full wp-image-109" title="ocean_wind20_chop2_foam" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/06/ocean_wind20_chop2_foam.png" alt="ocean with foam" width="640" height="360" /></a></p>
<p>If you do not need to render foam, set the FoamEnabled parameter of the OceanWaves shader to 0 to reduce computation time for the waves.</p>
<p>Wave animation is controlled by the current frame number and the FramesPerSecond parameter value.</p>
<p>The waves can be tiled in X and Y; the above pictures are a 2&#215;2 grid of the same wave pattern.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=103</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Air Point Cloud File Format</title>
		<link>http://sitexgraphics.com/blog/?p=99</link>
		<comments>http://sitexgraphics.com/blog/?p=99#comments</comments>
		<pubDate>Mon, 30 Apr 2012 17:33:09 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[point clouds]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=99</guid>
		<description><![CDATA[Air can save and re-use point-based data for effects such as indirect illumination, occlusion, subsurface scattering, and caustics.  The Air Point Tool (airpt) included with Air allows point data to be translated to and from several formats including a simple &#8230; <a href="http://sitexgraphics.com/blog/?p=99">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Air can save and re-use point-based data for effects such as indirect illumination, occlusion, subsurface scattering, and caustics.  The Air Point Tool (airpt) included with Air allows point data to be translated to and from several formats including a simple text format.  However, some users have requested information on the native Air Point Cloud (.apc) format used to store unstructured point data.  We&#8217;ve uploaded the source code for a simple APC reader <a title="printapc" href="http://www.sitexgraphics.com/printapc.zip">here</a>.</p>
<p>An Air point cloud is a simple binary file with a short header followed by a list of records, one record for each point.  Here&#8217;s the header:</p>
<pre>
typedef struct {
  char diName[48];
  int diType, diNarr, diIndex, diSize;
} DataInfo;

typedef struct {
  char id[4];
  unsigned int hsize;
  float gbound[6];
  float world2camera[16], world2ndc[16];
  int xres, yres;
  float par, fov;
  int flags;
  int maxdepth, maxleafsize;
  int nbrick, bricksize;
  int nbiv,npts;
  unsigned int ptoffset;
  float minwidth, maxwidth;
  int pad[256];
  int ndata,datasize;
  DataInfo di[64];
} AirPointHeader;
</pre>
<p>The ptoffset field gives the file position where the actual data begins.  The data for each point is stored as a binary array of floats with little-endian byte order.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=99</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to render an object&#8217;s x,y,z position</title>
		<link>http://sitexgraphics.com/blog/?p=88</link>
		<comments>http://sitexgraphics.com/blog/?p=88#comments</comments>
		<pubDate>Tue, 28 Feb 2012 22:14:16 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Passes]]></category>
		<category><![CDATA[Shaders]]></category>
		<category><![CDATA[passes]]></category>
		<category><![CDATA[renderman]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=88</guid>
		<description><![CDATA[A user asked how to render an object&#8217;s world-space position into an image.  To address this question, we&#8217;ve included a new ShowPosition surface shader in Air 11.04 and later.  Here are the shader parameters: Surface "ShowPosition" "float UnitSize" [1] "float[3] &#8230; <a href="http://sitexgraphics.com/blog/?p=88">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A user asked how to render an object&#8217;s world-space position into an image.  To address this question, we&#8217;ve included a new ShowPosition surface shader in Air 11.04 and later.  Here are the shader parameters:</p>
<pre>Surface "ShowPosition"
 "float UnitSize" [1]
 "float[3] Origin" [0 0 0]
 "float Clamp" [0]
 "float Cyclic" [0]
 "string ShadingSpace" ["world"]</pre>
<p>Here&#8217;s a rendering with the default parameter values.  The output color is the world-space x,y,z position of the current shading location:</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition1.png"><img class="alignnone size-full wp-image-89" title="showposition1" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition1.png" alt="ShowPosition" width="300" height="225" /></a></p>
<p>It doesn&#8217;t normally make sense to filter position values, so this image was rendered with only 1 pixel sample (PixelSamples 1 1 in the RIB file) and no filtering.</p>
<p>The position values may well be greater than 1 or less than 0, so a full-precision position image should be saved in a file format such as HDR, EXR, or TIFF that supports floating-point data.</p>
<p>The ShowPosition shader also allows the position values to be scaled to lie in the unit interval, which allows the data to be recorded in an 8-bit or 16-bit image.  The scaling is performed by mapping the position into a cube with one corner defined by the Origin parameter and each side of length UnitSize.  In this image the UnitSize is set to 10:</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition2.png"><img class="alignnone size-full wp-image-90" title="showposition2" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition2.png" alt="show scaled position" width="300" height="225" /></a></p>
<p>Position values that lie outside of the box defined by the Origin and UnitSize value will be clamped to the unit interval if the Clamp parameter is set to 1.  If the Cyclic parameter is set to 1, out of range values will be wrapped to form a periodic pattern.  Here&#8217;s the same model with UnitSize set to 1 and Cyclic set to 1:</p>
<p><a href="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition3.png"><img class="alignnone size-full wp-image-91" title="showposition3" src="http://sitexgraphics.com/blog/wp-content/uploads/2012/02/showposition3.png" alt="show cyclic position" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=88</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shader Networks and Layered Shaders</title>
		<link>http://sitexgraphics.com/blog/?p=81</link>
		<comments>http://sitexgraphics.com/blog/?p=81#comments</comments>
		<pubDate>Sun, 31 Jul 2011 17:39:37 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Shaders]]></category>
		<category><![CDATA[passes]]></category>
		<category><![CDATA[renderman]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=81</guid>
		<description><![CDATA[SiTex Graphics Air version 11 (press release) introduces the ability to use multiple shaders to compute the shading for surfaces, displacements, imagers, and environments. This new capability provides a simple solution to several common shading tasks that would otherwise require &#8230; <a href="http://sitexgraphics.com/blog/?p=81">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>SiTex Graphics Air version 11 (<a title="Air 11 press release" href="http://www.sitexgraphics.com/html/air_11_press_release.html">press release</a>) introduces the ability to use multiple shaders to compute the shading for surfaces, displacements, imagers, and environments.</p>
<p>This new capability provides a simple solution to several common shading tasks that would otherwise require complex custom shaders:</p>
<ul>
<li><strong>Decals</strong>:  apply an arbitrary number of texture maps to an object&#8217;s color and feed the result into any surface shader.</li>
</ul>
<ul>
<li><strong>Extra output variables</strong>:  add an arbitrary number of additional shaders to an object to produce extra output values without affecting the normal shading of the object.</li>
</ul>
<ul>
<li><strong>Assign different shaders to specific regions</strong>:  simple shader compositing allows existing surface shaders to be selectively applied to sections of a surface.</li>
</ul>
<ul>
<li><strong>Replicate application shader networks</strong>:  create arbitrary shader networks by connecting pre-compiled components.</li>
</ul>
<p>Further, the implementation of networked and layered shaders does not require existing shaders to be re-written to take advantage of these new features.</p>
<p>This article describes how to use multiple shaders to address each of these tasks.  Sample shaders and rib files are included in the AIR distribution in:</p>
<pre style="padding-left: 30px;">$AIRHOME/examples/layers
</pre>
<h3>Simple Color Layers</h3>
<p>Here&#8217;s a simple RIB fragment that assigns multiple surface shaders to an object:</p>
<pre>Surface "ColorMap" "string ColorMapName" "grid.tx"
Surface "+VMarble"</pre>
<p>Prepending the shader name with &#8220;+&#8221; tells Air to append the shader to the list of shaders assigned to the object. The shaders are executed in the order in which they are assigned. Subsequent shaders inherit the current shading state (including the values of global variables) from shaders previously executed. Here&#8217;s a ColorMap shader that uses a texture map to set the object&#8217;s color value:</p>
<pre>generic ColorMap(
  string ColorMapName = "";
  float SetColor = 1;
  output varying color __Color = 0;
)
{
  if (ColorMapName!="") {
    __Color = color texture(ColorMapName,s,t);
    if (SetColor!=0) Cs = __Color;
  }
}</pre>
<p>In the RIB fragment given above, the VMarble shader will use the color map result as one of the input colors for the marble pattern. No modification of the VMarble shader is required.</p>
<p>The new generic shader type is compatible with any other shader type.  Generic shaders can be used to construct re-usable components for layered and networked shaders.</p>
<p>Sample scene: colormap.rib</p>
<h3>Decals</h3>
<p>The layers example directory includes a LayerDecal shader that applies a masked color to a surface. Simple sequential shader assignment allows an arbitrary number of decals to be applied to a surface without constructing a complex custom surface shader:</p>
<pre>Surface "LayerDecal"
  "ColorMapName" "sitex.tx"
  "OriginXY" [.3 .67]
  "SizeXY" [-.3 -.3]
  "DecalColor" [1 1 1]
Surface "+LayerDecal"
  "ColorMapName" "sitex.tx"
  "OriginXY" [.25 .6]
  "SizeXY" [-.25 -0.25]
  "DecalColor" [1 0 0]
Surface "+plastic"</pre>
<p>Sample scene: decals.rib</p>
<h3>Extra Passes</h3>
<p>Another task made easy with multiple shaders is adding extra output values to a rendering pass.   Air 11 includes a new generic shader that adds an occlusion output value to any surface (stored in a __occlusion output variable).   Sample usage:</p>
<pre> Display "extrapass.tif" "framebuffer" "rgba,color __occlusion"
...
Surface "VMarble"
Surface "+genOcclusion" "setshaderoutput" 0</pre>
<p>Sample scene: extrapass.rib</p>
<h3>Shader Compositing</h3>
<p>Air&#8217;s multi-shader support includes an option to composite one shader on top of another. Here&#8217;s an example that adds a plastic decal to a metallic surface:</p>
<pre>Surface "VMetal"
Surface "*VPlastic" "OpacityMapName" "sitex.tx" "ColorMapName" "square.tx"</pre>
<p>The * before the shader name tells Air to blend the output color from the VPlastic shader with the output color of the VMetal shader using the output opacity from the VPlastic shader. Any output variables shared by the two shaders will also be composited using the output opacity.</p>
<p>Sample scene: compshaders1.rib</p>
<p>The above example shows how to composite a shader with controls for its output opacity. For surface shaders without opacity controls, an auxiliary shader can be used to control the opacity. Here is a simple generic shader that sets the global input opacity value:</p>
<pre>generic OpacityMap(
  string OpacityMapName = "";
  output varying color __Opacity = 1;
)
{
  if (OpacityMapName!="") {
    __Opacity = color texture(OpacityMapName,s,t,"fill",-1);
    if (comp(__Opacity,1)==-1) __Opacity=comp(__Opacity,0);
    Os = __Opacity;
  }
}
</pre>
<p>This shader allows any surface shader that modulates its output color by the input opacity to be composited over another shader.  Most surface shaders modulate their output color in this way.</p>
<p>Here is how the OpacityMap shader might be used to add a marble decal to a 2D grid:</p>
<pre>Surface "VGrid2D"
Surface "+OpacityMap" "OpacityMapName" "sitex.tx"
Surface "*VMarble"</pre>
<p>To optimize the evaluation of composited shaders, Air will skip any shader layer whose input opacity value is 0.</p>
<p>Sample scene: compshaders2.rib</p>
<h3>Shader Networks</h3>
<p>Multiple shaders can be used to re-construct a general shader network by defining connections among the shaders assigned to an object. Connections are defined by including additional parameters in the shader declaration. First, each shader declaration is assigned a name using:</p>
<p style="padding-left: 30px;">&#8220;string layername&#8221; &#8220;<em>componentname</em>&#8220;</p>
<p>Naturally layername does not need to be an actual parameter of the shader.</p>
<p>Each connection is defined with an additional string parameter:</p>
<p style="padding-left: 30px;">&#8220;string connect:<em>toparametername</em>&#8221; &#8220;<em>fromlayer</em>:<em>fromparametername</em>&#8220;</p>
<p>The connection transfers the value of <em>fromparametername </em>in layer <em>fromlayer </em>to the target parameter in the current shader.  The source parameter must be an output variable of the source shader or a global shader variable.  The target parameter is normally one of the shader&#8217;s input parameters, but it can also be the global input color (Cs) or input opacity (Os).  The source and target parameters must have the same type.</p>
<p>Sample usage:</p>
<pre>Surface "ColorMap"
  "string ColorMapName" "grid.tx"
  "float SetColor" [0]
  "layername" "gridlayer"
Surface "+VMarble"
  "connect:VeinColor" "gridlayer:__Color"</pre>
<p>In this example, the marble vein color is taken from the ColorMap shader&#8217;s __Color output variable.</p>
<h3>Applications</h3>
<p>The <a title="Air Stream for Maya" href="http://www.sitexgraphics.com/html/air_stream.html">Air Stream</a> plug-in for Maya uses the new shader network capability in Air 11 to translate Maya&#8217;s shader networks for rendering with Air.  This approach also easily allows:</p>
<ul>
<li>Air shader parameters to be driven by a Maya shading network</li>
<li>Air shaders and Maya shaders to be mixed in a single network</li>
<li>Air custom shading language functions to be incorporated in a Maya shading network using generic shaders</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=81</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A dictionary function for the shading language</title>
		<link>http://sitexgraphics.com/blog/?p=73</link>
		<comments>http://sitexgraphics.com/blog/?p=73#comments</comments>
		<pubDate>Thu, 31 Mar 2011 23:09:00 +0000</pubDate>
		<dc:creator>sitexgraphics</dc:creator>
				<category><![CDATA[Shaders]]></category>
		<category><![CDATA[dso]]></category>
		<category><![CDATA[renderman]]></category>

		<guid isPermaLink="false">http://sitexgraphics.com/blog/?p=73</guid>
		<description><![CDATA[For the Air 11 release we&#8217;ve added new shaders that compute a physical sky environment and sun position based on geographical location and date/time.  We thought it would be nice to be able to enter a location using a simple &#8230; <a href="http://sitexgraphics.com/blog/?p=73">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the Air 11 release we&#8217;ve added new shaders that compute a physical sky environment and sun position based on geographical location and date/time.  We thought it would be nice to be able to enter a location using a simple city name instead of having to look up and remember a set of figures for latitude, longitude, and time zone every time.</p>
<p>We need a function that allows us to look up a set of values based on a name, like looking up a word&#8217;s definition in a dictionary.   We can add such a function to Air&#8217;s shading language by implementing a dynamic shadeop, or DSO for short, which will be loaded by Air automatically and used to evaluate our new function.</p>
<p>The dictionary DSO adds the following new functions to the shading language:</p>
<pre>float dictionary(string dictname, string keyname, float fvalue);
float dictionary(string dictname, string keyname, color cvalue);
float dictionary(string dictname, string keyname, string svalue);
</pre>
<p>The dictionary function looks for a text file named dictname and tries to load a list of token value pairs, one per line.  The token values should look like</p>
<pre>Seattle 47.45 -122.3 -8
</pre>
<p>The functions return 0 if they succeed.  If an error occurs, the functions return one of the following error codes:</p>
<pre>-1:  unable to find or read dictionary file
-2:  key name not found
-3:  unable to convert value to the requested type
</pre>
<p>Since Air 11 has not yet been released, here are a couple other uses for the dictionary function that you can try with the current Air release.</p>
<p>The first example uses the dictionary function to allow the base surface color to be specified using a name instead of r,g,b values.  The Air distribution includes a list of named colors in $AIRHOME/vizools/colors.txt (used by the Air Space tool).  Here&#8217;s the source code for a simple NamedColor shader:</p>
<pre>surface NamedColor(
 float Ambient = 1;
 float Diffuse = 1;
 string ColorName = "";
 string ColorList = "$AIRHOME/viztools/colors.txt"
)
{
  color Ct = Cs;
  if (ColorName!="") dictionary(ColorList,ColorName,Ct);
  normal Nf = faceforward (normalize(N),I);
  Oi = Os;
  Ci = Oi * Ct * (Ambient * ambient() + Diffuse * diffuse(Nf));
}</pre>
<p>The dictionary function will expand the reference to the $AIRHOME environment variable in the ColorList value.</p>
<p>In a RIB file, we can then specify a named color as:</p>
<pre>Surface "NamedColor"
 "string ColorName" "neon pink"</pre>
<p>Another application for the dictionary function is to allow simple text files to be used to define &#8220;preset&#8221; values for a shader&#8217;s parameters.  Here&#8217;s an extended version of the standard paintedplastic surface shader with an option to use a file with preset values:</p>
<pre>surface paintedplasticpreset(
 float Ka = 1;
 float Kd = .5;
 float Ks = .5;
 float roughness = .1;
 color specularcolor = 1;
 string texturename = "";
 string preset = "";
)
{
 float preKa=Ka;
 float preKd=Kd;
 float preKs=Ks;
 float preroughness = roughness;
 color prespecularcolor=specularcolor;
 string pretexturename=texturename;

 if (preset!="") {
  dictionary(preset,"Ka",preKa);
  dictionary(preset,"Kd",preKd);
  dictionary(preset,"Ks",preKs);
  dictionary(preset,"roughness",preroughness);
  dictionary(preset,"specularcolor",prespecularcolor);
  dictionary(preset,"texturename",pretexturename);
 }
 Ci = Cs;
 if (pretexturename != "")     Ci *= color texture(pretexturename);
 normal Nf = faceforward (normalize(N),I);
 Oi = Os;
 Ci = Oi * Ci * (preKa*ambient() + preKd*diffuse(Nf)) + prespecularcolor * preKs*specular(Nf,-normalize(I),preroughness);
}</pre>
<p>A sample preset file might look like:</p>
<pre>Kd 0.4
Ks 0.6
roughness 0.2
specularcolor = 1 1 0
texturename = grid.tx</pre>
<p>The new dictionary shadeop can found in this <a href="http://www.sitexgraphics.com/dictionary1.zip">archive</a>.  Unzip the archive to the AIRHOME directory, and the new shadop will automatically be added to the shaders directory of your Air installation (where Air can find it).  Examples and source code for the shadeop can be found in $AIRHOME/examples/dictionary.</p>
]]></content:encoded>
			<wfw:commentRss>http://sitexgraphics.com/blog/?feed=rss2&amp;p=73</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
