Render TOP

From TouchDesigner 088 Wiki

RenderTOP 09.jpg

Summary

The Render TOP is used to render all 3D scenes in TouchDesigner. You need to give it a Camera object and a Geometry object as a minimum.

The Geometry object needs to have a Material assigned to it. Materials can be pre-packaged ones like the Phong material, or they can be OpenGL GLSL shaders. All textures and bump maps in TouchDesigner materials are TOPs, i.e. files must be read in via Movie File In TOPs.

Rendering in TouchDesigner ties in nicely with compositing via the Render TOP and all other TOPs.

The Render TOP renders in many RGBA and single-channel formats, in 8-bit fixed-point up to to 32-bit floating point per pixel component.

It can render transparent surfaces correctly using Multi-Pass Depth Peeling. See below: Order Independent Transparency.

Multiple Cameras: The Render TOP is able to render multiple cameras (more quickly than separately) in a single node. You specify multiple cameras in one Camera parameter, and use Render Select TOP to pull out those camera results.

See also Rendering, all the articles in the Rendering Category and the Render Pass TOP.

NOTE: If you are doing non-realtime GPU-intensive renders, see the note in Windows Hangs in the Movie File Out TOP.

PythonIcon.png renderTOP_Class

Parameters - Render Page

Camera camera - Specifies which Camera to look through when rendering the scene. You can specify multiple cameras and retrieve each camera image using the Render Select TOP.

Geometry object - Specifies which Geometry will be included in the rendered scene. You can use Pattern Matching to specify objects using patterns. Example: geo* ^geo7 will render all Geometry components whose names start with geo except geo7.

Lights lights - Specifies which Lights will be used to render the scene. You can use Pattern Matching here as well.

Anti-Alias antialias - Sets the level of anti-aliasing in the scene. Setting this to higher values uses more graphics memory.

Render Mode rendermode - You can render different projections: a Cube Map, Fish Eye, Dual Paraboloid or normal 2D. The Cube Map renders 6 views as needed for reflection maps in the Phong Material. See also the Cube Map TOP and the Projection TOP.

Parameters - Advanced Page

Render render - Enables rendering; 1 = on, 0 = off.

Dither dither - Dithers the rendering to help deal with banding and other artifacts created by precision limitations of 8-bit displays.

Color Output Needed coloroutputneeded - This is an optimization if you don't actually need the color result from this pass. Turning this off avoids a copy from the offscreen render buffer to the TOP's texture. When anti-aliasing is enabled, turning this off will also avoid 'resolving' the anti-aliasing.

Draw Depth Only drawdepthonly - This will cause the render to only draw depth values to the depth buffer. No color values will be created. To make use of the depth buffer, use the Depth TOP.

Anti-Aliasing enableantialias - Turn anti-aliasing off or on. See Anti-Alias parameter on the render parameter page to control amount of anti-aliasing.

Alpha-to-Coverage alphatocoverage - This is a feature that allows you to control how the anti-alias is resolved by using the pixel's alpha value. Say the anti-alias setting is set to 4x. This means that for each final pixel color, it will blend the color values of 4 pixels from the anti-alias buffer. When Alpha-to-Coverage is enabled, the alpha value controls how many pixel samples will be used to create the final pixel value. If your alpha value is 0.75, then 3 of the 4 pixels will be used. If it's 0.5 then 2 of the 4 pixels will be used.

Polygon Depth Offset polygonoffset - This feature pushes the polygons back into space a tiny fraction. This is useful when you are rendering two polygons directly ontop of each other and are experiencing Z-Fighting. Refer to Polygon Depth Offset for more information. This is also an important feature when doing shadows.

Polygon Offset Factor polygonoffsetfactor -

Polygon Offset Units polygonoffsetunits -

Cull Face cullface - Front Faces, Back Faces, Both Faces, Neither. Will cause the render to avoid rendering certain polygon faces depending on their orientation to the camera. Refer to Back-Face Culling for more information.

# of Color Buffers numcolorbufs - Any shader you write can output to more than one RGBA buffer at a time. For GLSL 3.3+ you would use the layout(location = 1) specifier on an out variable in the pixel shader to write to the 2nd buffer. In GLSL 1.2 instead of writing to gl_FragColor in your shader, you write to gl_FragData[i] where i is the color buffer index you want to write the value to.

Allow Blending for Extra Buffers allowbufblending - Controls if blending (as enabled by the MAT common page setting) will be enabled for extra buffers beyond the first one. Often the extra buffers are used to write other types of information such as normals or positions, where blending wouldn't be desirable.

Depth Buffer Format depthformat - Use either a 24-bit Fixed-Point or 32-bit Floating-Point depth buffer (single channel image).

Linear Camera-Space Depth lineardepth - This parameter is enabled when the Depth Buffer Format above is set to 32-bit Floating-Point. This will feed the Depth TOP with linear camera-space depth values. Only works with Perspective projection in the Camera COMP. Warning: This does not work well if you have polygons that cover a large section of the viewport, because the interpolation of the values breakdown across such a large space. Large models that subdivided into small polygons are fine though. Use the re-ranging parameters in the Depth TOP instead if this is the case for your scene.

Override Material overridemat - This allows you to specify a material that will be applied to every Geometry that is rendered in the Render TOP. It is useful for pre-processing passes where we are outputting information about the geometry rather then lighting them and outputting RGB.

Depth Peel depthpeel - Depth peeling is a technique used as part of Order-Independent Transparency. This parameter enables rendering depth-peels, but without combining all the layers using blending to create order independent transparency. Instead is keeps all the layers separate and they can be retrieved using a Render Select TOP. Depth peeling is done by first rendering rendering geometry normally and saving that image and depth. Then another render is done but the closest pixels that were occluded by the previous pass are written to the color buffer instead. This can be done multiple times, each time peeling back farther into the scene. If you are rendering a sphere the first render will be the outside of the sphere, and the second peel layer will be the back-inside of the sphere.

Order-Independent Transparency orderindtrans - Helps to render transparent geometry in proper depth order. This eliminates the need to sort the geometry based on distance from camera. This process is multi-pass. For every pixel the closest surface is rendered in the first pass, the second closest surface second, up to the number of passes specified by the Transparency Passes parameter below. Turning this option on will disable some advanced features in the Render TOP, as well as anti-aliasing.

The feature is a pixel-based approach, not object-based. So its performance is not directly related to the number of objects, but rather how they are layered.

It uses a technique called Depth Peeling. First you render the normal frame. On your next render you peel away all of the pixels you saw in the first frame, and reveal the pixels underneath them. The next frame you do the same, peeling away the pixels you could see from the 2nd render. And so on. Once all of the renders are done, you re composite each layer Over the other, starting at the farthest back layer.

If you take a sphere for example, you'll need to do 2 passes, the first one for the front of the sphere, and then 2nd will be the inside of the sphere.

If you have 10 spheres, one behind the other. You'll need 19-20 passes to get the correct image.

If you have 10 spheres, each next to each other across the screen, you'll only need 2 passes.

In reality though you will only need 3-5 passes to get an image that's acceptable. It may not be 100% correct, but it'll look pretty close to correct.

Each pass is a full render, so each pass adds significant overhead.

Transparency/Peel Layers transpeellayers - Number of passes the renderer will use when Order Independant Transparency is turned on.

Display Overdraw overdraw - This feature visually shows the overdraw in the scene. Refer to the Early Depth-Test article for more information. In particular the Analyzing Overdraw section.

Overdraw Limit overdrawlimit - This value quantizes the outputted color value to some # of overdraws. Refer to the Early Depth-Test for more information.

Parameters - Crop Page

Crop Left cropleft - Positions the left edge of the rendered image.

Crop Right cropright - Positions the right edge of the rendered image.

Crop Bottom cropbottom - Positions the bottom edge of the rendered image.

Crop Top croptop - Positions the top edge of the rendered image.

Parameters - GLSL Page

The GLSL parameter page allows passing of TOPs (samplers) and uniforms into GLSL MATs in a global fashion, instead of having to bind them to each and every MAT in the system. This is useful for multi-pass techniques. If a MAT defines a sampler/uniform of the same name, the one in the MAT overrides the one in coming from the Render TOP.

Sampler Name sampler0-sampler4 - This is the sampler name that the GLSL program will use to sample from this TOP. The samplers need to be declared as the same dimensions as the TOP (sampler2D for a 2D TOP, sampler3D for 3D TOP).

TOP top0-top4 - This is the TOP that will be referenced by the above sampler name above it.

Exposed by the + Button, texture sampling parameters:

Refer to the Texture Sampling Parameters article for more information on the parameters exposed by pressing the + button. The parameter prefix for each of the parameters is top0 up to top4.

Uniform Name uniname0-uniname4 - The uniform name, as declared in the shader.

Value value0[xyzw]-value4[xyzw] - The value(s) to give the uniform.

Depending on how the uniform is declared, only some of the values of the 4 available per parameter are passes to the shader. For example, if the uniform is declared as a vec2, then only the first 2 values are passes to the shader, the other 2 are ignored.

Parameters - Common Page

Resolution - quickly change the resolution of the TOP's data.

  • Input - uses the input's resolution.
  • Eighth, Quarter, Half, 2X, 4X, 8X - multiply the input's resolution by that amount.
  • Custom Resolution - enables the Custom Res parameter below, giving direct control over res in the X and Y axis.

Custom Res - enabled only when the Resolution parameter is set to Custom Resolution. Some Generators like Constant and Ramp do not use inputs and only use this field to determine their size. The drop down menu on the right provides some commonly used resolutions.

Use Global Resolution Multiplier - Uses the Global Resolution Multiplier found in Edit>Preferences>TOPs. This multiplies all the TOPs resolutions by the set amount. This is handy when working on computers with different hardware specifications. If a project is designed on a desktop workstation with lots of graphics memory, a user on a laptop with only 64MB VRAM can set the Global Resolution Multiplier to a value of half or quarter so it runs at an acceptable speed. By checking this checkbox on, this TOP is affected by the global multiplier.

Aspect Ratio - sets the image aspect ratio, which is the visible width vs height, independent of the pixel resolution. If the pixels are not square, the aspect ratio is not the resolution's width/height. Watch for unexpected results when compositing TOPs with different aspect ratios.

  • Input - uses the input's aspect ratio.
  • Resolution - uses the aspect of the image's defined resolution (ie 512x256 would be 2:1), whereby each pixel is square.
  • Custom Aspect Ratio - lets you explicitly define a custom aspect ratio.

Fill Viewer - determine how the TOP image is displayed in the viewer.

  • Input - uses the same Fill Viewer settings as it's input.
  • Fill - stretches the image to fit the edges of the viewer.
  • Fit Horizontal - stretches image to fit viewer horizontally.
  • Fit Vertical - stretches image to fit viewer vertically.
  • Fit Best - stretches or squashes image so no part of image is cropped.
  • Fit Worst - stretches or squashes image so image fills viewer while constraining it's proportions. This often leads to part of image getting cropped by viewer.
  • Native Resolution - displays the native resolution of the image in the viewer.

NOTE: To get an understanding of how TOPs works with images, you will want to set this to Native Resolution as you lay down TOPs when starting out. This will let you see what is actually happening without any automatic viewer resizing.

Viewer Smoothness - This controls pixel filtering in the viewers.

  • Nearest Pixel - uses nearest pixel or accurate image representation. Images will look jaggy when viewing at any zoom level other than Native Resolution.
  • Interpolate Pixels - uses linear filtering between pixels. This is how you get TOP images in viewers to look good at various zoom levels, especially useful when using any Fill Viewer setting other than Native Resolution.
  • Mipmap Pixels - uses mipmapfiltering when scaling images. This can be used to reduce artifacts and sparkling in moving/scaling images that have lots of detail. When the input is 32-bit float format nearest filtering will always be used, regardless of what is selected in the menu.

Pixel Format - format used to store data for each channel in the image (ie. R, G, B, and A). Refer to Pixel Formats for more information.

  • Input - uses the input's pixel format.
  • 8-bit fixed (RGBA) - uses 8-bit integer values for each channel.
  • 16-bit float (RGBA) - uses 16-bits per color channel, 64-bits per pixel.
  • 32-bit float (RGBA) - uses 32-bits per color channel, 128-bits per pixels.


  • 10-bit RGB, 2-bit Alpha, fixed (RGBA) - uses 10-bits per color channel and 2-bits for alpha, 32-bits total per pixel.
  • 16-bit fixed (RGBA) - uses 16-bits per color channel, 64-bits total per pixel.
  • 11-bit float (RGB), Positive Values Only - A RGB floating point format that has 11 bits for the Red and Green channels, and 10-bits for the Blue Channel, 32-bits total per pixel (therefore the same memory usage as 8-bit RGBA). The Alpha channel in this format will always be 1. Values can go above one, but can't be negative. ie. the range is [0, infinite).
  • 8-bit fixed (R) - has 8-bits for the red channel, 8-bits total per pixel.
  • 16-bit fixed (R) - has 16-bits for the red channel, 16-bits total per pixel.
  • 16-bit float (R) - has 16-bits for the red channel, 16-bits per pixel.
  • 32-bit float (R) - has 32-bits for the red channel, 32-bits per pixel.
  • 8-bit fixed (RG) - has 8-bits for the red and green channels, 16-bits total per pixel.
  • 16-bit fixed (RG) - has 16-bits for the red and green channels, 32-bits total per pixel.
  • 16-bit float (RG) - has 16-bits for the red and green channels, 32-bits per pixel.
  • 32-bit float (RG) - has 32-bits for the red and green channels, 64-bits per pixel.
  • 8-bit fixed (A) - An Alpha only format that has 8-bits per channel, 8-bits per pixel.
  • 16-bit float (A) - An Alpha only format that has 16-bits per channel, 16-bits per pixel.
  • 32-bit float (A) - An Alpha only format that has 32-bits per channel, 32-bits per pixel.