Air Stream for Maya 2014

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 to automatically load when Maya starts:

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.

Posted in Maya | Comments Off on Air Stream for Maya 2014

Fake Carpet shader

fake carpet shader sample

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.

Getting Started

Here’s how to add carpet to a room model:

  • 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.
  • 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.
  • 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.
  • 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.

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.

Carpet Shape

The carpet is modeled as a grid of carpet fibers.  The geometric model of the fibers can be tuned using the following parameters:

StrandCount, StrandWidthFraction

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.

StrandTiltAngle, StrandTiltVary, StrandTiltFrequency, StrandStiffness
StrandPolarAngle, StrandPolarVary, StrandPolarFrequency

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.

The direction of tilt can be changed using the StrandPolar parameters, which control a rotation in degrees about the vertical axis.

StrandSegments, TraceTip, TraceJoint

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.

Carpet Shading

The carpet is shaded using an empirical model that assumes some light is reflected from the front of each fiber and some is transmitted.

FrontScatter, BackScatter, ScatterPower

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.

SelfShadowMax, ColorMapName, BaseColor, IndirectDiffuse

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.

ColorMapName allows a color map to be applied to the fibers.

BaseColor gives the color of the “fabric” under the fibers, which is visible where fibers are missing.

IndirectDiffuse is a simple multiplier for the diffuse result returned for indirect illumination.  The shader does not trace fibers for indirect rays.

Carpet Trace Controls

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:

SampleGridSize

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.

TraceMargin

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 “window” 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.

TestForIntersections, TraceBias

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.

Final Remarks

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.

Posted in Shaders | Tagged , | Comments Off on Fake Carpet shader

Fast spherical lights

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:

  • 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.
  • Some software (such as Massive) does not provide an interface for area lights.

To address those drawbacks we’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:

http://www.sitexgraphics.com/spherelight.zip

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:

  1. 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:
    lenL=max(sqrt(L.L),radius);
    blur = abs(atan(radius,sqrt(lenL*lenL-radius*radius)));
    
  2. 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.

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.

Posted in Shaders | Tagged , , | Comments Off on Fast spherical lights