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)发展出雏形至今 ...
随机推荐
- Asp.Net Mvc日志处理
/// <summary> /// 日志处理帮助类 /// </summary> public class LogHelper { private static Queue&l ...
- python3.0安装django2.0、xadmin
1.操作环境 Windows10.python3.8 2.安装django2.0 pip install django==2.0 x 1 pip install django==2.0 3.安装相 ...
- Java自学-集合框架 遍历
遍历ArrayList的三种方法 步骤 1 : 用for循环遍历 通过前面的学习,知道了可以用size()和get()分别得到大小,和获取指定位置的元素,结合for循环就可以遍历出ArrayList的 ...
- Winform中怎样跨窗体获取另一窗体的控件对象
场景 Winform中实现跨窗体获取ZedGraph的ZedGraphControl控件对象: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/de ...
- MongoDB常用数据库命令第三集
show dbs 查看已经存在的数据库 use 数据库名 切换到指定的数据库(无论数据库是否存在 均可切换成功) db 查看当前数据库 db.getCollectionNames() 查看当前数据库下 ...
- system execl
1. system(); int system(const char *command); 在Windows下,用来调用常用的Dos命令 在Linux下,system()会调用fork()产生子进程, ...
- Xcode修改项目名称
http://blog.sina.com.cn/s/blog_a42013280101blxo.html
- shell 多行重定向方法(多重嵌套)
这里讲的是多重嵌套.没用过 EOF的朋友请参考其他基础贴 在自动化运维中,常常需要shell脚本.在自动化创建脚本时,会遇到脚本内容里有用EOF重定向到配置文件的代码. 这样就不能用EOF来创建脚本了 ...
- 如何解决问题:程序无法正常启动(0xc0000022)
如何解决问题:程序无法正常启动(0xc0000022) 下文是由NeoSmart技术,通过全球网络上的工程师开发者和技术人员一起收集起来的信息,进行汇总并编辑而成的. 错误现象 该错误一般会通过警告, ...
- 关于使用repo时repo init和repo sync失败的一个解决方案
由于我国的网络的原因,在访问谷歌等一些国外网络资源时经常会遇到被拦截的情况,导致repo等一些代码管理工具拉取代码网络受限受阻,下面提供一个可以参考的简单解决方案. 1.repo init时的遇到fa ...