Why you should use Raytrace only


#1

A few people have asked why they should turn off Scanline in the Maya globals and select Raytrace instead.

Simply put: Raytracing is more efficient than Scanline. Even if it’s just primary rays.

There is overhead introduced with Scanline rendering. It takes a moment to initialize the algorithm and there’s horizontal coherence but not vertical for tiles. There’s also the fact that Scanline algorithms may cause more objects to be built than necessary inside a tile. Z-buffering, etc may need to sort the triangles to decide who is in front. This means you may have an object built behind something opaque. The more geometry you have, the worse this becomes.

Generally Scanline performance is Linear. The more you add complexity, the slower it gets.

Raytrace performance tends to be logarithmic. The more complex the scene, the less it hurts overall performance. (The slope flattens out.)

Now, modern Scanline still attempts to speed up this process with Rasterization tricks. Early occlusion culling, etc are used to avoid tessellating some objects. But this only works to a point. You can see this in the fact that most raytracers allow a lot of “in render” processes while rasterizers much prefer you bake some things first (pointclouds).

Raytraced primary rays use the acceleration structure to find the necessary triangle to render. In scenes with plenty of triangles, this can be a substantial gain in performance. Scenes with multi-millions of triangles can shave multiple (if not dozens) of minutes off their rendertime. (We aren’t rendering in 1995 anymore. Render a single tree and voila, 1 million triangles. We’re generating entire forests at home now.)

In fact, raytracing performance is good enough that many renderers omit a scanline option (Vray for one) The only major argument for not using raytracing is the old argument of memory consumption. Memory is cheap and plentiful. So are 64-bit systems and software.

Also, you can control the amount of tracing where it might call more geometry by limiting ray distance and bounces in shaders and globals. (Do I really need the reflection of that tiny trashcan 6 blocks down the virtual street?)

So, try turning off that pesky “Scanline” button and select “Raytracing” and see how that goes.


#2

I’ve often wondered about this, so I appreciate your clear explanation. Thanks for that.

Do you simply use raytrace primary on every render? Or, to put it the other way, are there any situations where scanline is still useful? (Given that I have lots of cpu’s and ram)

David


#3

thx for the tip and explanation … I’ve been using raytracing for a like over 8 month now and so far def I’ve seen improvements on render times in large scenes or even the ones that aren’t that big …


#4

Some numbers:

Lots of unique and shiny spheres in a cube formation. Not really rocket science or an interesting scene at that.

Raytrace:

RC 0.10 progr: rendering finished
RC 0.10 info : wallclock 0:03:30.62 for rendering
RC 0.10 info : allocated 788 MB, max resident 1583 MB
GAPM 0.10 info : triangle count (including retessellation) : 16610880

Scanline:

RC 0.10 progr: rendering finished
RC 0.10 info : wallclock 0:03:54.73 for rendering
RC 0.10 info : allocated 1054 MB, max resident 1877 MB
GAPM 0.10 info : triangle count (including retessellation) : 16610880

Both my time and my memory usage increased with Scanline.

Also, with the exception of Rasterizer blur, raytraced motion blur has much better performance when it can use the efficiency of raytraced primary rays. The time saved can make raytraced motion blur more appealing.


#5

Basically. I only use Scanline when I forget to turn it off.

If your render fails because of memory, it will probably fail with Scanline On because chances are you still have Raytracing on as secondary rays. So you just double the punishment. Fail, and fail slower.

Memory consumption is a different animal. And many times it’s the result of textures and other complexities.

My above scene is over 16 million unique triangles and it just ate 1.5GB I can continue to increase that amount and render a hundred million triangles and still be well within my limits at this rate.

Scene composition also makes a difference. The “teapot in a stadium” can be difficult to resolve but most raytracers can handle it within reason.


#6

Motion blur test:

Hundreds of glossy and subdivided spheres with high quality blur, 3 motion steps.

Raytrace:

RC 0.10 info : wallclock 0:50:31.24 for rendering
RC 0.10 info : allocated 1092 MB, max resident 8963 MB
GAPM 0.10 info : triangle count (including retessellation) : 16610880

Scanline:

RC 0.2 info : wallclock 0:56:46.92 for rendering
RC 0.2 info : allocated 2232 MB, max resident 10831 MB
GAPM 0.2 info : triangle count (including retessellation) : 16610880

Scanline ate a lot more memory than raytrace and also took longer.

In fact, the memory usage was a bit more than I expected. But the overall result was pretty close to what I thought would happen. There’s also a pretty decent amount of blur that most scenes won’t have. In theory I could have made it faster with Progressive as well.

Caveat: Some shaders don’t like to have Scanline off. I noticed the motion vectors pass built into Maya (Toxik2D) outputs nothing for me with Scanline off. (Something Autodesk should fix. knock knock)

This is a little something I would like to revisit after Maya 2012 is released.


#7

There is an additional example.In the attached image I simply instanced several thousend pfxtopolygon trees with a particle instancer.

On windows7 the scanline renderer seems to triangulate all of the instances because after a second or two I had to restart my machine because it used too much memory.

Then - after the restart - I switched to raytracer and it used not more than about 1.5GByte of ram for rendering.


#8

Yep Haggi, for instancing to work, you have to be using Raytracing as your primary. Also (in 2009) BSP2 accounted for huge speed gains in conjunction with Raytracing as primary. Not sure if regular BSP works in 2010-2011, but I almost always use BSP2 now if I’m instancing anything.


#9

Thank you for that explanation Bitter. I’ve always used scanline since I have never found any tutorials or seen anyone choose raytracing.


#10

BSP2 is the default set from 2010 and on, but “regular” BSP is still available… thou it’s kinda’ hidden I think.


#11

A discussion of the differences between these two probably deserves its own thread, but I’m interested if there is a reason you mentioned it here.

edit: Ah… I see now it was in relation to Sho Pi’s suggestion.

David


#12

When you select BSP2 (which you probably should, one of the few decent defaults in Maya) you are using a BVH structure for rendering. This does affect the raytracer since it is the structure used to accelerate rendering. (Without an acceleration structure you’d have to do things like test intersection against every triangle in the scene in a giant list. Eek!)

Bounding Volume Hierarchy

In any event, with the exception of a few shader “gotchas” you should probably avoid Scanline just like you would regular BSP. Some of you may find older scenes render faster or some scenes that used to crash can squeak through now, but they will indeed render.

Fewer headaches = much better.


#13

We had some huge speed problems with BSP2 and a high geometry count in a small area (little high res realflow mesh). We switched to regular BSP and it was at least twice as fast.

So BSP2 is appropriate for most but not for all cases, sometimes it is worth to try regular BSP.


#14

That’s the teapot problem. Be sure and send that file to mental images (not Autodesk).


#15

We had some huge speed problems with BSP2 and a high geometry count in a small area (little high res realflow mesh). We switched to regular BSP and it was at least twice as fast.

So BSP2 is appropriate for most but not for all cases, sometimes it is worth to try regular BSP.

Agreed. The inverse though is that instancing massive geometries does not work at all without BSP2 in mental ray, at least in Maya 2009. You have to have Raytracing as primary and BSP2, or else the RAM caps out as if instancing wasn’t working or it just crashes basically. Regular BSP is still the default for me and I use it unless instancing stuff a bunch, really. I’ve seen no speed gains with BSP2 in a light scene over regular BSP, in arch/viz stuff.

(long story longer)
Bitter, your post was great and terribly helpful as well. I only knew that Raytracing primary worked, but not why it worked better for most of my scenes. Thanks for the breakdown!


#16

No problemo. It’s knowledge some of us take for granted and once in awhile someone asks “why something or other” and I’ve asked that too.

However, I am careful about where the information comes from and if I truly want to know, I find a way to ask the source.

It’s like sharing a python script or shader network. It puts you out there and improves the overall community as opposed to the occasional elitist yammerings I see from time to time where people come off like “I am an artiste. . .”

Yeah whatever, just tell me what you put the slider setting to and why so we can ALL benefit.
:beer:

When 2012 is released I am hoping to give it a good run through and then see what we can do to improve performance again. But first and foremost is leaving behind some legacy settings that Autodesk feels its clients cling to.


#17

This is great information and a great discussion. Thanks for sharing.


#18

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.