50 likes | 189 Views
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<Object> listObj_ .for each Object* obj in listObj_ .call obj->draw() , which is a virtual function
E N D
Ray TracingTP OpenGL PHAM Trong Tôn WANG Yuanhang
Scene 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
Ray casting >ray sphere intersection, algebraic approach .if there is intersection Call void Viewer::select(int x, int y) P = Ro + t*Rd Ro Rd .Po Pt t, the closest positive solution of quadratic function. (P- Po )∙(P- Po )-r^2=0 Store Pt, t, normal, material and calculated texture mapping in parameter hit .otherwise return background
Ambient Color Light source Direct reflection q q Diffuse Color View point a Specular Color Lighting & Shadow • I = Ia ka • + Ipkdcosθ • + Ipks (cosα)n
1 (0,0) 1 (u,v) (x,y,z) Texture mapping & Anti-aliasing mapping u = 1.0 – θ/2πθ = atan2(x,y) v = 0.5 – α/πα = atan(z/sqrt(x2+y2)) * Sampling window (n=2)