Simple Features (Euler, ImgTexture, Spotlight)

Euler Rendering

Modified Files:

src/main.cpp

src/render.cpp

Implementation

The rendering on eulers requires headless program, so the GUI initialization in original main function will fail. The created GUI is an indepedent thread which launches a rendering thread and frequently querying the data structure of rendering threads to display the intermediate results. To achieve headless rendering, we bypass the GUI class and directly launch rendering thread in main.cpp function. In addition, to better monitor the progress of rendering on Euler cluster, we add support for progress report and storing intermediate checkpoints. The final rendering script on Euler is like following example:

sbatch --ntasks=16 --time=4:00:00 --wrap="cd build; ./nori ../scenes/pa4/table/table_path_mis.xml gui false report_step 20 checkpoint_step 10"

Validation

We compare the images rendered on PC and Euler. The images only have differences due to different sampling and mean error = 0.

PC Euler

Image Texture

Modified Files:

src/imgtexture.cpp

src/bitmap.cpp

Implementation

We use provided bitmap class to read image base-color texture in exr format. For each querying with uv coordinate, we interpolate the texture values from the bitmap. The interpolate() function is implemented in src/bitmap.cpp. It's implemented by bilinearly interpolating four surrouding pixel values according to the distance to them. For getting uv coordiante, in mesh type object, if its uv coordinates are provided, the setHitInformation() in src/mesh.cpp will interpolate the uv coordinates according to the bary centric coordinate of the intersection point. Then, we can pass uv information when we are creating BSDFQuery.

To control the contrast effect of image texture, we add support for exponential scaling. Bigger scaling will improve the contrast effect on the final result. The image coordinate has top-left as (0,0) but uv has bottom-left as (0, 0), therefore, the uv coordinate's second dimension must be reversed to get image coordiante before querying the bitmap.

Validation

image texture

with texture (exp scale=1.0) with texture (exp scale=2.0) no texture

Spotlight

Modified Files

src/spotlight.cpp

Implementation

The spotlight is specified by position, direction, power, total angle and fall-off angle. The total angle defines the maximum range that can be lightened, and the fall-off angle defines the boundary out of which attenuation begins.

In eval() function, radiant intensity is computed based on total light power and the angles of maximum and fall-off. (ref: PBRT-v3)

$$I = \frac{Power}{2 \pi (1 - 0.5 (\cos\theta_{total} + \cos\theta_{falloff}))}$$

Then, the intensity is weighted by fall-off coefficient. The coefficient is ranged between [0, 1]: 1 if within the falloff angle, 0 if outside the maximum angle, linear interpolation on cosine range if between them.

$$W(\theta) = \frac{\cos \theta - \cos \theta_{falloff}}{\cos \theta_{total} - \cos \theta_{falloff}}$$

The final evaluated radiance is:

$$R = \frac{I\times W(\theta)}{distance^2}$$

For sampling on the spotlight, since it has no area, the sampled point is its position as same as the pointlight. The pdf is set to 1.0 and eval() is called to compute the radiance.

Validation

Increase fall-off angle, the boundary will become more obvious and power distribution is more uniform, resulting decreased global lumination.


Increase spotlight power, the lumination increases but the lighting pattern is unchanged.


Increase total angle, spot light illuminates more place but decreases the global illumination.

.center { display: block; margin-left: auto; margin-right: auto; width: 50%; }