Unity代写 | 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. We have provided you with a template C#
implementation that you will need to complete. We are not using the Unity engine,
however, you may and that some of the theory in this assignment will be transferable to
Unity development (particularly the maths). The assignment is broken down into nu-
merous 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-o 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 unsuit-
able 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.

There are plenty of resources about ray tracing online. You are welcome to use these
resources. If you do, we strongly encourage you to make sure you understand those
resources, rather than just copying bits of their code. It is also a good idea to consult
multiple sources to check whether there are significant differences in their approach.
Note that the use of external libraries or code dependencies is not allowed { part of the
fun of building a ray tracer is that it can be done from scratch!

Stage 1 – Basic ray tracer (12 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 re ects of 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 study will come later in the assignment.

Stage 1.1 – Familiarise yourself with the template

Before writing any code, try to fully 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 han-
dling. 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 di-
rectly 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 run:
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 le
(-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.

You can see this by taking 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 (e.g., the default image width and
height), instead pass values using the appropriate ags on the command line, if you want
to change parameters.



本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: itcsdx@outlook.com  微信:itcsdx