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)发展出雏形至今 ...
随机推荐
- 高性能TcpServer(C#) - 3.命令通道(处理:掉包,粘包,垃圾包)
高性能TcpServer(C#) - 1.网络通信协议 高性能TcpServer(C#) - 2.创建高性能Socket服务器SocketAsyncEventArgs的实现(IOCP) 高性能TcpS ...
- minggw 安装
windows上如果没有安装 visual studio, 也就是俗称的vs, 在安装一些带有c或者c++代码的Python模块的时候, 会报错Unable to find vcvarsall.bat ...
- Linux文本文件——管理文本的命令
Linux文本文件——管理文本的命令 摘要:本文主要学习了在Linux中管理文本的命令. cat命令 cat命令用来显示文本文件的内容,也可以把几个文件内容附加到另一个文件中,即连接合并文件,是Con ...
- SQL之CASE WHEN用法详解
原文链接:https://blog.csdn.net/rongtaoup/article/details/82183743 原文链接:https://www.cnblogs.com/zhuyeshen ...
- 4. 移动安全渗透测试-(Android逆向基础)
4.1 smali 基础 1.注释 smali中使用#来代表注释一行例如:# const-string v0, "aaa" #这句不会被执行 2.数据类型 V void,只能用于返 ...
- 电信NBIOT 3 - 数据下行
电信NBIOT 1 - 数据上行(中国电信开发者平台对接流程) 电信NBIOT 2 - 数据上行(中间件获取电信消息通知) 电信NBIOT 3 - 数据下行 电信NBIOT 4 - NB73模块上行测 ...
- windows elasticsearch使用ik分词器插件后启动报错java.security.AccessControlException: access denied ("java.io.FilePermission" "D:...........\plugins\ik-analyzer\config\IKAnalyzer.cfg.xml" "read")
删除es安装文件夹中空格,遂解决......(哭
- leetcode整理(一)
leetcode题目整理,基本上不是最优解 1. 回文数 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 ...
- Lnmp搭建zabbix运维监控系统
使用目的? 在公司项目中需要做一个日志监控,最开始选择的是efk,但是efk的资料相对较少并且之前对这几个产品都没接触过,使用起来难度.于是选择了zabbix作为项目的运维监控系统. zabbix能做 ...
- 8-剑指offer: 替换空格
题目描述 请实现一个函数,将一个字符串中的每个空格替换成"%20".例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 代码: c ...