Skip to content

WildScene

Ben Heasly edited this page Oct 17, 2016 · 10 revisions

The WildScene example loads and renders a 3D scene which was downloaded from a web site and created by an author who is unrelated to RenderToolbox.

This demonstrates some utilities in RenderToolbx and mexximp which are useful for cleaning up or "taming" scenes which were downloaded "from the wild". These utilities are necessary because wild scenes often contain broken image references, malformed geometry, etc.

Although this example deals with only one wild scene, the utilities should be applicable to many scenes. We hope they will reduce the manual effort required for taming and rendering wild scenes.

Above, Mitsuba rendered the scene with the camera facing head-on.

Above, Mitsuba rendered the scene with an oblique camera angle.

Description

The scene contains a model of the Millenium Falcon downloaded from tf3dml.com. The model uses a matte material with spatially varying texture taken from an image file that was downloaded with the model. Thanks to the contributor ideastudio and the author "glenn" for making the model available!

In addition to the Millenium Falcon model, the scene contains a camera which views the model head on (in the first rendering), or from an oblique angle (in the second). Spectrally uniform point lights surround the camera to provide illumination which is harsh but effective.

Rendering

Use the script rtbMakeWildScene.m to produce the image above.

Internals

This example uses several utilities to tame the wild scene and make it ready for rendering and viewing.

mexximpCleanImport()

The mexximp utility mexximpCleanImport() loads the scene and does some automatic cleanup, such as polygon triangulation, making sure normals point out from their surfaces, generating missing UV coordinates, and converting texture images to the OpenEXR format which is good for both PBRT and Mitusba.

mexximpSceneScatter()

Then mexximp utility mexximpSceneScatter() provides a scatter plot to preview the model geometry, which can be useful for rejecting wild models that are broken beyond repair.

mexximpCentralizeCamera()

The mexximp utility mexximpCentralizeCamera() adds a camera to the scene, attempts to aim the camera at the center of the scene geometry, and adjusts the viewing distance to fit the geometry in the camera's field of view. This is a useful place to start, since often geometry is not located near the origin.

In the first rendering, the camera is placed at the default orientation, viewing the scene directly down the z-axis. In the second rendering, the camera is moved to a more pleasing oblique viewing axis.

mexximpAddLanterns()

The mexximp utility mexximpAddLanterns() adds 8 point lights to the scene, in a cube arrangement centered on the camera. This is useful since often scenes don't contain lights suitable for physically-based rendering and sometimes no lights at all. The resulting illumination is harsh, but effective for getting started and viewing the scene.

mexximpVisitStructFields() and rtbResourcePath()

The mexximp utility mexximpVisitStructFields() is used to scan the entire loaded scene struct and look for file names. For each file name found, it applies the RenderToolbox utility rtbResourcePath(). This function does fuzzy matching and replacing on file names encountered in the scene struct vs file names in the working folder. This is important because often wild scenes contain broken image references.

For example, the original Millenium Falcon model refers to a texture image named C:\Documents and Settings\glenn\Desktop\falcon.jpg, which probably existed on the author's workstation. This needs to be matched with the file falcon.jpg, which is included with the downloaded model.

Clone this wiki locally