程序代写|COMP30019 – Graphics and Interaction

这是一篇来自澳洲的关于图形和交互的Project 1: Ray Tracer程序代写

 

Assignment Brief

You are tasked with building a ray tracer. Your ray tracer will output a single static PNG image, based on an input ‘scene’ file and command line arguments. We have provided you with a template C# implementation that you will need to complete. We are not using the Unity engine in this project, however, you may find that some of the theory in this assignment will be transferable to Unity development (particularly the maths). The assignment is broken down into numerous stages and steps. Our expectations for each stage and the respectively allocated marks are outlined in detail below. You should aim to complete each step in sequence since this will make the process less overwhelming.

There are various approaches to modelling how light interacts with surfaces in a scene.

Almost always, the choice of approach comes down to a trade-off between computational complexity and realism. A ray tracing based approach can produce very realistic images,however this comes with a significant computational cost that generally makes it unsuitable for real-time rendering. Even if there are no real-time rendering requirements, we still have to approximate and optimise the ray tracing process, since simulating all rays in a scene is computationally intractable.

Template code

You will be given a GitHub repository to work on your project that is already preinitialised with the template code. This is a private repository, so you may commit/push to it without worry of other students having access to your work. You are expected to use GitHub from the start through to the end of the project, and should commit and push frequently. We won’t accept submissions not hosted in your private repository.

A link to accept the assignment and automatically create your template repository is provided on the Canvas project page (where you found this specification document). Note that you may submit the assignment as many times as you wish – only the latest will be marked.

Stage 1 – Basic ray tracer (9 marks)

You will first implement the basic functionality of a ray tracer. At its core, ray tracing is an application of geometry and basic linear algebra (vector maths will become your bread and butter!). For example, a ray of light can be modelled by two three-dimensional vectors: a starting position and direction. Surfaces, light sources, and other entities in the environment can also be defined using vectors. Using geometry, it is possible to calculate how a ray reflects off a surface, or perhaps even refracts through it. Ultimately we are interested in simulating rays of light propagating throughout the environment,interacting with various surfaces, before finally reaching the viewer as pixels on their screen. If we are clever in utilising ‘real-life’ physical models for these interactions, we can generate incredibly realistic scenes.

In this first stage you will implement some basic vector functionality, and figure out how to shoot a ray for each pixel in a rendered image. We won’t yet be worrying about materials, lighting, shading, etc. Such fancy stuff will come later in the assignment.

Stage 1.1 – Familiarise yourself with the template

Before writing any code, try to understand how the template provided to you works. We have already taken care of quite a few details for you, such as input and output handling.

A sample input scene is provided to you in a text file (tests/sample scene 1.txt), and a parser for this file has been written so you can access objects and resources directly within the Scene class (src/scene/Scene.cs). The core ray tracing logic (which you will write) should be implemented inside the Render() method in Scene.cs. This method takes an Image object for which you can set the individual colour of each pixel, as well as derive properties such as its width and height. When the program is run, this image will automatically be outputted as a PNG image file.

Try running the project so that you can see this in action. Open up the terminal in Visual Studio Code (or your preferred environment), and run1:

dotnet run — -f tests/sample_scene_1.txt -o output.png

Although this looks like a bit of a mouthful at first, all it is doing is running the project with two command line arguments: an input text file (-f) and an output image file (-o). The input file will be read and parsed, and the output image written accordingly.

Open the generated output file, and you will notice the entire image is black, since no ray tracing has been implemented yet. Before continuing, test your understanding by modifying the project code to output the image entirely in white instead.

Hint:

Try using some loops inside the Render() method. The Image class has Width and Height properties which should be handy for determining the loop bounds. These properties are already determined by the command line arguments -w and -h, if specified.

Now take a look at the main Program.cs file. In the OptionsConf class, you can see all of the potential command line arguments and their default values (these are the values used if that argument is not specified at runtime – e.g., not entered on the command line). Don’t change these default values, instead, pass values using the appropriate flags on the command line, if you want to change parameters. At this point it’s worth stressing that you should not modify the Program.cs file at all. Doing so risks our automated test suites breaking when running your project during marking (see the ‘Submission‘ section for details).