Assignment 2 Ray Tracing

Similar documents
The feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):

Practical 2: Ray Tracing

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

Ray Tracer Due date: April 27, 2011

Assignment 6: Ray Tracing

Computer Graphics Tick 1

Virtual Reality for Human Computer Interaction

Ray-Tracing. Misha Kazhdan

Photorealism: Ray Tracing

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Raytracing CS148 AS3. Due :59pm PDT

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Lighting and Shading

Topics and things to know about them:

Ray Tracing COMP575/COMP770

COMP371 COMPUTER GRAPHICS

CS 465 Program 5: Ray II

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Ray tracing. Methods of Programming DV2. Introduction to ray tracing and XML. Forward ray tracing. The image plane. Backward ray tracing

Programming projects. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer. Assignment 1: Basic ray tracer

Ray Tracing. Kjetil Babington

CS5620 Intro to Computer Graphics

Lighting. Figure 10.1

Shading I Computer Graphics I, Fall 2008

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Ray Tracer I: Ray Casting Due date: 12:00pm December 3, 2001

Ray Tracing Part 1. CSC418/2504 Introduction to Computer Graphics. TA: Muhammed Anwar & Kevin Gibson

Lecture 18: Primer on Ray Tracing Techniques

Homework #2. Shading, Ray Tracing, and Texture Mapping

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Interactive Real-Time Raycasting

Computer Graphics I. Assignment 3

A Little Background. Motivation. Motivation

CS 184: Assignment 4 Simple Raytracer

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Lecture 15: Shading-I. CITS3003 Graphics & Animation

CS 4620 Program 4: Ray II

CHAPTER 1 Graphics Systems and Models 3

The University of Calgary

Intro to Ray-Tracing & Ray-Surface Acceleration

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Review for Ray-tracing Algorithm and Hardware

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Comp 410/510 Computer Graphics. Spring Shading

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

The exam begins at 2:40pm and ends at 4:00pm. You must turn your exam in when time is announced or risk not having it accepted.

Shading. Brian Curless CSE 557 Autumn 2017

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Illumination Models & Shading

Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

TDA361/DIT220 Computer Graphics, January 15 th 2016

03 RENDERING PART TWO

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

MITOCW MIT6_172_F10_lec18_300k-mp4

Luxo Jr. (Pixar, 1986) Last Time. Real Cameras and Ray Tracing. Standard Rasterization. Lights, Cameras, Surfaces. Now Playing:

lecture 18 - ray tracing - environment mapping - refraction

Shadows. COMP 575/770 Spring 2013

Ray tracing idea. Ray Tracing. Ray tracing algorithm. Plane projection in drawing. CS 465 Lecture 3

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

COMPUTER GRAPHICS AND INTERACTION

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

CS Simple Raytracer for students new to Rendering

Deferred Rendering Due: Wednesday November 15 at 10pm

Introduction to Ray-tracing Objectives

Lecture 11: Ray tracing (cont.)

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Glass Gambit: Chess set and shader presets for DAZ Studio

L15 POV-Ray - Part 1

RAYTRACING. Christopher Peters INTRODUCTION TO COMPUTER GRAPHICS AND INTERACTION. HPCViz, KTH Royal Institute of Technology, Sweden

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

Lecture 11. More Ray Casting/Tracing

Previously... contour or image rendering in 2D

CPSC GLOBAL ILLUMINATION

Photon Mapping. Due: 3/24/05, 11:59 PM

A Quick Introduction to POV-Ray

Local Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Recursion and Data Structures in Computer Graphics. Ray Tracing

Global Illumination CS334. Daniel G. Aliaga Department of Computer Science Purdue University

Shading, Advanced Rendering. Week 7, Wed Feb 28

ECS 175 COMPUTER GRAPHICS. Ken Joy.! Winter 2014

Project 1 Simple Ray Tracer

CS 130 Final. Fall 2015

CSE 167: Introduction to Computer Graphics Lecture #6: Lights. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

COS 116 The Computational Universe Laboratory 10: Computer Graphics

Simple Lighting/Illumination Models

Lecture 8 Ray tracing Part 1: Basic concept Yong-Jin Liu.

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

Graphics for VEs. Ruth Aylett

Introduction to Visualization and Computer Graphics

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

A simple OpenGL animation Due: Wednesday, January 27 at 4pm

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

DH2323 DGI13. Lab 2 Raytracing

Shading. Reading. Pinhole camera. Basic 3D graphics. Brian Curless CSE 557 Fall Required: Shirley, Chapter 10

Transcription:

Assignment 2 Ray Tracing Overview The concept of ray tracing: a technique for generating an image by tracing the path of light through pixels in an image plane and simulating the effects of its encounters with virtual objects. The technique is capable of producing a very high degree of visual realism, usually higher than that of typical scan line rendering methods, but at a greater computational cost. The objective of this exercise is to implement a ray casting/tracing engine. A ray tracer shoots rays from the observer s eye through a screen and into a scene of objects. It calculates the ray s intersection with objects, finds the nearest intersection and calculates the color of the surface 1

according to its material and lighting conditions. (This is the way you should think about it this will help your implementation). 2

Requirements Read this entire explanation before starting. Understand the slides taught in class especially. The feature set you are required to implement in your ray tracer is as follows: Background o Black Display geometric primitives in space: o Spheres o Planes Basic lighting o Directional lights o Spot lights o Ambient light o Simple materials (ambient, diffuse, specular...) Basic hard shadows One Reflection (10 Points bonus) Scene Definition The 3D scene your ray tracer which will be rendering will be defined in a scene definition text file. The scene definition contains all of the parameters required to render the scene and the objects in it. The specific language used in the definition file is defined later. 3

Geometry Geometric primitives Sphere A sphere is defined by a center point and scalar radius. The normal of each point on the sphere s surface is easily computed as the normalized subtraction of the point and the center. Plane Plane is always a rectangle. A plane is defined by a point represents the center of the plane, a normal vector to the plane, width and length. Every plane has white 32X32 checker board pattern. You can Assume that the normal of a plane has one zero coordinate and one edge of the plane is parallel to one of the axis. For example if the normal is (1,1,0) then one edge direction is (0,0,1) and second edge direction is (1,-1,0). Spheres and planes can intersect each other. Background The background of the rendered scene is black. Camera The camera is a simple pinhole camera as described in the lecture slides and will be located at (0,0,0). Camera direction will be toward (image plane center). Lighting Basic lights and shadows For basic lighting you need to implement: 4

1. Ambient lighting a color that reflects from all surfaces with equal intensity. 2. Directional A light source like the sun, which lies at infinity and has just a direction. 3. Spot light A point light source that illuminates in a direction given by a vector. This light source has a cutoff angle as describe in the following image. Every light source has its own intensity (color) and there can be multiple light sources in a scene. Shadows appear where objects obscure a light source. In the equation they are expressed in the term. To know if a point in space (usually on a surface) lies in a shadow of a light source, you need to shoot a ray from in the direction of the light and check if it hits something. If it does, make sure that it really hits it before reaching the light source and that the object hit is not actually a close intersection with the object the ray emanated from. Materials You need to implement the lighting formula (Phong) from the lecture slides. The material of a surface should be flat with ambient, diffuse, specular reflections, and a shininess parameter (the power of ). The first 4 parameters are RGB colors. Shadow You can choose to add shadow effect to your scene using parameter in Phong model (see lecture slides). Shadow appears when some object located between the light source and another object which can be observed by the viewer. In that case you should ignore the covered light source part in Phong model. Some common mistakes may cause spurious shadows to appear. Make sure you understand the vector math involved and all the edge-cases. Reflection (10 points bonus) You can choose implement planes which is defined in the objects file to be a mirror. Each ray hit a mirror plane breaks symmetrically to the normal (include light rays). The color of the pixel in a mirror plane is calculating according to the breaking ray. Don't forget to consider the light sources rays which break by the mirror plane. If you choose to implement this task ignore mirror objects material parameters: ambient, diffuse, specular reflections. Mirror will be uniform (without squares). Mirror plane will be signed by M at the end of the parameters list. 5

Fisheye lens (10 points bonus) Create a fisheye effect. You may make it by calculating the ray reflectance from fisheye lens which is located between the screen and the scene or between the eye and the screen. Further reading: http://en.wikipedia.org/wiki/fisheye_lens#mapping_function If you implement this bonus run your program with argument "fish" to see the scene through fish eye lens (when running without parameters the program show the original scene). Up to 10 bonus points will be given for extremely interesting scene you build. Submit init.txt file and output image of your ray tracer. Every additional advanced feature (as acceleration, transparency, environmental light) will give you extra points. 6

Input You will get one text file named init.txt. The first line in the file will start with the word "scene" following by (screen center coordinates x, y, z), up vector (x, y, z), w width of the scene, when ( ) is Image resolution (you can assume that ) and Ambient lighting (R, G, B coordinate). 12 parameters total which are separated by commas. Image plane normal is the vector From the second row we will describe the object in the scene: Light will describe by "light" keyword following by light direction (x, y, z), light intensity (R, G, B) and if it is a spotlight light position (x, y, z) and light cutoff angle. 6 or 10 parameters total. Sphere will describe by "spher" keyword following by the sphere center coordinate (x,y,z), radius, material parameters each one has 3 components (R, G, B) and shininess parameter. 14 parameters total. Plane will describe by "plane" keyword following by the a normal to the plane coordinates (x,y,z), center of plane point coordinates (x,y,z),width and length, material parameters each one has 3 components (R, G, B) and shininess parameter. 18 parameters total. If you choose to implement reflection bonus, you generate each object that signed with "M" at the end of the line as a mirror. Input example: scene 0,0,-2,0,1,0,2,512,512,0.5,0.1,0.8 light 1,1,1,0.3,0.2,0.6 light 1,-1,1,0.9,0.1,0.6,0,4,-5.5,30 spher 0,0,-5,1.5,0.3,0.3,0.3,0.4,0.4,0,0.1,0.7,0,5 plane 0,1,0,0,-2,0,100,100, 0.3,0,0.3,0.4,0,0,0.1,0.7,0,20 M Notes Recommended Milestones Design Before you start coding! You should think carefully about the structure and design of your system. Take the time to define interfaces, classes and interactions between objects. Implementing a ray tracer poses an array of opportunities for creating good OOP design Make sure you take advantage of them. Write incrementally. Start from a small scene with one or two objects. 7

Validation We will provide you with sample scenes for validation and the way they are supposed to render in your ray tracer. Your implementation may vary from the supplied image in little details but in general the scene should look the same. Some general hints: A color can be seen as a vector that points from black (0,0,0) to a point in the RGB space. Use the Vector3f class to handle vectors and RGB. Before plotting a pixel, make sure that its color does not exceed the range of 0-1 for every color channel. Right vector of the screen will be orthogonal to up vector and toward vector (see slide 42 of PS 3. Use 'fscanf' and fseek function to read parameter from file. Example: float var; FILE *f; //file discriptor Fseek(f,5,SEEK_CUR); //skip 5 character from the current position in the file fscanf(f,"%f,",&var); //put a float number into var and return 1 when succeed Submission: Submission is in pairs. Everything should be submitted inside a single zip file named <ID1> _<ID2>.zip The zip file should include all of your.h files and.cpp files or your project if you use VS. 8

Appendix A Step by Step Guidance Following are some practical suggestions that could make the exercise easier for you. There are many other ways to approach it as well, and you don't necessarily have to follow these directions. 1. Make sure you read the scene definition file correctly. 2. Define you C++ object for each light source, sphere and a plane. 3. Try to render small scenes with one light and one or two objects. 4. Add lights and compare your results which friends. 5. Implement lighting types. 6. Add support for shadows and reflection by recursively shooting additional rays. 7. Go through the exercise definition and make sure you haven't forgotten anything. 8. Debugging: An easy way to start debugging is to find a pixel where you know something is wrong and try to debug the calculation of that specific pixel. Say you found there is a problem at (344, 205), You can start by writing something like this: if (x == 344 && y == 205) printf("yo!"); // set breakpoint here. You can also print to a log file. Helpful links: http://en.wikipedia.org/wiki/ray_tracing_(graphics) http://www.cl.cam.ac.uk/teaching/1999/agraphhci/smag/node2.html http://www.siggraph.org/education/materials/hypergraph/raytrace/rtrace0.htm 9

Good Luck! 10