Ray Tracing TP OpenGL PHAM Trong Tôn WANG Yuanhang.
-
Upload
earl-tucker -
Category
Documents
-
view
214 -
download
0
Transcript of Ray Tracing TP OpenGL PHAM Trong Tôn WANG Yuanhang.
![Page 1: Ray Tracing TP OpenGL PHAM Trong Tôn WANG Yuanhang.](https://reader036.fdocuments.in/reader036/viewer/2022082711/56649f2f5503460f94c4977d/html5/thumbnails/1.jpg)
Ray TracingRay TracingTP OpenGLTP OpenGL
PHAM Trong TônPHAM Trong Tôn
WANG YuanhangWANG Yuanhang
![Page 2: Ray Tracing TP OpenGL PHAM Trong Tôn WANG Yuanhang.](https://reader036.fdocuments.in/reader036/viewer/2022082711/56649f2f5503460f94c4977d/html5/thumbnails/2.jpg)
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 PHAM Trong Tôn WANG Yuanhang.](https://reader036.fdocuments.in/reader036/viewer/2022082711/56649f2f5503460f94c4977d/html5/thumbnails/3.jpg)
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 PHAM Trong Tôn WANG Yuanhang.](https://reader036.fdocuments.in/reader036/viewer/2022082711/56649f2f5503460f94c4977d/html5/thumbnails/4.jpg)
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 PHAM Trong Tôn WANG Yuanhang.](https://reader036.fdocuments.in/reader036/viewer/2022082711/56649f2f5503460f94c4977d/html5/thumbnails/5.jpg)
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)