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

code cleanup for Car example

parent db8d69df
No related branches found
No related tags found
No related merge requests found
%%% RenderToolbox3 Copyright (c) 2012-2013 The RenderToolbox3 Team.
%%% About Us://github.com/DavidBrainard/RenderToolbox3/wiki/About-Us
%%% RenderToolbox3 is released under the MIT License. See LICENSE.txt.
% Render a Mercedes SLS and display as an isetbio optical image.
%
% Henryk Blasinski
%% Scene description
% Henryk Blasinski
%% Initialize.
% tbUse('isetbio');
close all;
clear all;
clear;
clc;
ieInit;
%% Simulation parameters
%% Choose simulation parameters.
filmDiag = 20;
targetDistance = 5000;
nSamples = 256;
conditionsFile = 'MakeCarConditions.txt';
%%
parentSceneFile = fullfile('Models','Mercedes SLS','sls_amg.obj');
% parentSceneFile = fullfile('Models','Renault Megane RS','exportedMegane.obj');
% Renderer options.
hints.imageWidth = 640;
hints.imageHeight = 480;
hints.renderer = 'PBRT'; % We're only using PBRT right now
hints.recipeName = 'MakeCar';
hints.copyResources = 1;
%% Choose Batch Render Options.
hints.imageWidth = 320;
hints.imageHeight = 240;
hints.renderer = 'PBRT';
hints.recipeName = 'Car';
hints.batchRenderStrategy = RtbAssimpStrategy(hints);
hints.batchRenderStrategy.remodelPerConditionAfterFunction = @MakeCarMexximpRemodeller;
hints.batchRenderStrategy.converter.remodelAfterMappingsFunction = @MakeCarPBRTRemodeller;
hints.batchRenderStrategy.remodelPerConditionAfterFunction = @rtbMakeCarMexximpRemodeller;
hints.batchRenderStrategy.converter.remodelAfterMappingsFunction = @rtbMakeCarPBRTRemodeller;
% Change the docker container
% change the docker container
hints.batchRenderStrategy.renderer.pbrt.dockerImage = 'vistalab/pbrt-v2-spectral';
resources = rtbWorkingFolder('folderName','resources', 'hints', hints);
root = rtbWorkingFolder('hints',hints);
parentSceneFile = fullfile(rtbRoot(), 'ExampleScenes', 'IsetbioExamples', ...
'Car', 'Models', 'Mercedes SLS', 'sls_amg.obj');
resources = rtbWorkingFolder( ...
'folderName', 'resources', ...
'hints', hints);
conditionsFile = fullfile(resources, 'rtbMakeCarConditions.txt');
%% Save data to resources folder
%% Save data to resources folder.
[waves, daylight] = rtbReadSpectrum('D65.spd');
rtbWriteSpectrumFile(waves,1e4*daylight,fullfile(resources,'SunLight.spd'));
%% Choose files to render
%% Load the scene.
[scene, elements] = mexximpCleanImport(parentSceneFile,...
'ignoreRootTransform',true,...
'flipUVs',false,...
'exrToolsImage','hblasins/imagemagic-docker',...
'convertToLeftHanded',true);
% 'toReplace',{'tga'},...
% 'targetFormat','exr',...
'ignoreRootTransform',true,...
'flipUVs',false,...
'exrToolsImage','hblasins/imagemagic-docker',...
'convertToLeftHanded',true, ...
'workingFolder', resources);
%% Start rendering
%% Write conditions file and scene files.
condition = {'clear'};
daylight = {'off'};
headlights = {'on'};
......@@ -102,27 +92,39 @@ for d=1:length(daylight)
end
end
rtbWriteConditionsFile(conditionsFile,names,values);
nativeSceneFiles = rtbMakeSceneFiles(scene, 'hints', hints, ...
'conditionsFile',conditionsFile);
%%
'conditionsFile',conditionsFile);
%% Render!
radianceDataFiles = rtbBatchRender(nativeSceneFiles, 'hints', hints);
%% Display as an isetbio optical image.
% TODO: Ideally, we want to use BuildOI here. Unfortunately, we don't have
% the "oiParameters" structure anymore. In RTB4, this structure held
% information about the film distance, diagonal, etc. We could then use
% this information to fill in parameter info in the OI, such as the
% F-number or the FOV. Now all that info is held in the remodeler. How
% should we move that info out from the remodeler into the oi?
for i=1:length(radianceDataFiles)
radianceData = load(radianceDataFiles{i});
% Create an oi
oiParams.lensType = 'pinhole';
oiParams.filmDistance = values{i,4};
oiParams.filmDiag = 20;
photons = radianceData.multispectralImage;
oiName = sprintf('%s_%i',hints.recipeName,i);
oi = BuildOI(radianceData.multispectralImage, [], oiParams);
oi = oiSet(oi,'name',values{i,1});
% Create an oi
oi = oiCreate;
oi = initDefaultSpectrum(oi);
oi = oiSet(oi, 'photons', single(photons));
oi = oiSet(oi, 'name',oiName);
ieAddObject(oi);
oiWindow;
vcAddAndSelectObject(oi);
end
oiWindow;
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