Computing Science CMPT 361
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的更多相关文章
- Introduction to Parallel Computing
Copied From:https://computing.llnl.gov/tutorials/parallel_comp/ Author: Blaise Barney, Lawrence Live ...
- 软件工程卷1 抽象与建模 (Dines Bjorner 著)
I 开篇 1. 绪论 II 离散数学 2. 数 (已看) 3. 集合 4. 笛卡尔 5. 类型 6. 函数 7. λ演算 8. 代数 9. 数理逻辑 III 简单RSL 10. RSL中的原子类型和值 ...
- 中国计算机学会CCF推荐国际学术会议
中国计算机学会推荐国际学术会议 (计算机系统与高性能计算) 一.A类 序号 会议简称 会议全称 出版社 网址 1 ASPLOS Architectural Support for Programmin ...
- [计算机、网络相关历史]unix简史
本文2001年由台湾“网络农夫”所写,其人生平不祥,此文受鸟哥大力推崇,两人应该相识.文章写得很不错,应该是查了很多资料整理而成的,美中不足的是好多语句不通顺,国考语文绝对不及格,哈哈. 0.我的准备 ...
- CCF推荐国际学术会议
类别如下计算机系统与高性能计算,计算机网络,网络与信息安全,软件工程,系统软件与程序设计语言,数据库.数据挖掘与内容检索,计算机科学理论,计算机图形学与多媒体,人工智能与模式识别,人机交互与普适计算, ...
- 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 ...
- (转) Reinforcement Learning for Profit
Reinforcement Learning for Profit July 17, 2016 Is RL being used in revenue generating systems today ...
- SCI&EI 英文PAPER投稿经验【转】
英文投稿的一点经验[转载] From: http://chl033.woku.com/article/2893317.html 1. 首先一定要注意杂志的发表范围, 超出范围的千万别投,要不就是浪费时 ...
- UNIX发展史(BSD,GNU,linux)
先前的一個理想 UNIX 系统自 1969 年 Ken Thompson 与 Dennis Ritchie 在美国贝尔电话实验室(Bell Telephone Laboratories)发展出雏形至今 ...
随机推荐
- laravel npm run dev 错误 npm run dev error [npm ERR! code ELIFECYCLE]
出现此问题是node_modules出现错误,需要执行: 1 rm -rf node_modules 2 rm package-lock.json 3 npm cache clear --force ...
- Java生鲜电商平台-一次代码重构的实战案例
Java生鲜电商平台-一次代码重构的实战案例 说明,Java开源生鲜电商平台-一次代码重构的实战案例,根据实际的例子,分析出重构与抽象,使代码更加的健壮与高效. 1.业务说明 系统原先已有登录功能,我 ...
- tf.argmax()解析
tf.argmax(input,axis)根据axis取值的不同返回每行或者每列最大值的索引. 代码如下: import tensorflow as tfimport numpy as npsess= ...
- css中的行内元素和块级元素总结
块级元素 <address>, <button>, <caption>, <dd>, <del>, <div>, & ...
- 在 React 项目中引入 GG-Editor 编辑可视化流程
蚂蚁金服数据可视化团队曾经开源了一款G6-Editor,但后来停止了对外支持,学习成本太高 好在后来他们团队的大牛高力结合 React + G6 开源了一个 GG-Editor(其实就是G6-Edit ...
- ANDROID培训准备资料之四大组件的简单介绍
Android四大组件是一个android app 最基本的组成部分,这篇博客主要给大家简单的介绍一下四种组件 (1)Activities (2)Services (3)BroadcastReceiv ...
- SQL的概念与发展 - 极客时间学习笔记
了解SQL SQL的两个重要标准是SQL92和SQL99. SQL语言的划分 DDL,也叫Data Definition Language,也就是数据定义语言,用来定义数据库对象,包括数据库.数据表和 ...
- Truck History POJ - 1789
题目链接:https://vjudge.net/problem/POJ-1789 思路: 题目意思就是说,给定一些长度为7的字符串,可以把字符串抽象为一个点, 每个点之间的距离就是他们本身字符串与其他 ...
- Rust中的闭包
这个功能有点高级, 暂时理解不完全, 先把代码练正确吧. use std::thread; use std::time::Duration; struct Cacher<T> where ...
- 10wx.showToast消息提示框 wx.showModal模态对话框
1==>wx.showToast 弹出层 在界面交互中 显示消息提示框 它是一个消失提示框 提示用户成功 或者失败等消息 <button size='mini' bindtap='hanl ...