Starting from:

$30

CS4247-Assignment 4 Solved

 Assignment Overview
§  You are provided with an incomplete C/C++ program that implements the progressive refinement radiosity algorithm

§  Task 1

ú  Complete the program

ú  Generate a radiosity solution for the sample input scene

§  Task 2

ú  Create a new input scene model

ú  Generate a radiosity solution for the new scene

 Learning Objectives
§  Implementing the Progressive Refinement Radiosity Algorithm

§  After completing the assignment, you should have learned

ú How to use the Hemicube algorithm to estimate form factors:

§  How to compute delta form factor for each pixel on the hemicube § How to set up OpenGL views to project the scene onto the faces of the hemicube

§  How to use the item buffering technique to identify the patch that occupies a pixel

ú How the progressive refinement radiosity algorithm works:

§  How to “shoot” light power from a shooter patch to the gatherer patches, and update the radiosity values of these patches

§  How to update the unshot power of a shooter patch with the new power received by its child gatherer patches

§  How to terminate the progressive refinement radiosity computation

 What Are Provided (1) – For Windows
§  Download the file cs4247_2021S2_assign4_todo_(win-vs2017).zip from the Assignments folder in LumiNUS Files § The ZIP file contains a Visual Studio 2017 solution file assign4.sln. The solution has three C/C++ projects

ú  QuadsViewer

ú  RadiositySolver

ú  RadiosityViewer

§  Tip: In Visual Studio, to make a project the default project to be built and run, you can right-click on the project name in the Solution 

Explorer, and select “Set as StartUp Project”

 What Are Provided (1) – For macOS
§  Download the file cs4247_2021S2_assign4_todo_(mac-xcode).zip from the Assignments folder in LumiNUS Files

§  The ZIP file contains the Xcode project assign4.xcodeproj, which has the following three C/C++ targets

ú  QuadsViewer

ú  RadiositySolver

ú  RadiosityViewer

 What Are Provided (2)
§  QuadsViewer is a completed (old-style) OpenGL application that lets you preview the input scene model and check the subdivision of the input quads into smaller “shooter” quads and even-smaller “gatherer” quads

ú  The default input scene model file is model.in

ú  Gatherer quads are obtained by subdividing shooter quads ú Press “m” to cycle through display of the input quads, the shooter quads, and the gatherer quads

ú  In quadsviewer.cpp, the size of the shooter and gatherer quads are controlled by the values of maxShooterQuadEdgeLength and maxGathererQuadEdgeLength respectively

§  These two values are from the input scene model file model.in

§  radiositysolver.cpp also uses these two values for the same purpose

 What Are Provided (3)
§  RadiositySolver is the incomplete program that 

ú  Reads the input scene model from model.in

ú  Subdivides the input quads into “shooter” and “gatherer” quads

§  In radiositysolver.cpp, the size of the shooter and gatherer quads are controlled by the values of maxShooterQuadEdgeLength and maxGathererQuadEdgeLength respectively

ú These two values are from the input scene model file model.in ú Computes a radiosity solution for the scene

§  This step is the part to be completed

ú  Computes vertex radiosities from the patch radiosities

§ This step can take very long to run, so you should first test your radiosity algorithm implementation with a model with not too many gatherer quads

ú  Outputs the model with radiosity solution to the file model.out

 What Are Provided (4)
§  RadiosityViewer is a completed (old-style) OpenGL application that lets you view the model output by RadiositySolver

ú  Reads in a model with radiosity solution from file model.out

ú  Performs simple tonemapping to map radiosity values to displayable color values (i.e. to R, G, B values from 0.0 to 1.0)

ú  Renders the polygons using the tonemapped radiosity values as vertex colors

ú  You can try the viewer on the given sample model file cornell_box.out

§  First, copy cornell_box.out to the file model.out

§  Note that the sample cornell_box.out has been “watermarked” with some bright and dark patches — your radiosity solution for cornell_box.in should not have those

 Task 1
§ Complete only the source file radiositysolver.cpp, which is part of the RadiositySolver project

ú  Complete the code at places marked “WRITE YOUR CODE HERE”

ú  You can add additional functions to the file ú Use good coding style and document your code adequately (otherwise marks deducted)

ú  Study the files quadmodel.{h,cpp} to see how the scene model and its subdivided quads are represented

ú  You can make use of helper functions found in common.h and vector3.h

 Task 1 (continue)
ú  Test your program on the provided sample input scene model cornell_box.in

§  Before running your RadiositySolver, copy cornell_box.in to the file model.in

§  After running your RadiositySolver, copy the output file model.out to cornell_box_my.out

ú  View your radiosity solution model.out using RadiosityViewer

(in non-wireframe mode) and capture three different snapshots

§  On Windows 10, you can use the Snip & Sketch tool (press Win + Shift + “S”) to take a snapshot of the window and save the image

§  Use the default window size

§  Save the three snapshots to image files

úcornell_box_1.png úcornell_box_2.png

úcornell_box_3.png

 Task 1 — RadiositySolver Explained
§  RadiositySolver uses to the Progressive Refinement Radiosity algorithm to compute patch radiosity of each gatherer quad

ú Pre-compute the delta form factors on the top face (already done) and side faces of the hemicube

§  Note that top hemicube face has same pixel resolution as the default window size (always a square)

ú Progressive Refinement Radiosity loop

§  Find the shooter quad with the greatest unshot power

§  Use a hemicube to compute form factors from the shooter quad to each of the gatherer quads

§  Update the radiosity of each of the gatherer quads

§  Update the unshot power of each shooter patch with the new power received by its child gatherer patches

§  Terminate loop if max iterations is reached

 Task 2
§  Create a new scene model

ú  Study the sample scene model cornell_box.in to find out the input model file format

ú  Name your new scene new_model.in

ú  Run your RadiositySolver program on new_model.in to output new_model.out

ú  View new_model.out in RadiosityViewer and capture three different snapshots

§  Use the default window size

§  Save your snapshots to image files

únew_model_1.png únew_model_2.png

únew_model_3.png

More products