Displacement mapping memory conservation

It seems maybe it might be a good time to start blogging the "Luxology Rendering Engine Failed" message and one of its likely causes. After much testing and looking at countless test cases submitted by so many of you, I have come to the realization, that 90% of these failures are directly related to MEMORY. Actually running out of memory, which as we all know, is a bad thing. Luckily most of us, only see the "engine failed" message rather than a full fledge system crash.

There are many factors that can cause excess memory usage, so I will address one of those that appear to be causing the majority of the reported failures.

Displacement Mapping

Probably the number one culprit for consuming excessive amounts of our precious memory is Displacement Mapping. Not having had this very cool feature in the past, most of now want to displace anything and everything (teddy bear motorcycles) even Ray is guilty. I remember the first time I used ray tracing, wow reflection, how cool, I made everything more reflective than it would be in real life (Pete still reminds me of this on a regular basis).

Even though displacement mapping is admittedly one of the coolest things for MicroStation users to have in their hands in years, we all need to know and understand how the displacement settings work, and their affect on the rendering process. It turns out that our default settings for displacement mapping are too fine for most MicroStation designs. We used Modo's defaults for all our Luxology rendering setups, which for small designs or test cases seemed to work very well. We are now finding that in real world MicroStation designs these default values can cause excessive memory consumption, leaving us with that puzzling message "Luxology Render Engine Failed".

Displacement Rate

This value drives the number of polygons created during Micropolygon Displacement rendering. To get straight to the point, INCREASING this number will DECREASE the number of polygons. Even a small change in the displacement rate will have a huge impact on the overall polygon count. The default value of 1.0 basically means that any micropolygon that has an edge longer than 1 pixel will be further tessellated.

You can think of it as one polygon per pixel. Polygons will get diced and diced until the edges get down to the single pixel range or they hit the Minimum Edge Length value. This description isn't totally precise but it gives a good working idea.

Displacement Rate and Minimum Edge Length are basically the same thing. They tell the Luxology render engine how small an edge needs to be. The Displacement Rate defines the edge in pixel space and the Minimum Edge Length is a world space measurement. In other words, when Luxology evaluates an edge against the two criteria, it is looking at the physical length of the edge to compare for Minimum Edge Length and the "visual" length from the cameras perspective when evaluating Displacement Rate. Think of it this way, when you measure a concrete block you know it is about 8 inches (200mm) tall. But if you hold your hand out in front of you and frame this between your fingers, the space between your fingers is only half an inch. One is the actual length and the other is the visual length.

The Displacement Rate specifies the distance between displacement evaluations (basically the desired length of micropolyon edges). The Luxology default is set to one pixel which is usually just right, at least in a perfect world, where you have truck loads of memory. As you can imagine having the length of any edge being approximately 1 pixel means that you will never see a faceted curve from too few polygons. The problem with the 1 pixel thing, is that for large MicroStation models and complex scenes it would be much better to have something a little less than perfect and know that you can actually render your scene, than having to see "Luxology Rendering Engine Failed" message.

Displacement is adaptive at the micropolygon level. Every polygon edge is considered separately. The distance from the camera to the center of the edge, the focal length, and the resolution are used to convert the Displacement Rate (in pixels) into a distance in world space. If the edge is longer than this and also longer than the Minimum Edge Length, it is split in half. This process continues recursively until all edges satisfy those requirements.
Since the displacement rate is approximately the edge length of the micropolygons, the polygon count will vary with the square of the rate. Even a small change like going from 1.0 to 1.4 should cut the number of micropolygons by about a factor of two.

The fact that we discuss the edge length in terms of pixels might be slightly misleading since these polygons can be oriented in such a way as to not be completely perpendicular to the camera's view. Since the edge length calculation occurs in world space and not screen space there can, in fact, be many more polygons in the image than there are pixels.

Displacement Ratio

The Displacement Ratio setting found on the Advanced tab of Render Settings dialog allows you to control the amount of subdivision in areas of the scene that are not visible to the camera. Low values will create more polygons and high values less. This setting works in tandem with the Displacement Rate setting allowing you to balance the amount of micropoly displacement in a scene, so memory usage can be kept to a minimum. You can set this to a fairly high value in most cases to improve rendering performance and conserve memory. The Luxology default displacement ration is 4.0, I would recommend that you use 8.0 as a starting point and if you are unhappy with the result you can always make this a smaller value.

Bottom Line

A Displacement rate of 2.0 and a Displacement Ratio of 8.0 seems to work much better (for the typically MicroStation design) than the previous defaults of 1.0 and 4.0 respectively. I will be changing our defaults to these less aggressive, memory friendly values in the next Luxology Render Engine Update. If you are working with small designs or test cases you can easily create or modify a setup and use the Luxology defaults.

In the following images I have a large Martian like terrain. I exported the file to Modo to get an accurate displacement polygon count with the setting shown. The images and render times are from MicroStation's Luxology dialog. While the first image has a little more detail the second image looks pretty convincing and the real difference might actually be no image "Luxology Render Engine Failed" vs. having a finished image.

As we move MicroStation and our rendering engine to 64-bit, at a point in the not too distant future, memory will no longer be an issue. For the present the Luxology engine has the power to render anything we throw at it, but until we can actually use truckloads of memory we can all best be served by getting up to speed on the settings that make our new engine run smoothly.

3m55s 7.8M polygons

Displacement Rate 1.0 and Displacement Ratio 4.0, render time 3 minutes 55 seconds, 7.8 million polygons, memory required to render ~1.5 GB.

2m29s 1.94M polygons

Displacement Rate is 2.0, Displacement Ratio 8.0, render time 2 minutes29 seconds, 1.94 million polygons, memory required to render 561MB