多伦多大学CSC D18Assignment1 课业解析

题意:
打造一个2D的渲染引擎
解析:
任务分为两个part和bonus部分。
Part1:A)第一部分是参数形式的几何表达式:1)考查光线l击中物体的p点(发现为n)的情况。a)光线击中一个椭圆时,参数a,b,c的值。b)画出椭圆、光线和法线的图形。c)因为圆是一种特殊的椭圆,写出圆形的方程。d)通过给定入射光线和折射率,计算入射角和折射角的关系。B)推导一个三位图形的切平面
Part2:根据给定的代码框架,实现光线传播算法。需要实现的场景中要包括:一个光源,一组圆形对象。
Bonus Part:1)增加场景中的物体,渲染除更酷的图像。2)实现光线的色散。3)实现彩色物体与光线的交互。
涉及知识点:
光线路径算法,参数函数
更多可加微信讨论
微信号 wanqcwanqcwanqc0219
pdf
F. Estrada, Aug. 2019
Assignment due date: Sep. 27th 12:00 (NOON)
Hand-in to be submitted at the D18 drop-box (4th floor IC),
code to be submitted on the mathlab server by the above due date
This assignment can be completed individually, or by a team of 2 students
Student Names (Last, First)
Student #1:
Student #2:
Student numbers
Student #1:
Student #2:
Student UtorIDs
Student #1:
Student #2:
We hereby afrm that all the solutions we provide, both in writing and in code,
for this assignment are our own. We have properly cited and noted any
reference material we used to arrive at this solution, and have not shared
our work with anyone else.


Student 1 signature Student 2 signature
(note: 3 marks penalty if any of the above information is missing)
CSC D18 – Fall 2019
Assignment 1 – Basic Geometry and 2D Light Transport
1
This assignment is intended to help you master the basic geometric principles we will use for
the rest of the term to build our advanced rendering engine. To that end, you will practice
2D geometry, develop an intuition of how 2D parametric lines can be used to represent light
rays, understand how we can represent simple objects and how these interact with our
light rays, and use simple transformations to build a simple, but accurate renderer for light
transport in 2D.
After completing this assigment, you will have gained the ability to simulate and visualize light
and its interactions with scene components!
Learning Objectives – after completing this assignment you should be able to:
Manage points and vectors using simple operations such as additions, dot, and cross products.
Represent light rays using 2D parametric equations. Represent objects using 2D implicit and
parametric forms.
Apply afne transformations to points and vectors, and use them to simulate the propagation
of light through a simple scene.
Determine points of intersection between light rays and simple scene objects (this is the basis
of ray tracing, which we will be fully developing soon).
Simulate the basic behaviour of light as it interacts with object surfaces: Reflection, scattering,
and refraction.
Explain how simple light sources behave, and the difference between primary and secondary
illumination.
Skills Developed:
Thinking in terms of geometry and vectors.
Manipulating simple geometric entities algebraically: rays, circles, boxes.
Using 2D transformations to implement code that bounces, reflects, and refracts light rays
according to fundamental principles of optics.
Understanding and extending code that deals with images, light rays, and objects.
Reference material:
The Lecture notes up to this point, found on the course website.
This handout (be sure to read everything carefully).
The comments in the starter code.
CSC D18 – Fall 2019
Assignment 1 – Basic Geometry and 2D Light Transport
F. Estrada, Aug. 2019
2
Part 1 – Written work. Be sure to provide clean, legible derivations and do not omit any steps your
TA may need to understand your work. Use diagrams wherever appropriate.
A) 2D – Parametric forms and the geometry of light transport

  1. A light ray hits an object at a point with surface normal
    a) [3 marks] – If the object is a 2D ellipse,
    (centered at [c
    x
    , c
    y
    ])
    Develop an equation in terms of that yields the
    value of at the intersection point between the ray and the ellipse.
    You should arrange things so your solution is in the form of a 2nd degree
    equation, make sure to show what the value of a b, and c are.
    Test your derivation by fnding the intersection between the ellipse
    and the ray given by
    b) [3 marks] – Provide the expressions that yield the components of the normal vector
    at the intersection. Test your derivation by computing the normal
    for the ellipse and ray in a), and draw a graph with the ellipse, ray,
    Intersection, and normal vector. If the graph looks wrong, check
    your work.
    c) [3 marks] – A circle is a special case of an ellipse. Show what the equations in a)
    and b) reduce to if the ellipse is such that a = b, c
    x
    =0, c
    y
    =0. Be sure
    to explicitly represent the radius of the circle!
    d) The diagram below shows the geometry of refraction. A ray
    arriving at a surface, is bent from direction
    With the angles between the incident and refracted rays being
    given by Snell’s law:
    [2 marks] Show how to determine and the angle of refraction
    given , (are the indexes of refraction)
    [2 marks] Show and explain with a diagram how to obtain vector
    using and simple 2D rotations.
    Test your procedure by computing the refraction direction
    given
    ( Attach any work for this part immediately after this page)
    CSC D18 – Fall 2019
    Assignment 1 – Basic Geometry and 2D Light Transport
    F. Estrada, Aug. 2019
    3
    B) Parametric surfaces, surface geometry, and transforms
    Here, you will analyze the surface shape of a parametric 3D surface you may
    have heard of before: The Mobius strip. The goal is to identify tangent planes and
    normal directions at arbitrary points on the surface – this would be required to render
    the strip in any 3D software.
    The surface of a Mobius strip with width w is given by:
    (http://mathworld.wolfram.com/MoebiusStrip.html)
    Where R is a constant, and represents the distance from the origin to the centerline of the Mobius strip, s is a parameter in [-w, w], and t is a parameter in [0, 2*Pi].
    Plotting points for a range of values of s and t yields the familiar shape of the Mobius
    strip:
    a) [2 marks] Derive the equations for the tangent plane at any point (s,t) on the
    surface. This is a parametric surface so we expect the tangent plane
    as a parametric plane defned by two vectors spanning the plane.
    多伦多大学CSC D18Assignment1 课业解析_第1张图片
    b) [2 marks] Determine the implicit equation for the tangent plane. This will
    requite you to fgure out the normal to the plane.
    c) [3 marks] The Mobius strip above is centered at the origin, and its axis is the
    z axis (shown as a red line above, the strip wraps around it). Suppose
    we need to render a Mobius strip whose centerpoint is at
    and whose axis is aligned with .
    Determine the sequence of transformations that takes points
    on the Mobius strip above and produces the desired
    transfomed strip. For rotations, show the rotation matrix and
    show how the angle of rotation is computed. The transform
    sequence must be shown in the correct order.
    CSC D18 – Fall 2019
    Assignment 1 – Basic Geometry and 2D Light Transport
    F. Estrada, Aug. 2019
    4
    Part 2 – Understanding how light works, 2D light transport
    多伦多大学CSC D18Assignment1 课业解析_第2张图片
    Your task for this assignment is to implement the core components of a light-propagation
    Algorithm. The task of the algorithm is fairly simple:
    Given a scene consisting of
    a) 1 light source (which has a known position, colour, and type)
    b) A set of objects (which in this case are circles, with known position and material type)
    The program will:
  2. Emit a light ray from the light source
  3. Propagate the ray through the scene until it hits an object (or one of the 4 walls that
    make up the image boundary)
  4. It then will bounce the ray in a physically consistent way, depending on the material
    the object the ray hit is made of
    The starter code provides most of the nuts and bolts you need to implement the interesting
    bits, so you will focus on the geometric issues involved with the steps described above, and write
    a little (but not a lot!) of code. Then you can sit back and watch your program trace light around
    a scene you created!
    Pattern of light resulting from a point light source
    (at the center of the image) and a set of refracting
    spheres
    CSC D18 – Fall 2019
    Assignment 1 – Basic Geometry and 2D Light Transport
    F. Estrada, Aug. 2019
    5
    Part 2 – Understanding how light works, 2D light transport (cont.)
    Step 1) Download and uncompress the starter code into a suitable directory. Take time now to
    compile and run it – learn what the command line arguments do, and how to use the
    program. Of course, at this point it won’t be able to trace light, but it will show you a
    box of the size you specifed, and the outlines of the objects defned for the scene.
    Step 2) Read all the header fles included with the starter code – I am providing you with a
    lot of functionality, so you should know what is already there for you to use, and not
    waste time implementing functions I’m providing. You will also get a picture of how the
    code is structured, and what parts you need to implement.
    Step 3) Read CAREFULLY the comments in rays2D.c – this is the fle you will be working on,
    and it has a couple of functions you must implement. The code has comments that
    will help you understand what you need to do.
    Once you’re done reading these comments, take a short break, then come
    back and read them again to make sure you didn’t miss anything.
    Step 4) Implement your solution. There are of course many ways to go about doing this, but
    I would suggest starting with casting rays from simple ‘laser’ light sources, and
    intersections between rays and walls.
    That gives you a basic framework on which to build the rest. The starter code will
    tell you what needs to be implemented. Test everything thoroughly, and for
    more than one case – your code will be auto-tested, so make sure it does the
    right thing on different scenes.
    For testing:
  • 1 or 2 samples, and recursion depth of 1 or 2 so you can check the basic
    geometry is correct.
  • Once you have the fundamental components working, increase sampling and
    recursion depth to check the process works to check the scene is rendered
    as expected.
    Of course, you should have a good idea what the scene
    Should look like given the light source
    And the objects in it
    CSC D18 – Fall 2019
    Assignment 1 – Basic Geometry and 2D Light Transport
    F. Estrada, Aug. 2019
    6
    Part 2 – Understanding how light works, 2D light transport (cont.)
    Notes: You are expected to use 2D rotations to generate the vector directions you need. This
    means your code needs to compute the relevant angles, determine suitable centers of
    rotation (and points to rotate), and then do the rotation to obtain whatever vector
    directions you need. Remember:多伦多大学CSC D18Assignment1 课业解析_第3张图片
    Step 5) Pack your code for submission:
  • Complete ‘autotester_id.txt’ so the auto-tester knows who you are.
    Compress your code into a single compressed .tgz fle named
    light2D_studentNo1_studentNo2.tgz (e.g. light2D_11223344_55667788.tgz)
    The tar command syntax is:

tar -cvzf name_of_your_compressed_tar_file.tgz *.c *.h autotester_id.txt
Then submit the compressed fle
submit -c cscd18f19 -a A1 -f name_of_your_compressed_tar_file.tgz
Double check that your compressed fle uncompresses properly, and that it contains
all the code as well as the ‘autotester_id.txt’ fle.
For reflection, the sign of the angle depends
on whether the normal is to the left or to
the right of the incoming ray
For refraction, be careful to account for the
directions of the different vectors which depend
on whether the ray is arriving at, or leaving
an object
Marking Scheme
Written problems 20 marks
Working code 30 marks (auto-tested)
Crunchy bonus Up to you!

CSC D18 – Fall 2019
Assignment 1 – Basic Geometry and 2D Light Transport
F. Estrada, Aug. 2019
7
Part 2 – Understanding how light works, 2D light transport (cont.)
Get Crunchy!
Of course, once you have a working 2D light transport engine, you want to use it to render
very cool images. For bonus marks, you can extend your renderer to:
[up to 10 marks] - Render a very cool scene (it should not be a clone of the one in this handout)
Spend some time placing objects with suitable materials around, and render
the scene at a reasonably good resolution, for lots of samples.
[10 marks] – Implement dispersion. White light is a mixture of light across all visible wavelengths.
Refracting objects bend light by different amounts depending on the wavelength,
and we expect them to spread out the different colour components in white light
(creating rainbows).
Modify your code to handle this by cleverly using sampling, and by manipulating the
index of refraction of the material depending on light wavelength.
Dispersion of light by refracting materials
[5 marks] - Implement spectral power distributions
for lightsources. Implement proper light
sources whose colour comes from a specifc
mixture of wavelengths at different amounts,
and have your light source emit rays that
follow this specifc mixture’s distribution.
[5 marks] - Implement coloured objects. Until now, all objects are ‘white’ in that they do not in
any way change the colour of the light bounced by, or transmitted through them.
modify your code so that it accounts for coloured objects.
Scene rendered with a white lightsource and colour
Refracting spheres.
Drop by and talk with me if you want to work
On any of these features but need a hint or
two, or if you have other crunchy ideas to
Try.
Have Fun!
Submitting crunchy stuff: Include a rendered
scene with your compressed submitted fle, as well
as a ‘crunchy.txt’ describing what you did!
CSC D18 – Fall 2019
Assignment 1 – Basic Geometry and 2D Light Transport
F. Estrada, Aug. 2019

你可能感兴趣的:(多伦多大学CSC D18Assignment1 课业解析)