Ray Tracing TP OpenGL

5
Ray Tracing Ray Tracing TP OpenGL TP OpenGL PHAM Trong Tôn PHAM Trong Tôn WANG Yuanhang WANG Yuanhang

description

Ray Tracing TP OpenGL. PHAM Trong Tôn WANG Yuanhang. Scene management and display. > Scene display workflow .call Scene::draw() in viewer . Scene::draw() scans through QPtrList listObj_ .for each Object* obj in listObj_ .call obj->draw() , which is a virtual function - PowerPoint PPT Presentation

Transcript of Ray Tracing TP OpenGL

Page 1: Ray Tracing TP OpenGL

Ray TracingRay TracingTP OpenGLTP OpenGL

PHAM Trong TônPHAM Trong Tôn

WANG YuanhangWANG Yuanhang

Page 2: Ray Tracing TP OpenGL

Scene management and displayScene management and display

> Scene display workflow

.call Scene::draw() in viewer

.Scene::draw() scans through QPtrList<Object> listObj_

.for each Object* obj in listObj_

.call obj->draw(), which is a virtual function

.draw() of derived class of Object override obj->draw()

> Scene loading workflow

.load scene file by Scene::loadFromFile

.call initFromDOMElement of respective Object

.parse xml, set parameter value

Page 3: Ray Tracing TP OpenGL

Ray Ray castingcasting>ray sphere intersection, algebraic approach

.if there is intersection

t, the closest positive solution of quadratic function.

Rd Ro

.otherwise

return background

Store Pt, t, normal, material and calculated texture mapping in parameter hit

P = Ro + t*Rd

(P- Po )∙(P- Po )-r^2=0

Pt

.Po

Call void Viewer::select(int x, int y)

Page 4: Ray Tracing TP OpenGL

Lighting & ShadowLighting & Shadow

I = Ia ka

Light source

Direct reflection

View point

Ambient Color

Diffuse Color

Specular Color

+ Ipkdcosθ + Ipks (cosα)n

Page 5: Ray Tracing TP OpenGL

TextureTexture mapping mapping & & Anti-Anti-aliasingaliasing

(x,y,z) (u,v)(0,0) 1

1mapping

u = 1.0 – θ/2π θ = atan2(x,y)

v = 0.5 – α/π α = atan(z/sqrt(x2+y2))

11 11

11 11*Sampling window

(n=2)