-
Notifications
You must be signed in to change notification settings - Fork 2
Dice Example Scene
The Dice recipe renders four 6-sided dice in mid-roll. The 6-sided die model was made with Blender version 2.63, based on some Blender tutorials. The recipe and wraps the dice in a bitmap texture defined in an OpenEXR image file.
This page outlines how the scene was created, and includes links to relevant Blender tutorials. It shows how to define and export UV texture coordinates with Blender. This should apply to other RenderToolbox3 recipes that use textures.
This wiki page assumes you are already somewhat familiar with Blender and RenderToolbox3. See Getting Started for some Blender basics. See MaterialSphere Example Scene and DragonColorChecker-Example-Scene for more about RenderToolbox3.
Here is what the scene looks like, as rendered with PBRT and Mitsuba:
Above, PBRT rendered the Dice scene with the direct-lighting integrator.
Above, Mitsuba rendered the Dice scene with the direct-lighting integrator.
The Dice scene began with a model of a 6-sided die. This video tutorial, "How to Create a Dice Cube using Blender", was pretty easy to follow. The video refers to Blender version 2.5, but it agrees well with version 2.63.
The tutorial shows how to create a cube-shaped die with rounded edges that look good in Blender. These rely on a Blender feature called "Subsurf modifier". In order to export the rounded edges, you must apply the modifier to the die's mesh data. You can do this by clicking on the "Apply" button in the Subsurf dialog, as discussed in this Blender forum.
At this point the modeled die will have the correct shape, but it will have boring coloring.
You can add fancy coloring by wrapping a texture around the die model. Texture wrapping requires you to define "UV" texture coordinates for each point on the surface of the die. These coordinates range from 0 to 1, and indicate to horizontal and vertical locations in an image file.
This video tutorial, "Image UV Mapping Texture Tutorial For Beginners", shows how to wrap a texture around a cube.
The tutorial uses Blender's "UV/Image Editor" view. Sometimes this view is obscured by a rendering preview, which is confusing! As discussed on this Blender Artists forum, you can close the offending preview by clicking on an "X" next to the phrase "Render Result" at the bottom of the UV/Image Editor view.
The tutorial will result in a "UV layout" image that you can edit. It might look different from the UV layout in the UV mapping tutorial. The idea is that the image will contain familiar landmarks from your 3D model that you can refer to when editing the texture image.
The modeling tutorial above produces a die with rounded edges. However, the subsequent UV mapping tutorial expects a cube with sharp edges. You might find it easier to mix the tutorials together as follows:
- Follow the modeling tutorial for 10 minutes to produce a die with sharp edges.
- Skip to the UV mapping tutorial to produce a UV layout image.
- Rejoin the modeling tutorial at the 10 minute mark, to round off the edges of the die.
This would result in a UV layout image like this one:
Although it came from the rough-edged die, it will still work with the rounded die. Just make sure that "Subdivied UVs" is checked in the Subsurf dialog (It should be checked by default).
The renderings above used a similar UV layout image, with red circles and blue squares drawn in.
You can copy and modify the die to produce a fun parent scene. In this parent scene, the die is copied, translated, and rotated four times, to evoke tumbling dice. This parent scene also contains a floor, a sun light, and a point light. When you have a parent scene you like, you can export a Collada file for use with RenderToolbox3:
File -> Export -> COLLADA (.dae)
RenderToolbox3 defines a generic mappings syntax for assigning texture images to materials.
The first step is to define a new texture based on an image file. OpenEXR images should work for both PBRT and Mitsuba. The next step is to assign the texture to a target material, in this case the material of the dice. All the hard work of wrapping the image around the dice is handled by the renderers, based on the UV coordinates created in Blener.
This excerpt from the mappings file, DiceMappings.txt, demonstrates the RenderToolbox3 generic syntax for working with textures:
% specify the reflectance bitmap for the dice
Generic {
% define a bitmap texture based on an .exr image
diceTexture:spectrumTexture:bitmap
diceTexture:filename.string = DiceUVColored.exr
% apply the bitmatp texture to the dice diffuse reflectance
Textured-material:material:anisoward
Textured-material:diffuseReflectance.texture = diceTexture
Textured-material:specularReflectance.spectrum = 300:0 800:0
}
The last step is to render the image! The executive script MakeDice.m produced the renderings at the top of this page.




