RenderToolbox SphereRenderer
I. User Reference
Geometry- Sphere radius: Radius of sphere in pixels. The display window is clipped to a rectangle around the sphere with a resolution of (2*radius+1)-by-(2*radius+1). The center of the sphere defines the origin of the local coordinate system.
- View distance: Specifies the distance along the z-axis in the local coordinate system from which the user views the sphere.
Point Lights
- ‘Choose:’, allows the user to choose from a menu of preset SPDs. The SPDs are stored in the ‘lights’ folder, which must reside in the same folder as ward_gui.m. Each file must be of the [name].mat format, and contain a variable S_[name] specifying the sample ~frequencies, and [name], specifying the spectral power distribution at those frequencies.
- The ‘Flat’ option allows the user to add a point light with a flat SPD, the magnitude specified by ‘Scale Factor’.
- ‘User Specified’ allows the user to type of paste an SPD into the text field, which must be sampled at 400-700nm in 10nm increments.
- ‘Scale Factor’ scales each value of the chosen SPD by the entered value.
After choosing the appropriate settings, click ‘Add light’ in order to add the specified light to the list of lights. In order to change the settings of a light, it must be removed and replaced by a light with correct settings. Click ‘Plot Spectrum’ to view a graph of the SPD of the selected light.
Ambient Lights
The ambient light is specified by the same parameters as the point lights.
Diffuse Reflectance
- The first option allows the user to choose among the Macbeth Color checker colors in order to specify the SRF of the sphere.
- ‘Choose:’ allows the user to choose from the SRF files in the folder ‘colors’ called [name].mat. Each file must contain a vector S_[name] specifying the wavelengths at which the SRF is measured, as well as an array [name] which specifies the actual SRF.
- ‘Flat’ allows the user to specify a flat SRF, the magnitude specified in ‘Scale Factor’.
- ‘User Defined’ allows the user to type or paste a SRF, which must be sampled from 400-700nm at 10nm increments.
- ‘Scale Factor’ multiples each element of the chosen SRF by the specified number. Plot spectrum displays a plot of the specified SRF.
Specular Reflectance
Settings do not differ from those of the diffuse reflectance.
Specular Blur
Allows the user to set a flat specular blur of the set magnitude or a user specified specular blur.
Tone Mapping
Choose a tone mapping method from the menu, and set the parameters in the list. Tone maps are functions listed in the toneMaps folder in the same folder as ward_gui.m. If ‘lock’ is not selected, each tone map function automatically determines the settings most appropriate for the rendered image. If ‘lock’ is selected, the tone map applies the settings from the last time the selected tone map was run unlocked. Do not select ‘lock’ on the first run of a tone map.
II. Program Scheme
1) ward_gui-initializes GUI based on ward.fig. contains callbacks to each GUI elements- ward_gui_OpeningFcn-called at start of program. sets defauls parameters, loads info from data files and populates menus
- loadLightsAndColors-first loads files [light_name].mat from ‘lights’ folder. Within each of these files must be a vactor S_[light_name] specifying the sampling wavelengths of the light SPD. The SPD must reside in the variable [light_name]. The function splines the SPD into the wavelength spectrum specified in handles.sampleVec. loadLightsAndColors next populates the lights popupmenu allowing the user to choose from available light sources, setting the default to D65 daylight, should that file exist in the ‘lights’ folder. The function next follows the same procedure to load available SRFs from the ‘colors’ folder. As before, these files must contain the vector S_[color_name] and [color_name], respectively specifying the sample wavelength spectrum and SRF.
- loadToneMap-This function looks in the folder ‘toneMaps’ for available tone mapping functions, and populates the tone map popup menu with the available choices. (see the tone map section below for more information)
- Macbeth Colors-ward_gui next loads the Macbeth colors from ‘sur_macbeth’, a file that must exist somewhere on the MATLAB path. It splines the loaded array, with a presumed title of ‘sur_macbeth’ and saves it in handles.macbethColors.
- Default values-ward_gui now sets a few of the GUI elements to their default values, and adds a lightwith these values (see addLight)
- pushbutton_addLight_Callback-called when user clicks the button ‘Add Light’
- addLight-Saves light, as specified in GUI in handles.lights(i) i is the number of the current light, saved in handles.currentLight, which increases by one after each addition of a light. The function places the specified SPD in handles.lights(i).spd, the name of the SPD (day light, flat, etc…) in handles.lights(i).spdString, the light position in handles.lights(i).position and the scale factor in handles.lights(i).scaleFactor. The function then refreshes the listbox of light sources to reflect the newly added light.
- pushbutton_render_Callback-called when the user clicks the ‘Render’ button.
- doRender-renders an image of the sphere. (see render section below)
- pushbutton_removeLight_Callback-called when user clicks the button ‘Remove Light’
- removeLight-Removes the selected light from handles.lights, and shifts the subsequent elements of handles.lights forward one position. Refreshes the listbox to reflect changes.
- pushbutton_plotAmbientLight_Callback, pushbutton_plotLight_Callback
- plotAmbientLight, plotPointLight called respectively. Plot the SPD of either the ambient light or the selected point light, as specified in the GUI
- pushbutton_plotDiffuseReflectance_Callback, pushbutton_plotSpecularReflectance_Callback-plot the SRF of either the diffuse reflectance or the specular reflectance.
- popupmenu_toneMapFiles_Callback-called when the user selects a new tone map from the tone map popup menu
- updateToneMapParameterList-populates the tone map parameter list boxwiththe parameters appropriate tothe selected tone map (see tone map section below for more information)
- updateToneMapParameterValue-updates the value of the parameter value text box to reflect newly selected parameter. This is necessary after updating the parameter list because the first element of the refreshed list is selected by default requiring the text box to reflect this change.
- listbox_toneMapParameterList_Callback-called when the user selects and element from the tone map parameter list.
- updateToneMapParameterValue-displays the value of the current parameter in the text box.
- edit_toneMapParameterValue_Callback-called when the user changes the value in the tone map parameter text box
- setToneMapParameterValue-updates the appropriate value stored in handles.[tonemap_name].[parameter_name].
2) doRender-topmost level function that executes the rendering
- getGUIParams-returns user settings from gui as struct. (see params in section IV below).
- render(params)-takes params, returned by getGUIParams or programmed manually, and renders an image of the sphere.
- calculateSurfaceGeometry(params)-returns a list of geometry information for each pixel of the image in list form (see section V for notes on list vs. square form). The function returns two arrays, anglesOut and geometry out. render only uses anglesOut. (see anglesOut and geometryOut in section IV below)
- ward(params, angles)-calulates the hyperspectral illuminance of each pixel based on the ward model. Params is usually supplied by getGUIParams. Returns the lists reflectedLight, reflectedDiffuseLight, reflectedAmbientLight and reflectedSpecularLight. In each of these lists, each column has params.numSamples elements representing the hyperspectral illuminance for one pixel. Slices in the third dimention represent the luminance of each pixel due to each of the different light sources, the first source corresponding to the first slice, etc…
(1) ward_DiffuseLight, ward_AmbientLight and ward_SpecularLight -take the same params and angles variables as ward.
- toneMap(params,reflectedLight, reflectedDiffuseLight, reflectedSpecularLight, reflectedAmbientLight) maps hyperspectral in list formvalues to a list of XYZ color values according to the tone map specified in params.toneMapName. toneMap only passes the arrays
III. Tone maps
(not written yet)IV. Array and Struct Contents
1) params-returned by getGUISettings|
sampleVec |
[start increment numIncrements] |
|
radius |
scaler, measured in pixels |
|
viewPoint |
(x,y,z) row vector specifying position of view point |
|
numLightSources |
scaler |
|
lightCoords |
(x,y,z), one row per light |
|
lightIntensity |
SPD, one col per light, the first column corresponding to the first point light, etc… each col must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
daylightIntensity |
SPD, one one column, must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
ambientLightIntensity |
SPD, one one column, must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
diffuseConst |
one row, must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
specularConst |
one row, must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
specularBlurConst |
one row, must have the same number of elements as specified in the number of increments (sampleVec(3)) |
|
toneMapName |
string, name of current tone map to be used. must match the name of a function in the ‘toneMaps’ folder |
|
toneMapLock |
boolean, |
|
[tonemap_name] |
contains subfields, each titled with the name of a parameter and set equal to the value of that parameter as specified in the GUI |
|
xmin |
scaler, minimum x coord of local coordinate system |
|
xmax |
scaler, maximum x coord of local coordinate system |
|
ymin |
scaler, minimum y coord of local coordinate system |
|
ymax |
scaler, maximum y coord of local coordinate system |
|
rows |
scaler, number of rows in square image of sphere |
|
cols |
scaler, number of cols in square image of sphere |
|
numPoints |
scaler, number of points in square image (=rows*cols) |
|
numLightSources |
scaler, number of light sources |
|
numSamples |
scaler, number of sample wavelentgs (=sampleVec(3)) |
2) anglesOut-returned from calculateSurfaceGeometry
|
row 1 |
cos(theta_incident) |
|
row 2 |
cos(theta_reflected) |
|
row 3 |
cos(delta) |
|
row 4 |
tan^2(delta) |
3) geometryOut-returned from calculateSurfaceGeometry
|
rows 1-3 |
x, y and z coords of the pixel in local cords (see local coords vs. array indices) |
|
rows 4-6 |
x, y and z coords of the surface norm (specified in Ward) |
|
rows 7-9 |
x, y and z coords of the reflectance vector (specified in Ward) |
|
row 10-12 |
x, y and z coords of the half vector (specified in Ward) |
There are 4 comments on this page. [Display comments]