-
Notifications
You must be signed in to change notification settings - Fork 7
Flythrough
The Flythrough example combines two 3D models: a night club and the Millennium Falcon. The Falcon flies through the night club.
- The NightClub scene is from Turbosquid.com. Thanks to user Lip1996 for sharing it.
- The MillenniumFalcon scene is from tf3dm.com. Thanks to user ideastudio for sharing it.
This example represents a new kind of workflow enabled by RenderToolbox4. It emphasizes scripting and scene exploration in Matlab, and downplays the conditions and mappings files.
Above, Mitsuba rendered the scene.
The night club model contains a detailed night club interior including floor, ceiling, walls, a bar, stools and chairs, and a loft seating area. For illumination, several meshes are "blessed" as area lights, including a "neon" light running around the walls, and the ceiling itself. The volume of the night club is filled with a "fog" medium, which creates a moody effect.
The Millennium Falcon model contains a finely detailed representation of the Millennium Falcon star ship from Star Wars. For illumination the rear portion of the model is blessed as an area light.
The Falcon model is scaled and inserted into the night club in various positions and orientations. Over several conditions, the Falcon appears to fly from the loft seating area, through the club, to a circular rug or landing pad. The camera also moves, in order to track the Falcon.
Use the script rtbMakeFlythrough.m
to produce the images above.
The Flythrough example uses some new RenderToolbox4 features. It demonstrates a new kind of workflow that favors scripting and exploration in Matlab. In this workflow, the user is not required to write a conditions file by hand, or a mappings file at all.
Below are some highlights for this new workflow, along with screenshots and links to the code.
The function mexximpCombineScenes() is used to combine the night club model with the Falcon model. It takes an "outer" scene, the night club, and appends the meshes, materials, and nodes from an "inner" scene, the Falcon.
Initially, the utility transforms the Falcon geometry to place it at the origin and give it unit size. This makes the import process predictable. Then it applies a user-supplied transform to scale and position the Falcon geometry withing the night club geometry.
Here's where the function is [used](https://github.com/RenderToolbox/RenderToolbox4/blob/master/ExampleScenes/Flythrough/rtbMakeFlythrough.m#L25 in this example).
The function mexximpScenePreview() is able to preview a scene's geometry and simplified materials, from within a Matlab figure.
It takes a mexximp scene and creates a 3D patch for each mesh. If found, it colors each patch like the diffuse RGB value associated with each mesh's material. It positions the Matlab perspective camera like the camera in the mexximp scene.
Here are two previews, taken from the beginning and end of the flythrough sequence:
The preview is able to respond to clicks within the axes. Clicks can move the camera around the scene or print information about the clicked mesh and camera position. This facilitated creation of the flythrough sequence, since the positions and orientations of the Falcon and the camera could be chosen by "clicking around" rather than guess and check.
This example invokes the preview multiple times, once per condition. This happens here, in a scene remodeler function. See below for more about remodeling functions.
The Flythrough example uses a conditions file to specify Falcon and camera positions and orientations. However, it was not necessary to create this file by hand. Instead, these values were programmatically chosen and written to file.
Several initial "waypoint" values were chosen by hand, by "clicking around" the scene preview figure. These are recorded here.
Then, additional values were chosen by spline interpolation of the waypoints. The splining happens here. The splining has the advantage that the number of frames rendered may be independent of the number of waypoints chosen by hand. Thus it would be easy to increase the number of frames and make enough for a movie.
Finally, the splined values are written automatically to a conditions file for later processing and rendering. This happens here.
The chosen positions and orientations for the Falcon and the camera are applied to the mexximp scene in a "remodeling" function. This is an alternative to using a mappings file.
This remodeling function is called rtbFlythroughMexximpRemodeler. It receives the mexximp scene itself, as well as values for the current condition, as read from the conditions file. It uses the conditions values to create transformation matrices and assigns these to the camera and the Falcon. It returns the updated scene struct.
The abstract interface for mexximp remodeling functions like this comes from the RenderToolbox4 RtbAssimpStrategy class.
The specific function used for this example is configured here. The idea is to explicitly create an instance of the RtbAssimpStrategy and set the remodeling function handle to it. This is an alternative to letting Render Toolbox create a default RtbAssimpStrategy, internally.
hints.renderer = 'Mitsuba';
hints.batchRenderStrategy = RtbAssimpStrategy(hints);
hints.batchRenderStrategy.remodelPerConditionAfterFunction = @rtbFlythroughMexximpRemodeler;
This example uses a second remodeling function to control the Mitsuba scene file that's generated. This function is able to directly modify the mMitsuba scene before the scene is written to disk. Thus, it's able to specify arbitrary Mitsuba-specific behaviors.
This remodeling function is called rtbFlythroughMitsubaRemodeler receives the mMitsuba native scene itself, as well as values for the current condition. It makes several modifications to the mMitsuba scene elements:
- The Mitsuba integrator and sampler are configured here.
- A fog medium is created and configured here.
- Several meshes are "blessed" as area lights here.
- Mitsuba-specific materials are confgiured here.
The abstract interface for renderer-native remodeling functions like this comes from the RenderToolbox4 RtbConverter class.
The specific function used for this example is configured here. The idea is to explicitly create an instance of RtbConverter and set the remodeling function handle to it. This is an alternative to letting Render Toolbox create a default RtbConverter, internally.
hints.renderer = 'Mitsuba';
hints.batchRenderStrategy = RtbAssimpStrategy(hints);
hints.batchRenderStrategy.converter.remodelAfterMappingsFunction = @rtbFlythroughMitsubaRemodeler;
- Home
- Conceptual overview
- How it works
- Installation
- Scene construction and translation
- Rendering
- PBRT file
- PBRT batch
- Mitsuba .... something
- Computation
- Local
- Cloud usage
- About Us