Skip to content
Snippets Groups Projects
Commit f3440d07 authored by Ben Heasly's avatar Ben Heasly
Browse files

new example rtbMakeInteriorMitsubaFactoids

parent 84033006
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,11 @@ if isempty(mitsuba)
end
end
% look carefully for the input file
workingFolder = rtbWorkingFolder('hints', hints);
fileInfo = rtbResolveFilePath(sceneFile, workingFolder);
sceneFile = fileInfo.absolutePath;
%% Render the factoid scene.renderer = RtbMitsubaRenderer(hints);
renderer = RtbMitsubaRenderer(hints);
......@@ -68,9 +73,21 @@ for ii = 1:numel(sliceInfo)
factoids.(factoidName).channels = {};
end
% sort channels, which may arrive out of order
switch channelName
case 'R'
dataIndex = 1;
case 'G'
dataIndex = 2;
case 'B'
dataIndex = 3;
otherwise
dataIndex = numel(factoids.(factoidName).channels) + 1;
end
% insert data and channel name into output for this factoid
slice = data(:,:,ii);
factoids.(factoidName).data(:,:,end+1) = slice;
factoids.(factoidName).channels{end+1} = channelName;
factoids.(factoidName).data(:, :, dataIndex) = slice;
factoids.(factoidName).channels{dataIndex} = channelName;
end
......@@ -46,12 +46,19 @@ parser.addParameter('factoids', ...
@iscellstr);
parser.addParameter('factoidFormat', 'rgb', @ischar);
parser.addParameter('singleSampling', true, @islogical);
parser.addParameter('hints', rtbDefaultHints(), @isstruct);
parser.parse(originalFile, varargin{:});
originalFile = parser.Results.originalFile;
factoidFile = parser.Results.factoidFile;
factoids = parser.Results.factoids;
factoidFormat = parser.Results.factoidFormat;
singleSampling = parser.Results.singleSampling;
hints = rtbDefaultHints(parser.Results.hints);
% look carefully for the input file
workingFolder = rtbWorkingFolder('hints', hints);
fileInfo = rtbResolveFilePath(originalFile, workingFolder);
originalFile = fileInfo.absolutePath;
% default output like the input
if isempty(factoidFile)
......
%%% RenderToolbox4 Copyright (c) 2012-2017 The RenderToolbox Team.
%%% About Us://github.com/RenderToolbox/RenderToolbox4/wiki/About-Us
%%% RenderToolbox4 is released under the MIT License. See LICENSE file.
%
%% Render the Interior scene with various lighting.
%% Choose example files, make sure they're on the Matlab path.
parentSceneFile = 'interio.dae';
conditionsFile = 'InteriorConditions.txt';
mappingsFile = 'InteriorMappings.json';
%% Choose batch renderer options.
hints.whichConditions = 1;
hints.fov = 49.13434 * pi() / 180;
hints.recipeName = 'rtbMakeInteriorFactoids';
%% Write some spectra to use.
resources = rtbWorkingFolder('folderName', 'resources', 'hints', hints);
cieInfo = load('B_cieday');
% make orange-yellow for a few lights
temp = 4000;
scale = 3;
spd = scale * GenerateCIEDay(temp, cieInfo.B_cieday);
wls = SToWls(cieInfo.S_cieday);
rtbWriteSpectrumFile(wls, spd, fullfile(resources, 'YellowLight.spd'));
% make strong yellow for the hanging spot light
temp = 5000;
scale = 30;
spd = scale * GenerateCIEDay(temp, cieInfo.B_cieday);
wls = SToWls(cieInfo.S_cieday);
rtbWriteSpectrumFile(wls, spd, fullfile(resources, 'HangingLight.spd'));
% make daylight for the windows behind the camera
[wavelengths, magnitudes] = rtbReadSpectrum('D65.spd');
scale = 1;
magnitudes = scale * magnitudes;
rtbWriteSpectrumFile(wavelengths, magnitudes, fullfile(resources, 'WindowLight.spd'));
%% Obtain factoids with Mitsuba.
% start by generating a regular scene file.
hints.renderer = 'Mitsuba';
nativeSceneFiles = rtbMakeSceneFiles(parentSceneFile, ...
'mappingsFile', mappingsFile, ...
'conditionsFile', conditionsFile, ...
'hints', hints);
% convert regular scene file for factoid rendering
factoidSceneFile = rtbWriteMitsubaFactoidScene(nativeSceneFiles{1}, ...
'hints', hints);
% invoke Mitsuba to get the factoids
factoids = rtbRenderMitsubaFactoids(factoidSceneFile, ...
'hints', hints);
%% Plot the factoids.
factoidNames = fieldnames(factoids);
nFactoids = numel(factoidNames);
rows = 3;
columns = ceil(nFactoids / rows);
for ff = 1:nFactoids
factoidName = factoidNames{ff};
factoid = factoids.(factoidName);
subplot(rows, columns, ff);
switch factoidName
case {'primIndex', 'shapeIndex'}
% index/nominal data with colormap
imshow(factoid.data(:,:,1), prism());
otherwise
% continuous data as stretched rgb
stretchedRgb = factoid.data ./ max(factoid.data(:));
imshow(stretchedRgb);
end
title(factoidName);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment