• Keine Ergebnisse gefunden

Exercise1(RaytracingBasics, 10Credits ) DueDate20.05.2021 AssignmentonAdvancedComputerGraphics-Sheet1

N/A
N/A
Protected

Academic year: 2022

Aktie "Exercise1(RaytracingBasics, 10Credits ) DueDate20.05.2021 AssignmentonAdvancedComputerGraphics-Sheet1"

Copied!
3
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Prof. G. Zachmann Toni Tan

University of Bremen School of Computer Science

CGVR Group May 8, 2021

Summer Semester 2021

Assignment on Advanced Computer Graphics - Sheet 1

Due Date 20.05.2021

Exercise 1 (Raytracing Basics, 10 Credits )

In this exercise, you should complete our raytracing framework. To do that, you have to implement some functions in this framework.

First, please take some time to become familiar with the structure of the framework. The hints in the tutorial class, but also the comments in the code should help you.

Basically, the framework consists of four essential components:

• GUI:The GUI is based on Qt. In order to compile the framework you will need a version of the Qt- framework to be installed on your PC, i.e., Qt 5.9 (https://download.qt.io/archive/qt/5.9/5.9.0/).

In the window on the right side, the GUI shows the resulting image that is generated via raytrac- ing. The window on the left side shows an OpenGL rendering of the scene. You can use it for debugging and for a comparison between the global illumination generated by raytracing and the local OpenGL lighting.

However, OpenGL and Qt are not necessary for the understanding of the raytracer; therefore, you should simply ignore this part of the code.

• XML Parser: The program reads 3D scenes in a simple XML format. We use a freely available XML library for parsing. You will find a pre-compiled version for windows in the zip-file. If you use Linux or Apple, you have to compile the library from the sources. You can find aMakefile in thexmlParsersub-folder.

The XML file format should be almost self-explanatory. However, you don’t have to create scenes by your own, you can simply use the pre-defined example scenes (objects.xml, glass- spheres.xml,metal-spheres.xmlorsteinbach.xml).

• Mathematical Helper Classes: You will find some simple template-classes to simplify mathematical computations:

– VectorT: template for n-dimensional vector computations – MatrixT: template for quadratic n×n matrices

– Matrix33T: specialisation of MatrixTfor 3×3 matrices – ColorT: template for RGB color computations

• Raytracer: The basic components of the raytracer are concentrated in theRaytracer class:

– Raytracer::render(): generates a ray for each pixel.

– Raytracer::traceRay(): traces the ray through the scene.

– Raytracer::shade(): This function should compute the local (Phong) shading for a point in the scene. Moreover, it should test whether or not the point is in the shadow.

ThePinholeCameraclass implements a simple pinhole camera. The most important function is PinholeCamera::generateRay(). It generates a ray from the eye point through the pixel(x,y) in the image plane.

1

(2)

Figure 1: Raytracing

TheRayclass represents such a ray. Basically, rays are defined by their starting point and direction.

Moreover, the class includes functions to compute the reflected and refracted rays.

All classes for entities in the scene (geometry, materials, light sources) are derived from their respective virtual base classes:

– Surface: virtual base class for geometric objects. All derived classes implement their own intersect() function that computes the intersection between the objects and a ray. The derived classesPlane,SphereandCheckerboardare fully implemented.

– Shader: Virtual base class for materials. The derived classPhongShaderis fully implemented.

The functionPhongShader::shade()computes the local Phong model.

– Light: Virtual base class for light sources. The derived classes PointLight andDirection- alLightare fully implemented.

Your tasks:

a) Implement the functionRaytracer::shade() in the file Raytracer.cpp. In this function, you should test whether or not the pixel is in the shadow. If the pixel is not in the shadow, you have to set its color to the appropriate (Phong) lighting.

If you implement this function correctly, the resulting image should look almost like the OpenGL rendering on the left side.

b) In order to realize a real raytracer, we have to trace also reflected rays. To do that, you should implement the functionRay::reflectedRay()inRay.cpp.

Moreover, you have to use this function in Raytracer::traceRay() to recursively compute the reflected color (that has to be added to the current color value).

c) Finally, we also want to include refractions into our raytracer. Therefore, you have to implement the functionRay::refractedRay()inRay.cpp. It should, depending on the refraction parameter of the material, return the refracted ray.

As in the previous part, you also have to trace the refracted ray recursively through the scene in Raytracer::traceRay() to compute the appropriate amount of color.

2

(3)

Exercise 2 (Meta-Ball Raytracing, 10 Credits )

In this assignment you are going to implement the intersection test for Metaballs in our raytracer. To do that, extend the functionMetaball::intersect() in Metaball.cpp with the intersection test.

As a potential-function you should use the exponential function shown in the lecture:

p(r) =e−br2

For the blending use the sum defined on slide in lecture:

F(x) =

n

X

i=1

ai p(kx−xik)

The following equation therefore defines the isosurface:

K={x|F(x)−τ= 0}

The assignment is comprised from the following sub-tasks:

a) Implement the potential function and sum thereof inMetaball::F(). All the points comprising the metaball are stored inMetaball::m_balls. They contain their bandwidthbi, weightai and positionxi. The isovalueτ is stored inMetaball::m_isovalue.

b) Implement the intersection test with the metaball inMetaball::intersect()and compute the normal at the intersection point with the method from slide in the lecture. This can be done with brute-force sampling along the ray.

Hints:

• For guidance how to implement an intersection test have a look intoSphere.cpp.

• Start with the scene inmeta-balls-simple.xml. It only contains a single metaball which allows you to use the calculation for the normal of a simple sphere as a starting point.

• Draw a scene for metaball-ray test in 2D to identify all the cases for the middle point in c).

Figure 2: This is how the metaball scenes should look like. From left to right: meta-balls- simple.xml,meta-balls.xmlandmeta-balls-complex.xml.

3

Abbildung

Figure 1: Raytracing
Figure 2: This is how the metaball scenes should look like. From left to right: meta-balls- meta-balls-simple.xml, meta-balls.xml and meta-balls-complex.xml.

Referenzen

ÄHNLICHE DOKUMENTE

The aim of the BONN-IIASA Research Project is to analyse and forecast economic growth and economic structural change of Lhe most important countries (or groups of countries) in the

 Interests, short for interest packet, are also called requests and data packets are also referred to as responses, replies, result packets or content objects.. Result packets

These issues are subject of the class Business Engineering, while the subsequent Enterprise Modeling class focusses specific modeling languages as well as layer-across topics

This project gets to the heart of poetic interpretation and the creative process by giving students the first-hand experience of writing an original, literary translation of a

In this position paper, we argue that Virtual Reality is a medium that has a potential to be used as a medium of choice for remote classroom access.. We also presented a proof

All p-values were first corrected using the BH method (i.e., corrections accounted for comparisons for the 3 groups of children) then corrected again using the Bonferroni method

When the operation is finished the robot puts in support (AS) the welding device and the piece in the matricial storehouse with four locations in order 1, 2, 3, 4.). There are

A final view shows the composed model like the photos on the packages of real 3D puz- zles, which help users find the right place for the puz- zle pieces.. Furthermore, an exploded