Computing Science CMPT 361 Fall 2019
Assignment #3
Due date: November 27th at 11:59 pm.
Ray Tracing
You will write a basic ray tracer. The entire assignment can be completed in Euclidean
space; there is no need for homogeneous coordinates. There are 25 points available.
(a) [1 point] Window setup
Use OpenGL to set up a window with a 400 x 400 pixel drawing window. Use a symbolic
constant rather than 400 so that you can change resolution by changing the constant.
(b) [2 points] Viewing
The eyepoint is the origin, and the view is down the negative z-axis with the y-axis pointing
up. The coordinate system is right-handed.
Have a constant or a procedure call that defines the Field of View in the Y-direction (fovy), in
degrees. The field of view is the angle between the top of the view volume and the bottom
of the view volume. It is illustrated in the following image, but note that we will have no
near or far clipping planes. Note that since we have a square window (400 x 400) the field of
view in the x-direction (fovx) is equal to fovy.
(image from learnwebgl.brown37.net)
Assume that the virtual screen is on the plane at z = -1.
Design an object called Ray to hold a ray, which consists of a start point p0 and a vector v
and represents the ray p(t) = p0 + tv for t ≥ 0.
Computing Science CMPT 361 Fall 2019
Instructor: Tom Shermer Simon Fraser University
In a routine named render, write a loop nest that will generate the initial rays for each of the
代写CMPT 361作业、代做system留学生作业
pixels. These initial rays start at the origin and have a vector v = (vx, vy, -1). Your job here is
to figure out the correct vx’s and vy’s given fovy. At this point, the body of the loop nest
should just create a ray object.
(c) [2 points] Primitives
You will have two types of objects that you will be making images of: spheres and planes.
Define an object for each of these primitives, e.g. a Sphere and a Plane. Design ways of
creating these objects so that they are put on a globally-accessible list (array, vector, etc.) of
objects. You may either keep one such list or two (which would be one for Spheres and one
for Planes).
When creating an object, specify its geometry and its material/surface properties. For
example, you might have:
new Sphere(1.0, 2.0, -3.0, 1.25, 0.1, 0.8, 0.8, 0.9, 0.9, 0.9, 32, 0.5, 0.0, 1.5)
which is quite hard to figure out. It’s better if you have objects that group the parameters,
such as a Point and a Color:
new Sphere(Point(1.0, 2.0, -3.0), 1.25, Color(0.1, 0.8, 0.8),
Color(0.9, 0.9, 0.9), 32,
0.5, 0.0, 1.5)
This is still a long parameter list, but it is meant to represent:
Center of sphere: (1.0, 2.0, -3.0)
radius of sphere: 1.25
kd: Color(0.1, 0.8, 0.8)
ks: Color(0.9, 0.9, 0.9)
q: 32
kr: 0.5
kt: 0.0 (no refraction)
index of refraction: 1.5
One can perhaps simplify the parameters farther by defining an object Material consisting of
all the material properties.
Material* aqua = new Material(Color(0.1, 0.8,0.8), Color(0.9, 0.9, 0.9), 32, 0.5, 0.0, 1.5)

new Sphere(Point(1.0, 2.0, -3.0), 1.25, aqua);
Computing Science CMPT 361 Fall 2019
Instructor: Tom Shermer Simon Fraser University
The object Plane should be similar, with the first four parameters denoting A, B, C, and D of
the plane equation Ax + By + Cz + D = 0:
new Plane(0.0, 1.0, 0.0, 1.0 , aqua);
This is the plane y = -1 given the ‘aqua’ material properties.
(d) [1 point] Lights
The lights you will be using are simple local point light sources with no falloff.
Define an object Light and a way of creating them so that they are put on a globallyaccessible
list (array, vector, etc.) of lights. Each light should have a location and a color
intensity:
new Light(Point(-100.0, -100.0, -20.0), Color(2.5, 2.5, 2.0))
Note that the “Color” here is color intensity and can contain values greater than 1.0; normal
colors (kd and ks) have channels that range between 0.0 and 1.0.
(e) [1 point] Scene setup and command-line argument
Your program must be capable of displaying one of four different scenes depending on a
command-line argument (which will be a number, 1 to 4). Each scene should set up lights,
primitives, camera (fovy), and also set a depth limit for the ray tree, an ambient light
intensity, and a background light intensity. You should have one subroutine for each scene
to display. Here’s roughly what a scene subroutine should look like, if you use the Material
object:
void scene2() {
Material* aqua = new Material( … );
Material* greenGlass = new Material(…);
Material* chrome = new Material(…);
fovy(40);
rayTreeDepth(4);
ambient(new Color(…);
background(new Color(…);
new Light(…);
new Light(…);
new Sphere(…);
new Sphere(…);
new Plane(…);
render();
}
Don’t slavishly copy that; you may have other syntax for creating your objects, or differentlynamed
subroutines, etc.
Computing Science CMPT 361 Fall 2019
Instructor: Tom Shermer Simon Fraser University
(f) [3 points] Ray-primitive intersections
As member functions of the primitive objects (Plane and Sphere), implement a routine which
will intersect a ray with the object. It should take the ray as a parameter and return the
smallest positive t value at which the ray intersects the primitive. If there is no such t value,
it returns a negative number. (This is an overloading of the return value but in this case
speed is important so we’ll forgive ourselves.) These computations have been covered in
lecture.
(g) [7 points] Ray tracing
Implement a function trace that takes a ray and a depth of tracing as parameters, and
returns a color intensity.
If the depth of tracing is 0, then trace should return the background color intensity.
If the depth of tracing is greater than 0, then trace should intersect the ray with all primitives
in the scene and determine which one has the smallest positive t where it intersects. This is
the object the ray hits. If the ray hits no object, then trace should return the background
color intensity.
If the ray hits an object, then let p(t) be the point where it hits. At this point, apply the
lighting formula

Computing Science CMPT 361的更多相关文章

  1. Introduction to Parallel Computing

    Copied From:https://computing.llnl.gov/tutorials/parallel_comp/ Author: Blaise Barney, Lawrence Live ...

  2. 软件工程卷1 抽象与建模 (Dines Bjorner 著)

    I 开篇 1. 绪论 II 离散数学 2. 数 (已看) 3. 集合 4. 笛卡尔 5. 类型 6. 函数 7. λ演算 8. 代数 9. 数理逻辑 III 简单RSL 10. RSL中的原子类型和值 ...

  3. 中国计算机学会CCF推荐国际学术会议

    中国计算机学会推荐国际学术会议 (计算机系统与高性能计算) 一.A类 序号 会议简称 会议全称 出版社 网址 1 ASPLOS Architectural Support for Programmin ...

  4. [计算机、网络相关历史]unix简史

    本文2001年由台湾“网络农夫”所写,其人生平不祥,此文受鸟哥大力推崇,两人应该相识.文章写得很不错,应该是查了很多资料整理而成的,美中不足的是好多语句不通顺,国考语文绝对不及格,哈哈. 0.我的准备 ...

  5. CCF推荐国际学术会议

    类别如下计算机系统与高性能计算,计算机网络,网络与信息安全,软件工程,系统软件与程序设计语言,数据库.数据挖掘与内容检索,计算机科学理论,计算机图形学与多媒体,人工智能与模式识别,人机交互与普适计算, ...

  6. An Implementation of Double-Array Trie

    Contents What is Trie? What Does It Take to Implement a Trie? Tripple-Array Trie Double-Array Trie S ...

  7. (转) Reinforcement Learning for Profit

    Reinforcement Learning for Profit July 17, 2016 Is RL being used in revenue generating systems today ...

  8. SCI&EI 英文PAPER投稿经验【转】

    英文投稿的一点经验[转载] From: http://chl033.woku.com/article/2893317.html 1. 首先一定要注意杂志的发表范围, 超出范围的千万别投,要不就是浪费时 ...

  9. UNIX发展史(BSD,GNU,linux)

    先前的一個理想 UNIX 系统自 1969 年 Ken Thompson 与 Dennis Ritchie 在美国贝尔电话实验室(Bell Telephone Laboratories)发展出雏形至今 ...

随机推荐

  1. EF操作与Linq写法记录

    项目总结:EF操作与Linq写法记录 1.EF引入 新建一个MVC项目之后,要引用EF框架,可以按照以下步骤进行: 1),在Models中添加项目 2),选择Entity Data Model,并重新 ...

  2. win10 net framework 3.5提示错误代码0x800f081f

    重装了win10系统,碰到以下几个问题 1.安装本地iis -启动或关闭windonws功能- 安装net framework 3.5的时候 提示错误代码0x800f081f 2.安装SqlServe ...

  3. asp.net实现页面跳转后不可以返回

    window.history.go(0); Response.Write("<script> window.history.go(0);alert('恭喜user注册成功!!!\ ...

  4. matlab 基础语法

    计算次幂 Trial>> 3 ^ 2 % 3 raised to the power of 2 ans = 9 MATLAB 计算正弦值 Trial>> sin(pi /2) ...

  5. CTF必备技能丨Linux Pwn入门教程——栈溢出基础

    这是一套Linux Pwn入门教程系列,作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的一些题目和文章整理出一份相对完整的Linux Pwn教程. 课程回顾>>Linux ...

  6. 在使用 Fortify进行源码扫描时需要做对项目需要做什么?

    1.一般我们的项目都是svn 或git 进行管理的,为了扫出异常的问题 做好把   “” .svn    “”  文件删除 2.把我们的项目需要的jar 文件放到一个文件夹内同项目一起进行扫描.这样为 ...

  7. LeetCode——Duplicate Emails(使用group by以及having解决分组统计结果)

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  8. JS 判断设备来源

    1.js代码判断当前设备: function deviceType(){ var ua = navigator.userAgent; var agent = ["Android", ...

  9. pandas - groupby 深入及数据清洗案例

    import pandas as pd import numpy as np 分割-apply-聚合 大数据的MapReduce The most general-purpose GroupBy me ...

  10. MyCat教程六:全局序列号-全局主键的自增长

      前面我们介绍了MyCat的分库分表操作,那么同一张表中的数据会被保存在不同的数据库中,那么这就涉及到了主键维护的问题,此时肯定不能使用单个数据库中id自增的方式来处理了,这时我们就可以通过MyCa ...