Skip to content
Snippets Groups Projects
Commit f3f955a3 authored by Brian Wandell's avatar Brian Wandell
Browse files

All a mystery to me. Nothing working in the sense of good images. Many...

All a mystery to me.   Nothing working in the sense of good images.  Many apparent improvements, but the renderings just suck.  So, shifting to run the test validation on the master branch.
parent 6aa8ffe4
No related branches found
No related tags found
No related merge requests found
classdef RtbPBRTCloudRenderer < RtbRenderer
%% Implementation for rendering with PBRT
% This could use a few more comments.
%
% HB Scien Stanford 2017
properties
% RenderToolbox4 options struct, see rtbDefaultHints()
......@@ -40,6 +43,8 @@ classdef RtbPBRTCloudRenderer < RtbRenderer
methods
function obj = RtbPBRTCloudRenderer(hints)
% Some of these should be parameters
obj.hints = rtbDefaultHints(hints);
obj.pbrt = getpref('PBRT');
obj.tokenPath = hints.tokenPath;
......
......@@ -37,7 +37,7 @@ gcloud = true;
% Should have a validity check. Surprising that we have the tokenPath early in
% the ordering within this nnHintsInit routine
% Small image size for debugging.
hints = rtbHintsInit('imageWidth',160,'imageHeight',120,...
hints = rtbHintsInit('imageWidth',640,'imageHeight',480,...
'recipeName','cloud-example',...
'tokenPath',tokenPath,...
'gcloud',gcloud,...
......@@ -49,23 +49,26 @@ hints = rtbHintsInit('imageWidth',160,'imageHeight',120,...
fprintf('Initializing gcloud');
[gs,kube] = rtbCloudInit(hints);
%% Delete any radiance data files from google cloud
remoteRadianceFiles = gs.ls('cloud-example/renderings/PBRTCloud');
for ii=1:length(remoteRadianceFiles)
gs.rm(remoteRadianceFiles{ii});
%% Delete radiance data files from google cloud and local
if gcloud
% Build the directories from the hints
remoteRadianceFiles = gs.ls('cloud-example/renderings/PBRTCloud');
for ii=1:length(remoteRadianceFiles)
gs.rm(remoteRadianceFiles{ii});
end
end
delete('/scratch/wandell/render_toolbox/cloud-example/renderings/PBRTCloud/*radiance*');
%% Full path to the object we are going to render
sceneFile = which('millenium-falcon.obj');
sceneFile = which('Dragon.blend');
% Is there a way to make this be a camera ob
% Camera set to be 50 meters from an object distance
% This could be an array of cameras.
cameras = rtbCamerasInit('type',{'lens'},...
'mode',{'radiance'},...
'distance',25);
'distance',25,...
'pixelSamples',512);
nCameras = length(cameras);
% Set up the work space
......@@ -105,28 +108,39 @@ mfScene = mexximpCleanImport(sceneFile,...
%% Initiate some positions
clear objects
% Not sure how I set the camera to look at the middle of the bounding box of the
% object.
% Find the current bounding box of the object, which is set below. The midPoint
% is not yet used.
[box3D , midPoint] = mexximpSceneBox(mfScene);
objects(2).prefix = ''; % Note that spaces or : are not allowed
objects(2).position = [0 0 0];
objects(2).position = [0 50 50];
objects(2).orientation = 30;
% [xmin xmax; ymin ymax; zmin zmax],
[box3D , midPoint] = mexximpSceneBox(mfScene);
objects(2).bndbox = mat2str(box3D);
% objects(2) = objects(3);
% objects(2).position = [-5 -5 0];
objects(1) = objects(2);
objects(1).position = [0 0 10];
objects(1).orientation = 60;
% Assemble the objects into a cell array of object arrangements
objectArrangements = cell(length(objects),1);
for ii=1:length(objects)
objectArrangements{ii} = objects(ii);
end
% For each fixed configuration of the objects, we render a series of images for
% different camera properties. For example, this function sets particularly the position,
% lookAt and film distance variables. Other slots are copied from the camera
% object itself. The placedCameras combine the different object arrangements
% and cameras. The output is placedCameras{nCameras}(nArrangements).
% different camera properties. This function sets the camera position, lookAt
% and film distance variables for each combination of camera and object
% arrangements. Other slots in placedCameras are copied from the cameras object.
%
% I am confused about what camera.position means. From following the code, it
% might mean the position of the object that camera is looking at.
%
% Also, the camera has a position and also a height. The position is 3D and the
% height is one number that in this cases matches the 3rd dimension of the
% position.
%
% The dimensions of this variable are placedCameras{nCameras}(nArrangements).
placedCameras = rtbCamerasPlace(cameras,objectArrangements);
%% Make values used for the Conditions file.
......@@ -206,10 +220,14 @@ fprintf('Jobs initiated\n');
%% Download, but check when ready
% To get rid of the Warning and to speed things up, we should follow the
% Installation instructions on this page.
% https://cloud.google.com/storage/docs/gsutil/addlhelp/CRC32CandInstallingcrcmod
%
radianceDataFiles = [];
while isempty(radianceDataFiles)
radianceDataFiles = rtbCloudDownload(hints);
pause(20);
pause(30);
end
% We aren't saving the radianceDataFiles for all the conditions.
......@@ -233,7 +251,7 @@ fov = 45;
meanIlluminance = 10; % Lux
%
for i=1:1 %slength(radianceDataFiles)
for i=1:length(radianceDataFiles)
% chdir(fullfile(nnGenRootPath,'local'));
% save('radianceDataFiles','radianceDataFiles');
......
function [ camera ] = rtbCamerasInit( varargin )
% Generate an array of cameras with various parameters for rendering
%
% Used in conjunction with object placement for multiple scenes.
% Used in conjunction with object placement for multiple scenes.
%
% See also: s_cloudExample.m
%
% HB SCIEN STANFORD< 2017
% HB SCIEN STANFORD 2017
%% Programming todo
% Shouldn't this use the same syntax as in the nnConditions. As written it is
% very specific to a notion of camera that isn't formally defined.
% Not sure what to do.
%%
p = inputParser;
p.addOptional('type',{'pinhole'});
......@@ -37,70 +41,70 @@ assert(length(inputs.microlens)==length(inputs.lens) || length(inputs.microlens)
cntr = 1;
for a=1:max([length(inputs.type), length(inputs.lens), length(inputs.microlens)])
for b=1:length(inputs.pixelSamples)
for c=1:length(inputs.distance)
for d=1:length(inputs.orientation)
for e=1:length(inputs.height)
for f=1:length(inputs.PTR)
for g=1:length(inputs.defocus)
for h=1:max([length(inputs.diffraction), length(inputs.chromaticAberration)])
for i=1:length(inputs.fNumber)
for j=1:length(inputs.filmDiagonal)
for k=1:length(inputs.mode)
for l=1:length(inputs.lookAtObject)
if length(inputs.type) == 1
camera(cntr).type = inputs.type{1};
else
camera(cntr).type = inputs.type{a};
end
if length(inputs.lens) == 1
camera(cntr).lens = inputs.lens{1};
else
camera(cntr).lens = inputs.lens{a};
end
if length(inputs.microlens) == 1
camera(cntr).microlens = inputs.microlens{1};
else
camera(cntr).microlens = inputs.microlens{a};
for b=1:length(inputs.pixelSamples)
for c=1:length(inputs.distance)
for d=1:length(inputs.orientation)
for e=1:length(inputs.height)
for f=1:length(inputs.PTR)
for g=1:length(inputs.defocus)
for h=1:max([length(inputs.diffraction), length(inputs.chromaticAberration)])
for i=1:length(inputs.fNumber)
for j=1:length(inputs.filmDiagonal)
for k=1:length(inputs.mode)
for l=1:length(inputs.lookAtObject)
if length(inputs.type) == 1
camera(cntr).type = inputs.type{1};
else
camera(cntr).type = inputs.type{a};
end
if length(inputs.lens) == 1
camera(cntr).lens = inputs.lens{1};
else
camera(cntr).lens = inputs.lens{a};
end
if length(inputs.microlens) == 1
camera(cntr).microlens = inputs.microlens{1};
else
camera(cntr).microlens = inputs.microlens{a};
end
camera(cntr).mode = inputs.mode{k};
camera(cntr).pixelSamples = inputs.pixelSamples(b);
camera(cntr).fNumber = inputs.fNumber(i);
camera(cntr).filmDiagonal = inputs.filmDiagonal(j);
camera(cntr).distance = inputs.distance(c);
camera(cntr).orientation = inputs.orientation(d);
camera(cntr).height = inputs.height(e);
camera(cntr).PTR = inputs.PTR{f};
camera(cntr).defocus = inputs.defocus(g);
if length(inputs.diffraction) == 1
camera(cntr).diffraction = inputs.diffraction{1};
else
camera(cntr).diffraction = inputs.diffraction{h};
end
if length(inputs.chromaticAberration) == 1
camera(cntr).chromaticAberration = inputs.chromaticAberration{1};
else
camera(cntr).chromaticAberration = inputs.chromaticAberration{h};
end
camera(cntr).lookAtObject = inputs.lookAtObject(l);
cntr = cntr+1;
end
end
end
end
end
end
end
end
end
end
end
camera(cntr).mode = inputs.mode{k};
camera(cntr).pixelSamples = inputs.pixelSamples(b);
camera(cntr).fNumber = inputs.fNumber(i);
camera(cntr).filmDiagonal = inputs.filmDiagonal(j);
camera(cntr).distance = inputs.distance(c);
camera(cntr).orientation = inputs.orientation(d);
camera(cntr).height = inputs.height(e);
camera(cntr).PTR = inputs.PTR{f};
camera(cntr).defocus = inputs.defocus(g);
if length(inputs.diffraction) == 1
camera(cntr).diffraction = inputs.diffraction{1};
else
camera(cntr).diffraction = inputs.diffraction{h};
end
if length(inputs.chromaticAberration) == 1
camera(cntr).chromaticAberration = inputs.chromaticAberration{1};
else
camera(cntr).chromaticAberration = inputs.chromaticAberration{h};
end
camera(cntr).lookAtObject = inputs.lookAtObject(l);
cntr = cntr+1;
end
end
end
end
end
end
end
end
end
end
end
end
function [ cameras ] = rtbCamerasPlace( cameras, objects )
% Assign camera values so that they are looking at the object position
% Assign camera values to look at the object position
%
%
% HB SCIEN Stanford, 2017
% Maybe we can get rid of this somehow
%% Maybe we can get rid of this somehow
global lensDir
%%
nArrangements = length(objects);
cameras = repmat({cameras},[1, nArrangements]);
for a=1:nArrangements
for i=1:length(cameras{a})
% Which object - this is an index
lookAtObject = cameras{a}(i).lookAtObject;
% Find the object position
objPosition = objects{a}(lookAtObject).position;
% Set the camera position and lookat direction towards that object
cx = cameras{a}(i).distance*sind(cameras{a}(i).orientation) + objPosition(1);
cy = cameras{a}(i).distance*cosd(cameras{a}(i).orientation) + objPosition(2);
cameras{a}(i).position = [cx, cy, cameras{a}(i).height];
cameras{a}(i).lookAt = objPosition;
cameras{a}(i).lookAt(3) = cameras{a}(i).height;
% Set the camera film distance to be in focus for the object?
lensFile = fullfile(lensDir,sprintf('%s.dat',cameras{a}(i).lens));
if strcmp(cameras{a}(i).type,'pinhole')
cameras{a}(i).filmDistance = effectiveFocalLength(lensFile);
else
% Uses CISET to find the sensor distance
% Why is the object distance stored in cameras?
cameras{a}(i).filmDistance = focusLens(lensFile,cameras{a}(i).distance);
if cameras{a}(i).defocus ~= 0
lens = lensC('fileName',lensFile);
focalLength = lens.focalLength;
% Units are unspecified, and scaling by 1000 is a problem
% throughout. (BW).
% Equivalent to focusLens in previous if/else block
sensorInFocus = 1/(1/(focalLength/1000) - 1/cameras{a}(i).distance);
sensorOutOfFocus = 1/(1/(focalLength/1000) + cameras{a}(i).defocus - 1/cameras{a}(i).distance);
......
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