may 08-38 cyray: real time ray-tracing for cell on a playstation3 30 april 2008 brendan campbell,...

26
May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and Faculty Advisor: Dr. Joseph Zambreno DISCLAIMER: This document was developed as part of the requirements of an electrical and computer engineering course at Iowa State University, Ames, Iowa. The document does not constitute a professional engineering design or a professional land surveying document. Although the information is intended to be accurate, the associated students, faculty, and Iowa State University make no claims, promises, or guarantees about the accuracy, completeness, quality, or adequacy of the information. Document users shall ensure that any such use does not violate any laws with regard to professional licensing and certification requirements. Such use includes any work resulting from this student-prepared document that is required to be under the responsible charge of a licensed engineer or surveyor. This document is copyrighted by the students who produced the document and the associated faculty advisors. No part may be reproduced without the

Upload: lambert-watts

Post on 11-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

May 08-38CyRay: Real Time

Ray-Tracing for CellOn a PlayStation3

May 08-38CyRay: Real Time

Ray-Tracing for CellOn a PlayStation3

30 April 2008

Brendan Campbell, Sean Godinez,

Daniel Risse, Aaron Westphal

Client and Faculty Advisor:

Dr. Joseph ZambrenoDISCLAIMER: This document was developed as part of the requirements of an electrical and computer engineering course at Iowa State University, Ames, Iowa. The document does not constitute a professional engineering design or a professional land surveying document. Although the information is intended to be accurate, the associated students, faculty, and Iowa State University make no claims, promises, or guarantees about the accuracy, completeness, quality, or adequacy of the information. Document users shall ensure that any such use does not violate any laws with regard to professional licensing and certification requirements. Such use includes any work resulting from this student-prepared document that is required to be under the responsible charge of a licensed engineer or surveyor. This document is copyrighted by the students who produced the document and the associated faculty advisors. No part may be reproduced without the written permission of the senior design course coordinator.

Page 2: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

OverviewOverview• Problem

– Ray Tracing, a method of rendering graphics, is a computationally expensive process. Most single-machine implementations of ray tracers cannot produce satisfactory results in real time. The MIT Blue Steel project is a Ray Tracer for the PS3, but has much room for improvement.

• Goal– Write a program to render realistic looking scenes using an impressive set

of graphical enhancements in real time animation on a PlayStation3 (PS3)

• Tasks – Implement a multi-threaded ray tracing program for Linux on the PS3 that

utilizes the Cell Broadband Engine’s SPE cores– Expand functionality, optimize throughput, and run ongoing tests

• Users– Dr. Joseph Zambreno, PS3 Linux users, and others interested in real-time

ray tracing using the Cell Broadband Engine

Page 3: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Why Ray Tracing?Why Ray Tracing?

Page 4: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

DefinitionsDefinitions• Ray Tracing

– A method of rendering realistic 3D images by shooting rays from a camera through each pixel on a screen. Each ray is recursively traced back to light sources in order to produce each pixel’s final color

• Scene– The data defining the objects and

light sources to be rendered

• kd-Tree– A hierarchical data structure for

partitioning points in k-dimensional space. Will be used to organize objects in the scene so that the necessary objects can be scanned efficiently

Page 5: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Definitions (cont’d)Definitions (cont’d)• Sony PlayStation3 Console (PS3)

– A high-performance home entertainment platform featuring the CBE capable of running Linux

• Cell Broadband Engine (CBE)– A multi-core processor developed by Sony,

Toshiba, and IBM that is the heart of the PS3. Has one PPE and 6 usable SPEs

• Power Processing Element (PPE) – The primary core of the CBE which executes

PowerPC instructions. It will be used to parse and assign scene data to the SPEs

• Synergistic Processing Elements (SPEs) – These are supplemental cores that specialize in

SIMD instructions. These will do the majority of the Ray-Tracing work

• Single Instruction, Multiple Data (SIMD)– Wide-pipelines allow for data-level parallelism.

Also called vectorized instructions, this permits the same instruction to be performed simultaneously on multiple blocks of data

© IBM

Page 6: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Program RequirementsProgram Requirements

• Functional– Shall have a fast frame rate to simulate real-time (≥20 FPS)– Shall have low latency to respond to user inputs (≤ 100ms)– Shall have 24 bit color pixels– Shall allow user to modify camera position and angle– Shall support a screen resolution of 720 x 576 pixels (576p)

• Non-Functional– Shall avoid branching functions and recursion to optimize algorithm run-

time on cell processor– Shall be able to store all required scene data in available cell processor

memory – Shall not be cross-compatible with other OS or processor types– Team shall also provide or procure a suitable model to render

Page 7: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

– Shadows– Reflection– Refraction– Material Effects– Phong Interpolation

– Diffuse Shading– Specular Shading– Texture Mapping– Anti-aliasing– Ambient Occlusion

Features to ImplementFeatures to Implement

Page 8: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

DeliverablesDeliverables

• Source Code • Executable Code• Renderable Model

for program input• Documentation

Our Blender Model of Coover Hall

Page 9: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

System Block DiagramSystem Block Diagram

Page 10: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Data Flow DiagramData Flow Diagram

Page 11: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

SpecificationsSpecifications

• Input– Scene Description File

• Yafray XML Format – exported from Blender

– USB Keyboard TTY interface

• Output– Frame Buffer

• ARGB byte ordering

– LCD Monitor• Currently configured for 720x576 pixels

Page 12: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Specifications (cont’d)Specifications (cont’d)

• Hardware– Sony PlayStation3 Console

• Cell Broadband Engine– Power Processing Element– Synergistic Processing Elements

– Relevant Peripherals• USB Keyboard• HDMI to DVI Adaptor Cable• LCD Monitor with DVI input

Page 13: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

• SoftwareUse Case Description:

• The user utilizes an input device to produce a camera movement command

• The system translates the command into a coordinate change for the active camera

– This change takes effect before for the next frame that has yet to start rendering.

• The system renders the scene using the new camera coordinates.

Specifications (cont’d)Specifications (cont’d)

Page 14: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Class DesignClass Design• SceneSet

– Contains all the objects in the scene. Primitives, Lights, and a Camera can be added to this object. All objects can be referenced through this object. Ray Tracing requests are called through this object.

• FrameBuffer– Contains a front and back buffer for displaying the scene. Each pixel will be

represented by 24-bit r,g,b values, and stored in a 32-bit slot for alignment purposes. All pixel updates will take place on the back buffer. The frames will flip with VSYNC (60 Hz).

• ObjectTree– This will be the tree containing all of the objects within the scene. This tree will be

an efficient way to reference parts of the scene that are needed.

• Triangles and Spheres– These are the basic primitives that are supported. These objects contains a

Material object. They handle the collision calculations.

Page 15: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Primary Class DesignPrimary Class Design

+cSceneSet () : cSceneSet+~cSceneSet () : cSceneSet+AddLight (cLight*) : void+AddSphere (cObject*) : void+AddTriangle (cObject*) : void+GetLights () : cLights+GetTriangles () : cObject+GetSpheres () : cObject

cSceneSet

+cLight () : cLights+cLight (float, float, float) : cLights+~cLight () : cLights

cLights

+cVector3 () : cColor+~cVector3 () : cColor+cVector3 (float, float, float) : cColor+Set (float, float, float) : void+Normalize () : void+Length () : float+SqrLength () : float+Dot (various) : float+Cross (various) : cColor

cVector3

+cCamera () : cCamera+~cCamera () : cCamera+Origin () : cVector3+X_Size () : int+Y_Size() : int+Distance () : int+A_X () : int+B_X () : int+A_Y () : int+B_Y () : int+CurrentPixel ()+RenderRay () : RayPacket

cCamera

Page 16: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Object Class DesignObject Class Design

+cMaterial () : cObject+~cMaterial () : cObject+cMaterial (cColor&, float, float, float) : cObject+SetColor (cColor&) : void+SetColor (Color) : void+SetColor (BYTE, BYTE, BYTE) : void+SetSpecular (float) : void+SetRefract (float) : void+SetReflect (float) : void+GetColor ()+GetSpecular () : float+GetRefract () : float+GetReflect () : float

cMaterial+cColor () : cColor+~cColor () : cColor+cColor (BYTE, BYTE, BYTE) : cColor+SetColor (cColor&) : void+SetColor (Color) : void+SetColor (BYTE, BYTE, BYTE) : void+SetRed (BYTE) : void+SetBlue (BYTE) : void+SetGreen (BYTE) : void+GetColor ()+GetRed ()+GetBlue ()+GetGreen ()

cColor

+cSphere () : cColor+~cSphere () : cColor+cSphere (cVector3, float) : cColor+Intersect (Ray&, float) : int

cSphere

+cTriangle () : cColor+~cTriangle () : cColor+cTriangle (cVector3*) : cColor+Intersect (Ray&, float) : int

cTriangle

-End11

-End2*

-End31

-End4*

Page 17: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

ImplementationImplementation

Expected Features and Timeline1. Simple Ray Tracer that runs on the PS3

2. Simple Ray Tracer utilizing Cell SPEs and kd-tree scene

3. Produce 3D Model file for CyRay to render

4. Specular Shading

5. Shadows

6. Phong Interpolation

7. Reflections

8. Refractive Transparency

9. Textures

10. Bump Mapping

11. Anti-Aliasing & Ambient Occlusion

Page 18: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Initial Test PlanInitial Test Plan

During DevelopmentUnit Tests:• Tests for Primitives – Know arrangement of distances,

checked for collisions• Tests for SceneSet and Framebuffer - Creation of visual

patterns. Qualitative Analysis. Frame Rate tests

Post Development• Integration tests for qualitative analysis• Testing against known rendering, pixel-by-pixel Mean

Square Error• Full integration Frame Rate analysis

Page 19: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

TestingTesting

Unit Tests: Tests for Primitives – Know arrangement of

distances, checked for collisions Tests for SceneSet and Framebuffer - Creation of

visual patterns. Qualitative Analysis. Frame Rate tests

Integration Tests: Qualitative analysis Test against Blender by pixel-wise Mean Square Error

• Camera lens equations are incompatible with Blender’s internal ray-tracer

Full integration Frame Rate analysis

Page 20: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Completed MilestonesCompleted Milestones

1. Single-threaded Ray Tracer for the PS3

2. Diffuse Shading

3. Multi-frame blending Anti-Aliasing

4. Adaptive Anti-Aliasing

5. Revised Blue Steel code for Cell SDK 3.0

6. XML Reader

7. Interactive Camera

8. Multithreaded Ray Tracer for the PS3

Page 21: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Earned Value AnalysisEarned Value Analysis

• Budgeted Cost of Work Scheduled: $7200– Estimate aggregate of hours to work @ $10/hour per

person (based on the weekly hours expected for 491)

• Actual Cost of Work Performed: $8420– Cost of all hours spent on work for Senior Design

• Budget Cost of Work Performed: $6315– Coding effort est. 75% complete * ACWP

Page 22: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Earned Value Analysis (cot’d)Earned Value Analysis (cot’d)

• Cost Variance: -$2105 or 33%• Schedule Variance: -$885• Cost Performance Index: 0.750• Schedule Performance Index: 0.877

Page 23: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Lessons LearnedLessons Learned

• Ray Tracing has many aspects that can be approached differently and it requires diverse knowledge to implement efficiently

• Cell is a heterogeneous parallel architecture• SPE Cache Memory limitations are a difficult issue

in implementation• Gained knowledge of approaches to Ray Tracing

with multiple goals in mind

Page 24: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

Future WorkFuture Work

• More Rendering Features:

Phong Interpolation, Reflection, Specular Shading, Refraction/transparency, Shadows, Textures, Bump Mapping, Ambient Occlusion

• Higher Resolutions, for instance 720p• More use of vectorized SIMD code• Scene Object Hierarchy (Octree/kd-tree)• Load-balancing• Dynamic Local-store management• Increase Rendering Resolution• Extend to cluster of networked PS3’s

Page 25: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

ConclusionsConclusions

• CyRay is an improvement over MIT’s Blue Steel project– Produced from a structured design process– Our design has more room for further

development and scaling– Our framework provides a cleaner interface– CyRay is compatible with Cell BE SDK 3.0

• We have demonstrated a proof of concept several anti aliasing strategies

Page 26: May 08-38 CyRay: Real Time Ray-Tracing for Cell On a PlayStation3 30 April 2008 Brendan Campbell, Sean Godinez, Daniel Risse, Aaron Westphal Client and

ReferencesReferences• Blender

– http://www.blender.org/• IBM Cell Processor

– http://www-128.ibm.com/developerworks/power/library/pa-fpfeib/• MIT Blue Steel Project

– http://www.cag.csail.mit.edu/ps3/blue-steel.shtml• ISU Senior Design Homepage

– http://seniord.ece.iastate.edu/• Ray Tracing Tutorial

– Bikker, Jacco– http://www.devmaster.net/articles/raytracing_series/part1.php

• Wikipedia: KD-Tree, Bump Mapping– http://en.wikipedia.org/wiki/