SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
Middle East Technical University                   Department of Computer Engineering



                                    CENG 477
                     Introduction to Computer Graphics
                                        Fall ’2011-2012
                            Assignment 1 - Ray Tracer

                          Due date: 13 November 2011, Friday, 23:55


1     Objective
You will implement a ray tracer. In this homework, you will dig into the details of ray tracing.
When you see the light at the end of the tunnel, we promise you’ll be very satisfied with the
result!


2     Specifications
    • You will read a scene file, for example ”scene.txt”. This file includes all the basic
      information you need when rendering a scene. Details of this file is included in the next
      chapter. The scene file will have the extension ”.txt”.

    • The scene file will exist in the workspace, and we will provide its name as the only
      command line argument to your program.

    • You will render the given scene using perspective projection.

    • The time limit is 15 minutes on ineks. If you exceed this time, your program will be
      terminated.

    • All coordinates provided in the scene file are world coordinates. Which means, they are
      only relative to the origin, not to each other.

    • All of the lights provided in the scene file are point light sources, equally shining in all
      directions.
      NOTE: Intensity values of the light need not be between 0-255. They simply define a
      light source’s power, or the amount of light it delivers. When calculating the final color
      of a pixel, you need to map values higher than 255 to maximum pixel intensity 255, for
      each band.

    • Your ray tracing algorithm will implement ambient shading, diffuse shading, specular
      shading, shadows and object reflectance properties.

    • You will save the rendered image to ”$SCENE FILE NAME$.ppm” in the workspace.
      For example, if you are asked to render ”scene.txt”, the output image should be ”scene.ppm”.
      ”.ppm” file format is very easy to write. You may use the sample code we provide for
      writing to a ”.ppm” file. You may find detailed information about the format here.
3     Scene File
The scene file includes every detail you will use when drawing a scene. The scene file format
is given as follows:

    ImageWidth ImageHeight

    Tmin

    Ray Reflect Count

    #Camera
    posx posy posz gazex gazey gazez uprx upy upz left right bottom top distance

    #Material MaterialIndex
    ambr ambg ambb difr difg difb sper speg speb specExpP refr refg refb

    #Triangle
    pos1x pos1y pos1z pos2x pos2y pos2z pos3x pos3y pos3z MaterialIndex

    #Sphere
    posx posy posz Radius MaterialIndex

    #Light
    posx posy posz Ir Ig Ib

    #Ambient
    Ir Ig Ib

    #Background
    Ir Ig Ib



3.1    Explanation of Scene File
The first three lines of a scene file are fixed. The rest may be of any order. There will be only
one camera entry and one ambient entry in the file.

    • ImageWidth ImageHeight

      // The width and height of the image to be rendered. Both Integer.


    • Tmin

      //   When sending a reflecting ray from an object, you should first normalize the ray.
      //   When checking for an intersection with other objects, you should take Tmin
      //   as minimum t parameter for the ray. Intersections with smaller t (such as the
      //   object itself) should not be taken into account.
      //   IMPORTANT: The frustum’s far edge is not defined. There is no limit on the
      //   maximum distance of intersection. You should check ray-object intersection with
      //   each object. If the ray does not intersect with any object in the frustum, then
      //   you assign the pixel background color.
• Ray Reflect Count

  // A ray can bounce off this many times. Integer.


• #Camera
  posx posy posz gazex gazey gazez uprx upy upz left right bottom top distance

  // You will send rays from the camera that is put into scene with the given parameters.
  // position parameters define the position of the camera. All Float.
  // gaze parameters define your viewing direction as a vector. All Float.
  // up parameters define the up vector. All Float.
  // left, right, bottom, up parameters together define the size of viewport. All Float.
  // distance is the distance of viewport from the camera. When sending the ray for
  // the first time, you should check if an intersecting object is on the other side of the
  // viewport, meaning that it is in the frustum. There are two ways for doing this. When
  // calculating the ray’s intersecting pixel’s position on the viewport, you create the ray’s
  // direction vector. If you don’t normalize this direction vector, pixel’s t parameter is
  // equal to 1. Therefore, an intersecting object’s t parameter should be larger than 1.
  // If you normalize the direction vector, then you should calculate t by taking magnitude
  // of it before normalization. Then, intersecting object’s t parameter should be larger
  // than that value. Float.


• #Material MaterialIndex
  ambr ambg ambb difr difg difb sper speg speb specExpP refr refg refb

  //   Objects in your scene will be defined with their material indexes. Materials define
  //   the physical properties of objects. As an example, the material of a table object
  //   can either be wood, or metal. However, we will only define materials with integer
  //   indices, therefore you can think of them as substance 1 and substance 2.
  //   ambient parameters define the percentage the object reflects each band of ambient
  //   light that is cast onto it. For example, if the ambient red property of a material is
  //   0.5, it will absorbe half of the red light it receives, and reflect the other half. Apply
  //   to three bands.
  //   diffuse parameters define the diffusal properties of the material.
  //   specular parameters define the specular properties of the material. Specular
  //   exponent specExpP should also be taken into account, when calculating an the
  //   amount of specular light an object reflects.
  //   reflective parameters are provided to be used with bouncing rays. The bouncing
  //   off ray will contribute to the color of the point it hits first. The reflective parameters
  //   are provided to calculate the amount of of added light (in terms of all three bands)
  //   to the point. If all reflective parameters are close to 1, this is a mirror-like material.
  //   All parameters except specExpP are Floats. specExpP is Integer.


• #Triangle
  pos1x pos1y pos1z pos2x pos2y pos2z pos3x pos3y pos3z MaterialIndex

  // A triangle is defined as three points in world coordinates. positions of three points
  //are given in an ordered manner. Normals should be calculated within this order.
  // MaterialIndex defines the material of the triangle. Use the indexed material for color
  // calculations. All parameters except MaterialIndex are floats. MaterialIndex is
// Integer.


    • #Sphere
      posx posy posz Radius MaterialIndex

      //   Position parameters of a sphere define its center’s position in world coordinates.
      //   Radius is the radius of the sphere.
      //   MaterialIndex defines the material of the sphere. Use the indexed material.
      //   All parameters except MaterialIndex are Floats. MaterialIndex is Integer.


    • #Light
      posx posy posz Ir Ig Ib

      // Position parameters of the light define the light’s position in world coordinates. All
      // Floats. Intensity parameters of the light define the light’s intensity values it delivers
      // in all directions. Intensity values could be higher than 255. Integers.


    • #Ambient
      Ir Ig Ib

      // Intensity parameters of the light define the ambient light’s intensity values in all three
      // bands. This is the amount of light each object’s each point receives even if it is under
      // shadow. Intensity values could be higher than 255. Integers.


    • #Background
      Ir Ig Ib

      // If a ray does not hit anything, the corresponding pixel will take this value. Just as
      // simple as that.


4     Hints & Tips
    • You will implement the ray tracer in C++.

    • You are highly advised to follow a object-oriented approach. The basic classes you may
      need to create are Vector3, Camera, Ray, Shape, Triangle, Sphere, Scene classes. Writing
      a ray tracer is a tedious work, and writing a code neatly by using classes properly will
      save you a huge amount of time, especially when debugging.

    • You are encouraged to use the Vector3 class you implemented in the warm-up.

    • We will test your codes on departmental machines using “g++”. Please make sure to
      run tests on ineks.

    • You may compile your code with -O2 for optimization.

    • In triangle calculations, if the values of beta, gamma and t are not in the expected
      interval, you may choose not to calculate the others. This will provide a certain speed-
      up.
• Normal vectors of triangles are needed for each ray. Pre-computation of normal vectors
      before casting rays will greatly speed-up the process.

    • For a triangle<a,b,c>, you may pre-compute the b-a and c-a vectors and access them
      when casting rays.


5     Submission
Submission will be done via COW. You should upload a single zipped file called “hw1.zip”. In
addition to your code, provide a makefile. Your executable should have the name ”raytracer”.
We will test your code as:

$./raytracer "$SCENE FILE NAME$.txt"

Follow the newsgroup for details.

Late submissions are allowed for this homework, regarding to the policy on the
course’s web site.


6     Grading
Grading will be made using the scala on the course’s website.


7     Cheating Policy
We have zero tolerance policy for cheating. People involved in cheating will be punished
according to the university regulations. See the course website for more information.

Mais conteúdo relacionado

Destaque

Destaque (13)

Nal
NalNal
Nal
 
Rv11
Rv11Rv11
Rv11
 
N
NN
N
 
Kampanje
KampanjeKampanje
Kampanje
 
CV-Farhan Mushtaq
CV-Farhan MushtaqCV-Farhan Mushtaq
CV-Farhan Mushtaq
 
Sante barley
Sante barleySante barley
Sante barley
 
Spreekbeurt St. Dierenlot oktober 2012
Spreekbeurt St. Dierenlot oktober 2012Spreekbeurt St. Dierenlot oktober 2012
Spreekbeurt St. Dierenlot oktober 2012
 
Spreekbeurt grasparkieten
Spreekbeurt grasparkietenSpreekbeurt grasparkieten
Spreekbeurt grasparkieten
 
Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.
Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.
Model-Based Testing: Theory and Practice. Keynote @ MoTiP (ISSRE) 2012.
 
ELABORACION DE NECTAR
ELABORACION DE NECTARELABORACION DE NECTAR
ELABORACION DE NECTAR
 
Case study on testing
Case study on testingCase study on testing
Case study on testing
 
Boekbespreking inge
Boekbespreking ingeBoekbespreking inge
Boekbespreking inge
 
20372748 case-study-on-computer-networking-kotak-mahindra-bank
20372748 case-study-on-computer-networking-kotak-mahindra-bank20372748 case-study-on-computer-networking-kotak-mahindra-bank
20372748 case-study-on-computer-networking-kotak-mahindra-bank
 

Semelhante a Hw1 updated

Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenBenjamin Glatzel
 
Defect detection in circlips using image processing in ni lab view
Defect detection in circlips using image processing in ni lab viewDefect detection in circlips using image processing in ni lab view
Defect detection in circlips using image processing in ni lab viewSayali Bodhankar
 
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfPapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfAdam Hill
 
Object detection at night
Object detection at nightObject detection at night
Object detection at nightSanjay Crúzé
 
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se..."Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...Edge AI and Vision Alliance
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
5 ray casting computer graphics
5 ray casting computer graphics5 ray casting computer graphics
5 ray casting computer graphicscairo university
 
PR-284: End-to-End Object Detection with Transformers(DETR)
PR-284: End-to-End Object Detection with Transformers(DETR)PR-284: End-to-End Object Detection with Transformers(DETR)
PR-284: End-to-End Object Detection with Transformers(DETR)Jinwon Lee
 
Simulating X-ray Observations with yt
Simulating X-ray Observations with ytSimulating X-ray Observations with yt
Simulating X-ray Observations with ytJohn ZuHone
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoreambikavenkatesh2
 
super-cheatsheet-deep-learning.pdf
super-cheatsheet-deep-learning.pdfsuper-cheatsheet-deep-learning.pdf
super-cheatsheet-deep-learning.pdfDeanSchoolofElectron
 
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdfSongsDrizzle
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancementRamin Anushiravani
 
Wits presentation 6_28072015
Wits presentation 6_28072015Wits presentation 6_28072015
Wits presentation 6_28072015Beatrice van Eden
 

Semelhante a Hw1 updated (20)

Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the Fallen
 
Defect detection in circlips using image processing in ni lab view
Defect detection in circlips using image processing in ni lab viewDefect detection in circlips using image processing in ni lab view
Defect detection in circlips using image processing in ni lab view
 
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdfPapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
 
november6.ppt
november6.pptnovember6.ppt
november6.ppt
 
Compressed Sensing - Achuta Kadambi
Compressed Sensing - Achuta KadambiCompressed Sensing - Achuta Kadambi
Compressed Sensing - Achuta Kadambi
 
Poster cs543
Poster cs543Poster cs543
Poster cs543
 
Object detection at night
Object detection at nightObject detection at night
Object detection at night
 
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se..."Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...
"Image Sensors for Vision: Foundations and Trends," a Presentation from ON Se...
 
06 image features
06 image features06 image features
06 image features
 
5 ray casting computer graphics
5 ray casting computer graphics5 ray casting computer graphics
5 ray casting computer graphics
 
PR-284: End-to-End Object Detection with Transformers(DETR)
PR-284: End-to-End Object Detection with Transformers(DETR)PR-284: End-to-End Object Detection with Transformers(DETR)
PR-284: End-to-End Object Detection with Transformers(DETR)
 
Simulating X-ray Observations with yt
Simulating X-ray Observations with ytSimulating X-ray Observations with yt
Simulating X-ray Observations with yt
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
 
Deferred shading
Deferred shadingDeferred shading
Deferred shading
 
Lecture1
Lecture1Lecture1
Lecture1
 
super-cheatsheet-deep-learning.pdf
super-cheatsheet-deep-learning.pdfsuper-cheatsheet-deep-learning.pdf
super-cheatsheet-deep-learning.pdf
 
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf
_AI_Stanford_Super_#DeepLearning_Cheat_Sheet!_😊🙃😀🙃😊.pdf
 
UNIT-4.pptx
UNIT-4.pptxUNIT-4.pptx
UNIT-4.pptx
 
A computer vision approach to speech enhancement
A computer vision approach to speech enhancementA computer vision approach to speech enhancement
A computer vision approach to speech enhancement
 
Wits presentation 6_28072015
Wits presentation 6_28072015Wits presentation 6_28072015
Wits presentation 6_28072015
 

Último

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Último (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Hw1 updated

  • 1. Middle East Technical University Department of Computer Engineering CENG 477 Introduction to Computer Graphics Fall ’2011-2012 Assignment 1 - Ray Tracer Due date: 13 November 2011, Friday, 23:55 1 Objective You will implement a ray tracer. In this homework, you will dig into the details of ray tracing. When you see the light at the end of the tunnel, we promise you’ll be very satisfied with the result! 2 Specifications • You will read a scene file, for example ”scene.txt”. This file includes all the basic information you need when rendering a scene. Details of this file is included in the next chapter. The scene file will have the extension ”.txt”. • The scene file will exist in the workspace, and we will provide its name as the only command line argument to your program. • You will render the given scene using perspective projection. • The time limit is 15 minutes on ineks. If you exceed this time, your program will be terminated. • All coordinates provided in the scene file are world coordinates. Which means, they are only relative to the origin, not to each other. • All of the lights provided in the scene file are point light sources, equally shining in all directions. NOTE: Intensity values of the light need not be between 0-255. They simply define a light source’s power, or the amount of light it delivers. When calculating the final color of a pixel, you need to map values higher than 255 to maximum pixel intensity 255, for each band. • Your ray tracing algorithm will implement ambient shading, diffuse shading, specular shading, shadows and object reflectance properties. • You will save the rendered image to ”$SCENE FILE NAME$.ppm” in the workspace. For example, if you are asked to render ”scene.txt”, the output image should be ”scene.ppm”. ”.ppm” file format is very easy to write. You may use the sample code we provide for writing to a ”.ppm” file. You may find detailed information about the format here.
  • 2. 3 Scene File The scene file includes every detail you will use when drawing a scene. The scene file format is given as follows: ImageWidth ImageHeight Tmin Ray Reflect Count #Camera posx posy posz gazex gazey gazez uprx upy upz left right bottom top distance #Material MaterialIndex ambr ambg ambb difr difg difb sper speg speb specExpP refr refg refb #Triangle pos1x pos1y pos1z pos2x pos2y pos2z pos3x pos3y pos3z MaterialIndex #Sphere posx posy posz Radius MaterialIndex #Light posx posy posz Ir Ig Ib #Ambient Ir Ig Ib #Background Ir Ig Ib 3.1 Explanation of Scene File The first three lines of a scene file are fixed. The rest may be of any order. There will be only one camera entry and one ambient entry in the file. • ImageWidth ImageHeight // The width and height of the image to be rendered. Both Integer. • Tmin // When sending a reflecting ray from an object, you should first normalize the ray. // When checking for an intersection with other objects, you should take Tmin // as minimum t parameter for the ray. Intersections with smaller t (such as the // object itself) should not be taken into account. // IMPORTANT: The frustum’s far edge is not defined. There is no limit on the // maximum distance of intersection. You should check ray-object intersection with // each object. If the ray does not intersect with any object in the frustum, then // you assign the pixel background color.
  • 3. • Ray Reflect Count // A ray can bounce off this many times. Integer. • #Camera posx posy posz gazex gazey gazez uprx upy upz left right bottom top distance // You will send rays from the camera that is put into scene with the given parameters. // position parameters define the position of the camera. All Float. // gaze parameters define your viewing direction as a vector. All Float. // up parameters define the up vector. All Float. // left, right, bottom, up parameters together define the size of viewport. All Float. // distance is the distance of viewport from the camera. When sending the ray for // the first time, you should check if an intersecting object is on the other side of the // viewport, meaning that it is in the frustum. There are two ways for doing this. When // calculating the ray’s intersecting pixel’s position on the viewport, you create the ray’s // direction vector. If you don’t normalize this direction vector, pixel’s t parameter is // equal to 1. Therefore, an intersecting object’s t parameter should be larger than 1. // If you normalize the direction vector, then you should calculate t by taking magnitude // of it before normalization. Then, intersecting object’s t parameter should be larger // than that value. Float. • #Material MaterialIndex ambr ambg ambb difr difg difb sper speg speb specExpP refr refg refb // Objects in your scene will be defined with their material indexes. Materials define // the physical properties of objects. As an example, the material of a table object // can either be wood, or metal. However, we will only define materials with integer // indices, therefore you can think of them as substance 1 and substance 2. // ambient parameters define the percentage the object reflects each band of ambient // light that is cast onto it. For example, if the ambient red property of a material is // 0.5, it will absorbe half of the red light it receives, and reflect the other half. Apply // to three bands. // diffuse parameters define the diffusal properties of the material. // specular parameters define the specular properties of the material. Specular // exponent specExpP should also be taken into account, when calculating an the // amount of specular light an object reflects. // reflective parameters are provided to be used with bouncing rays. The bouncing // off ray will contribute to the color of the point it hits first. The reflective parameters // are provided to calculate the amount of of added light (in terms of all three bands) // to the point. If all reflective parameters are close to 1, this is a mirror-like material. // All parameters except specExpP are Floats. specExpP is Integer. • #Triangle pos1x pos1y pos1z pos2x pos2y pos2z pos3x pos3y pos3z MaterialIndex // A triangle is defined as three points in world coordinates. positions of three points //are given in an ordered manner. Normals should be calculated within this order. // MaterialIndex defines the material of the triangle. Use the indexed material for color // calculations. All parameters except MaterialIndex are floats. MaterialIndex is
  • 4. // Integer. • #Sphere posx posy posz Radius MaterialIndex // Position parameters of a sphere define its center’s position in world coordinates. // Radius is the radius of the sphere. // MaterialIndex defines the material of the sphere. Use the indexed material. // All parameters except MaterialIndex are Floats. MaterialIndex is Integer. • #Light posx posy posz Ir Ig Ib // Position parameters of the light define the light’s position in world coordinates. All // Floats. Intensity parameters of the light define the light’s intensity values it delivers // in all directions. Intensity values could be higher than 255. Integers. • #Ambient Ir Ig Ib // Intensity parameters of the light define the ambient light’s intensity values in all three // bands. This is the amount of light each object’s each point receives even if it is under // shadow. Intensity values could be higher than 255. Integers. • #Background Ir Ig Ib // If a ray does not hit anything, the corresponding pixel will take this value. Just as // simple as that. 4 Hints & Tips • You will implement the ray tracer in C++. • You are highly advised to follow a object-oriented approach. The basic classes you may need to create are Vector3, Camera, Ray, Shape, Triangle, Sphere, Scene classes. Writing a ray tracer is a tedious work, and writing a code neatly by using classes properly will save you a huge amount of time, especially when debugging. • You are encouraged to use the Vector3 class you implemented in the warm-up. • We will test your codes on departmental machines using “g++”. Please make sure to run tests on ineks. • You may compile your code with -O2 for optimization. • In triangle calculations, if the values of beta, gamma and t are not in the expected interval, you may choose not to calculate the others. This will provide a certain speed- up.
  • 5. • Normal vectors of triangles are needed for each ray. Pre-computation of normal vectors before casting rays will greatly speed-up the process. • For a triangle<a,b,c>, you may pre-compute the b-a and c-a vectors and access them when casting rays. 5 Submission Submission will be done via COW. You should upload a single zipped file called “hw1.zip”. In addition to your code, provide a makefile. Your executable should have the name ”raytracer”. We will test your code as: $./raytracer "$SCENE FILE NAME$.txt" Follow the newsgroup for details. Late submissions are allowed for this homework, regarding to the policy on the course’s web site. 6 Grading Grading will be made using the scala on the course’s website. 7 Cheating Policy We have zero tolerance policy for cheating. People involved in cheating will be punished according to the university regulations. See the course website for more information.