-
Notifications
You must be signed in to change notification settings - Fork 2
DragonColorChecker Example Scene
The ColorChecker Dragon parent scene contains a dragon model in the corner of a room, illuminated with 2 area lights. The scene is manipulated with 24 multi-spectral reflectnaces to produce a family of 24 renderer-native scene files and renderings. The renderings are processed to make a 4x6 sRGB montage of 24 dragons, which resembles a standard "Color Checker" chart.
This wiki page assumes you are already somewhat familiar with Blender. See Getting Started for some Blender basics.
The complete rendering recipe is located in the RenderToolbox3 repository at:
(path-to-RenderToolbox3)/ExampleScenes/Dragon/
Here is what the final montage looks like, as rendered with PBRT and Mitsuba:
Above, PBRT rendered the Dragon scene, 24 times, with the dragon's color as a variable.
Above, Mitsuba rendered the Dragon scene, 24 times, with the dragon's color as a variable.
The ColorChecker Dragon recipe uses 4 files:
-
Dragon.dae
is the Collada parent scene file with camera, lights, dragon, floor, walls, and default materials. -
MakeDragonColorChecker.m
is the executive script that generates renderings and the final montage. -
DragonColorCheckerMappings.txt
introduces new materials and multi-spectral reflectances to the scene. -
DragonColorCheckerConditions.txt
lists 24 sampled spectra, for 24 the renderings.
Read more below, about how each file contributes to the final montage.
Note: the Dragon/
folder contains several other Dragon recipes that use the same Collada parent scene file. See Dragon.
Dragon.dae
is the Collada parent scene file that is the basis for the ColorChecker Dragon family of renderings and montage.
You can view the parent scene with a modeling application like Blender:
- Create a new empty scene.
- You might need to delete a few objects that Blender adds by default.
- Clicking File -> import -> COLLADA (.dae), and choose
Dragon.dae
.
You should be able to explore the parent scene and each scene object.
MakeDragonColorChecker.m
is the executive script that renders the scene. It binds together the COLLADA parent scene file with a conditions file and a manipulations file and invokes RenderToolbox3 utilities that create a family of renderer-native scene files and renderings, and a final sRGB montage.
Here is the full executive script, with comments:
%% Choose example files, make sure they're on the Matlab path.
parentSceneFile = 'Dragon.dae';
conditionsFile = 'DragonColorCheckerConditions.txt';
mappingsFile = 'DragonColorCheckerMappings.txt';
%% Choose batch renderer options.
% which colors to use, [] means all
hints.whichConditions = [];
% pixel size of each rendering
hints.imageWidth = 150;
hints.imageHeight = 120;
hints.recipeName = mfilename();
ChangeToWorkingFolder(hints);
% capture and save renderer output, or display it live in Command Window
hints.isCaptureCommandResults = true;
%% Make a fresh conditions file.
% choose spectrum file names and output image names
nSpectra = 24;
imageNames = cell(nSpectra, 1);
fileNames = cell(nSpectra, 1);
for ii = 1:nSpectra
imageNames{ii} = sprintf('macbethDragon-%d', ii);
fileNames{ii} = sprintf('mccBabel-%d.spd', ii);
end
% write file names and image names to a conditions file
varNames = {'imageName', 'dragonColor'};
varValues = cat(2, imageNames, fileNames);
conditionsFile = WriteConditionsFile( ...
fullfile(GetWorkingFolder('resources', false, hints), conditionsFile), ...
varNames, varValues);
%% Render with Mitsuba and PBRT.
% how to convert multi-spectral images to sRGB
toneMapFactor = 100;
isScaleGamma = true;
% make a montage with each renderer
for renderer = {'Mitsuba', 'PBRT'}
% choose one renderer
hints.renderer = renderer{1};
% make 24 multi-spectral renderings, saved in .mat files
nativeSceneFiles = MakeSceneFiles(parentSceneFile, conditionsFile, mappingsFile, hints);
radianceDataFiles = BatchRender(nativeSceneFiles, hints);
% condense multi-spectral renderings into one sRGB montage
montageName = sprintf('%s (%s)', 'DragonColorChecker', hints.renderer);
montageFile = [montageName '.png'];
[SRGBMontage, XYZMontage] = ...
MakeMontage(radianceDataFiles, montageFile, toneMapFactor, isScaleGamma, hints);
% display the sRGB montage
ShowXYZAndSRGB([], SRGBMontage, montageName);
end
DragonColorCheckerMappings.txt
is the mappings file, which modifies the parent scene with things that Collada doesn't know about.
It swaps the handedness of the scene camera, so that Collada, PBRT, and Mitsuba cameras all agree. It specifies matte material for the floor, walls, and dragon, replacing any default materials from Collada. It converts 2 mesh objects in the Collada scene into area lights that shine with a daylight spectrum.
Note: some spectra are specified in spd-spectrum files. These can be found in the RenderToolbox3 RenderData/
subfolder. Other spectra are specified as lists of wavelength:intensity pairs. For example, 300:0.75 800:0.75
specifies that the intensity at 300nm and 800nm should be 0.75 (other intensities will be interpolated between these endpoints).
The parenthetical text (dragonColor)
refers to the conditions file, below. dragonColor
is a variable that gets replaced with a different value for each rendering condition. In this case, it gets replaced with a different sampled spectrum, for each of 24 different conditions.
Here is the full text, with comments:
Collada {
% swap camera handedness from Blender's Collada output
Camera:scale|sid=scale = -1 1 1
}
% specify generic scene elements that apply to PBRT and Mitsuba
Generic {
Collada {
% swap camera handedness from Blender's Collada output
Camera:scale|sid=scale = -1 1 1
}
% specify generic scene elements that apply to PBRT and Mitsuba
Generic {
% transform some mesh shapes into daylight area lights
LightX-mesh:light:area
LightX-mesh:intensity.spectrum = D65.spd
LightY-mesh:light:area
LightY-mesh:intensity.spectrum = D65.spd
% make gray walls and floor
WallMaterial-material:material:matte
WallMaterial-material:diffuseReflectance.spectrum = 300:0.75 800:0.75
FloorMaterial-material:material:matte
FloorMaterial-material:diffuseReflectance.spectrum = 300:0.5 800:0.5
% make a color-changing, matte dragon!
DragonMaterial-material:material:matte
DragonMaterial-material:diffuseReflectance.spectrum = (dragonColor)
}
Note: the names Camera
, WallMaterial-material
, FloorMaterial-material
, DragonMaterial-material
, LightX-mesh
, and LightY-mesh
are the unique identifiers for elements of the scene. These identifiers are used in the Collada scene file and the mappings file, and are the points of contact between the two files.
See Mappings File Format, and Mappings Syntax for more about mappings and introducing new elements to the scene.
See Adjustments Files and Scene DOM Paths for more about scene element unique identifiers.
DragonColorCheckerConditions.txt
is the conditions file, which lists variable names and values for each condition.
For the ColorChecker Dragon, contains a list of 24 .spd
spectrum files. These files are located in the RenderData/
subfolder of RenderToolbox3. Each file name replaces the (dragonColor)
text in the mappings file, above. The conditions file also contains an imageName
used in file names of the renderings.
Here is the full text:
imageName dragonColor
macbethDragon-1 mccBabel-1.spd
macbethDragon-2 mccBabel-2.spd
macbethDragon-3 mccBabel-3.spd
macbethDragon-4 mccBabel-4.spd
macbethDragon-5 mccBabel-5.spd
macbethDragon-6 mccBabel-6.spd
macbethDragon-7 mccBabel-7.spd
macbethDragon-8 mccBabel-8.spd
macbethDragon-9 mccBabel-9.spd
macbethDragon-10 mccBabel-10.spd
macbethDragon-11 mccBabel-11.spd
macbethDragon-12 mccBabel-12.spd
macbethDragon-13 mccBabel-13.spd
macbethDragon-14 mccBabel-14.spd
macbethDragon-15 mccBabel-15.spd
macbethDragon-16 mccBabel-16.spd
macbethDragon-17 mccBabel-17.spd
macbethDragon-18 mccBabel-18.spd
macbethDragon-19 mccBabel-19.spd
macbethDragon-20 mccBabel-20.spd
macbethDragon-21 mccBabel-21.spd
macbethDragon-22 mccBabel-22.spd
macbethDragon-23 mccBabel-23.spd
macbethDragon-24 mccBabel-24.spd
See Conditions File Format for more about specifying variables and values.