![]() Los Angeles mental ray® User Group |
![]() | ||||||||||||
| |||||||||||||
Resources Sections General Install/Setup Options Settings Performance Optimizations mi Scene File FG/AO/GI Subsurface Scattering Shiny Stuff mrfm (Maya) Shader Writing Hair and Geometry Shaders | Rasterizer TipsThe 'rasterizer' is the name of the scanline algorithm implemented with mental ray 3.4. It is a replacement for the 'Rapid Motion' scanline algorithm from previous mental ray releases. Whether you specify The rasterizer separates shading from sampling. Normally, without the rasterizer, shading is initiated by shooting an eye ray from the camera at a sample location. This primary ray hits an object and typically starts the shading calculation by calling the material shader of this object. When using the rasterizer, shading calculations occur separately, and associate with the tesselated geometry. The rasterizer samples pick up the shading results from the geometry. To understand how this works, first we'll present sampling and filtering in the rasterizer, and then we'll address shading. Samples and pixelsFrom Samples Tips, we see that adaptive sampling uses samples at the corners of pixels and subpixels. However, when using the rasterizer, the samples are shifted back to the centers of pixels and subpixels. In addition, the rasterizer always uses a fixed grid pattern of samples; it will not create adaptive sampling patterns. Instead of using the ![]() ![]() The equation for determining how many samples are taken per pixel is ![]() ![]() In mental ray 3.4, the default DiagnosticsSamples diagnostics is disabled when using the rasterizer, because it is a visualization tool to see the adaptive samples pattern. The rasterizer uses a fixed sampling pattern. Temporal Sampling/Motion BlurIn the rasterizer, each spatial sample has its own unique time within the open shutter interval. This method is similar to fast motion blur, except that the samples are located at (sub)pixel centers rather than (sub)pixel corners. And as in fast motion blur, motion smoothness is related to the number of spatial samples per pixel. Filtering to pixelsAfter each tile has been sampled, we enter the filtering stage. Note that the default
The following diagrams depict the tile overlap samples for a 4x4 tile size. Note that there would be no overlap samples with filter size of 1 1, because there are no samples on the edges of the pixels.
Writing multipass sample buffersPass files reflect the shifted sampling patterns. For example, here is the render output listing for our 8 x 8 grape image with a task size of 4, and samples collect 1: Accessing with multipass preprocessWith the rasterizer, all accessed samples will be pre-existing. There are no gaps. Be careful not to mix rasterizer passes with non-rasterizer passes, because the sampling patterns will not match. Recall that the rasterizer has (sub)pixel center based samples, as opposed to (sub)pixel corner based samples. JitteringLikewise, jittering is applied with respect to the centers of pixels and subpixels instead of the corners. Each jittered sample lies somewhere in its respective jitter region, as determined by the QMC algorithm.
ShadingIn the rasterizer, the shading step occurs before, rather than during, the spatial sample calculation. mental ray takes a shading sample for each tesselated primitive of a tesselated object. (For all objects, currently, a triangle serves as the primitive.) As the triangle moves, mental ray uses the same shading sample throughout the frame time. It is this re-use of shading results which speeds up the rendering process for an image requiring a similar number of spatial samples.
On the left, the dot in the center of the triangle represents the shading sample taken at frame time 0. As the triangle moves, the same shading sample stays with the triangle. On the right, we see the triangle at the end of the motion path, frame time 1. Separate from shading, mental ray takes spatial samples with a density specified by
Any spatial sample hitting that triangle will use the same single shading sample calculated at time 0. However, note that as the triangle moves, it covers a different set of spatial samples. Actually, because each spatial sample has its own unique time, the triangle position will be different for each sample. The sample time determines the distance the triangle has moved along its motion path. So a sample covered by the triangle at the beginning of the frame time may not hit the triangle at the end of the frame time. For example, the highlighted sample below left hits the triangle at time 0.2, whereas the sample below right misses the triangle at time 0.65.
Also consider that multiple layers of geometry may be moving. Assuming some transparency, mental ray uses all the triangles underneath the spatial sample until it hits an opaque object.
This means that the time associated with the spatial sample determines which triangles it uses to composite the final sample. We call this step "collapsing the sample". With multipass, this is what is written out to the sample-based pass file, i.e., before filtering. Technical note: Sample Collapse Evaluation Volume and environment shaders are called at the time of collapsing a sample. In addition, a separate opacity function, Technical note: User Framebuffers Because multiple shading samples may combine into a spatial sample, the Furthermore, because shading occurs separately, and the order depends on a sample's time and place, you can't reliably pass information between shaders on different transparent layers using, Shading SamplesThe
Samples Motionmental ray also provides for taking more than 1 shading sample over the frame time per triangle. The The sample is taken at times 0, 1/n, .., n-1/n, where n is what is specified by samples motion. In the example below, n = 5, and we show the location of the triangle and its shading sample at these five times
A shading sample is used for the triangle as it moves from its start time to the next shading sample time. In other words, the shading sample at time 0 is used for all spatial sample times from 0 to 1/n. Again using n = 5 below, we show a shading sample taken at 0.2 used for a spatial sample taken at 0.3. Note that we show a spatial sample hitting just inside the bottom of the triangle at 0.3
Mulitple shading samples can be used to cut down on the artifact of dragging a fixed reflection across motion. It acts as oversampling for anything that changes over time during shading. Keep in mind that this is not the same thing as multisegment motion paths, which enable non-straight motion paths within the frame time. A curving motion path could very well use a single shading sample effectively for a given shot. However, by using multisegment motion paths together with multiple shading samples, fairly sophisticated motion blur effects are possible. Usage and PerformanceIdeally, the rasterizer handles scenes which do not require raytraced effects. However, from the information above, you should understand that each shading sample does have the ability to trace reflected and refracted rays. However, once a ray is shot, much of the time and memory savings from using the rasterizer could be eaten up with bsp tree construction, and object loading. For this reason, we recommended detail shadow maps instead of raytraced shadows for transparent shadow effects. As a common example, most hair rendering can be satisfied with the rasterizer and detail shadow maps. In the following table, we present some general guidelines on rasterizer usage, by presenting features that trigger rays to be traced.:
Because the rasterizer takes shading samples on geometry in an undefined order, then combines them for the sample result later, shaders may behave differently. For each triangle in the scene, mental ray resets the shading sample context and then, calculates the shading sample. Some shaders which depend on this context may need to be modified. See the following table.
SummaryIn mental ray 3.4, the rasterizer is the scanline method replacing Rapid Motion. These are the scene options to control it:
At the command line, you may use:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||