Skip to content

Read Write functions

David Cardinal edited this page Oct 11, 2021 · 6 revisions

The iset3D logical flow is

(a) read in the PBRT scene and its auxiliary files,

(b) specify the rendering parameters, and

(c) write out the PBRT scene with adjusted parameters into a directory that will be mounted and rendered by the docker container.

piRead

The piRead function takes the name of the PBRT scene file as input and returns a rendering recipe (@recipe) as output.

pbrtFile = fullfile(piRootPath,'data','teapot-area','teapot-area-light.pbrt');
thisR = piRead(pbrtFile);

Typically, after the rendering recipe is returned the user specifies, say, the camera position, the lens properties, and the directory that will be mounted by the docker container (outFile). Once these properties are set, the modified recipe is called with the piWrite function.

piWrite

The piWrite function takes the recipe object as an input and writes out a new scene PBRT file into the directory that will be mounted by the docker image. The function also copies the resources that are needed to render the file from the original data directory to the new directory. A typical example is

[p,n,e] = fileparts(pbrtFile); 
thisR.set('outputFile',fullfile(piRootPath,'local','testworld',[n,e]));
piWrite(thisR);

The piWrite function performs one additional change: The text lines between the WorldBegin/WorldEnd commands is written out to a separate file, world.pbrt. The main scene PBRT file includes these commands via an Include directive that is added at the end of the scene PBRT file

WorldBegin
Include "world.pbrt"
WorldEnd

We make this adjustment because we frequently upload these scene files to the Cloud for rendering. The differences between the files that we render are often no more than changes in the camera lookAt or the lens properties or the lighting properties. The WorldBegin/End text is constant, and yet it can be quite large. By writing it out as a separate file, we need to upload it to the cloud only once. This saves both on transfer time and disk usage.

Clone this wiki locally