联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2020-10-16 10:52

Coursework I:

Ray-tracing

COMP0027 Team

We have shown you the framework for solving the coursework at cg.cs.ucl.ac.uk/. You should start by

extending the example Coursework1. The programming language is WebGL (https://www.khronos.org/

registry/webgl/specs/latest/1.0/) and the OpenGL ES Shading Language (GLSL) www.khronos.org/

files/opengles_shading_language.pdf. Do not write any answers in any other programming language, in

paper, or pseudo code. Consider downloading the coursework in case your connection becomes unavailable.

Remember to save your solution often enough to a .uclcg file. In the end, hand in that file via Moodle.

The total points for this exercise is 100.

Above, the scene from this coursework, rendered with the simple initial ray-tracer you are asked to extend.

1

1 New primitives: Plane and cylinder (30 points)

We have added definitions of planes (a normal n and a distance r to the origin) and cylinders (an orientation

o and a radius r) to the scene. You are asked to add code to intersect them (10 points) and explain how

they work (10 points). Pay attention on how Sphere is intersected. Stick to the same function signature for

Plane and Cylinder that contain HitInfo, including normals and material (10 points).

2 Materials (6 points)

Make the scene show different materials and explain why those parameters are adequate in some table: paper

2

(1 points) metallic mirror ground plane (2 points) a glass sphere (2 points) and a yellow plastic sphere (1

points). It is important that settings are chosen such that the distinct visual features become visible in the

scene.

3 Casting shadows (20 points)

We have discussed how shadows, reflections and refractions work and how recursions can be unrolled into

loops under some conditions. The framework contains the skeleton of such a traversal, but without the code

for shadows, reflection and refraction.

First, add shadow tests to the shading (10 points), with comments (5 points) and explain what typical error

can be made here (5 points).

3

4 Adding reflections and refractions (34 points)

To add these, first extend the Material class to hold all information you need for computing reflection and

refraction (10 points).

Next, the code already contains the loop to perform the ray traversal iteratively, what remains to be added

is code for computing the reflection direction (12 points) and refraction direction. Refraction direction is

subdivided into two tasks: 1) the main code flow for bouncing rays and including the refractive constant (10

points) and 2) using the enteringPrimitive flag properly for keeping track of IORs (2 points) for a total of

(12 points).

Note how objects far away enough behind the glass sphere appear mirrored. Although not shown here, objects

that are behind and near the glass sphere would just appear distorted.

4

5 Fresnel (10 points)

The image with reflection and refraction looks okay, but the glass likely does not look like glass as it shows

reflection and refraction at equal strength all over the sphere. Such an image is shown above. Here, and

in reality, reflection and refraction strength vary so that wreflect and wrefract sums to one or less, so here we

simply assume wreflect = 1 ? wrefract. This weighting depends on the view direction and the normal at the hit

point. The reflection is typically strong on grazing angles close to the edge of the sphere, while the refraction

is strongest in the centre. Do some research to find out how those weights could be computed and tell us

what you used (5 points) and implement it (5 points) in the function fresnel. A simple implementation

such as using a single dot product or the approximation by Schlick could be a good starting point.

5


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp