380 likes | 604 Views
Curs 5. Real-time rendering – randare în timp real. Real Time rendering. Real-time requirements : - Load pol i gonal scăzut pe pipeline -ul grafic M etod e conservative si neconservative Culling (conservativ) Simplifica re (n e conservativ) IBR - Image Based Rendering (h i brid).
E N D
Curs 5 Real-time rendering – randare în timp real
Real Time rendering • Real-time requirements: - Load poligonalscăzut pe pipeline-ul grafic • Metode conservative si neconservative • Culling (conservativ) • Simplificare (neconservativ) • IBR - Image Based Rendering (hibrid)
Culling • Principiu culling:Poligoanele care nu sunt vizibile de către utilizator nu trebuie randate: • Ascunse de alte poligoaneale aceluiași obiect (Backface culling) • Înafara volumului de vedere (Viewfrustum culling) • Ascunse de alte obiecte (Occlusion culling)
Backface culling • Fiecare poligon este asociat cu o normală care îi determină orientarea • Poligoanele sunt astfel: • Frontfacing, când normala intersectează planul utilizatorului • Backfacing, în caz contrar • În cazul obiectelor convexe, poligoanele backfacingsunt ascunse de cele frontfacing V = VizibilI = Invizibil
Backface culling • De la un viewpoint specific, doar câteva poligoane sunt vizibile (statistic 50 %) • Ignorând aceste poligoane, teoretic, performanțelear trebui să crească mult (de 2 ori). • De fapt, acest lucru nu are loc din cauza calculului orientării care este realizat în pipeline-ul grafic, după transformările geometice
Backface culling hardware • Plăcile grafice au implementate un HW backface test, care eliminăpoligoanele BF polygons înainte de etapa de iluminare • BF test este reprezentat de produsul scalar dintre normala la poligon (Np) și direcțiade privire (D): B = Np.D • B<0 frontfacingB>0 backfacing Np
Backface culling software • Ar fi bine să găsim poligoanele BF polys înainte de accesul la pipeline-ul grafic • Există tehnici SW • Sunt eficientedacă sunt folosite structuri ierarhice • NORMAL MASKS (Zhang e Hoff, 1997) • preprocessing (normalmaskspreparation) • run-time (test) http://www.cs.unc.edu/~zhangh/backface.html
Viewfrustum culling • Poligoanelecare nu sunt incluse în volumul de vedere nu sunt vizibile • Acestea trebuie identificate pentru a nu fi trimise la pipeline
Viewfrustum culling • CLIPPINGRemovaloftriangles (or portions)notfalling inside the view volume • Efficient HW technique • Takesplacelater in the pipeline • Doesnotaffect the polygonalload onthee pipeline
Viewfrustum culling • VF cullingisananticipatedclipping • Geometryisdivided in: • Inside Viewfrustum (visible) RENDERED • OutsideViewfrustum (invisible) CULLED • Simple VF Culling: • Eachpolygonistested • Ineffectiveformanypolygons • Scene Graphneeded
Viewfrustum culling • Hierarchical VF Culling: • Nodes are tested (BoundingVolumes or SG node) • If the nodeiscompletelyoutside the VF, so do alsoall the containedpolys CULLED • If the nodeiscompletely insideso do alsoall the containedpolys RENDERED • If the nodeis PARTIALLY inside: • Lowerlevelnodes are tested • If the nodeis a leaf: • Test on allpolygons (uneffective) • All the polygons are RENDERED
Viewfrustum culling • Frame to Frame Coherence:Objects not visible at time t, will be probably not visible also at t+Dt • Coherence test for traslation (Dd) and rotation (Dq) of the viewpoint: BS BS Dd Dq Dd < distance → Still outside Dd > distance→ Check direction, then possibly check VF Dq against VF → Still outsideDq towards VF → Check VF
VF Culling test • An object is outside the VF if it is behind at least one of its planes: Considering planes normals oriented towards the VR inside: • For a point: distance from plane < 0 • For a sphere: distance center from plane < - r • For a box: distance of its vertices < 0 (all 8 checks needed?) • Calculations are relatively simple, however the planes equations may be tricky BB BS BS BB BB BS
Frustum in Clip Space • The projection transforms the VR into a cube of vertices (±1,±1, ±1) (clip space) • Planes in Clip Space are easy to determine: • Eq. generic: ax+by+cz+d = 0 • In this case: x = 1, x = -1, etc. • With the projection matrix the points tobe checked can be trasformed quickly andtests can take place in the clip space
Occlusion culling • Some polygons, although front-facing within the VF, can be hidden by other objects • Z-Buffering • Occlusion tested at pixel level • For each (x,y,z) in WindowSpace, the z value is tested against the z-buffer one related to position (x,y) • If z is smaller the point is occlubed • Also in this case: • It is made downstream the pipeline • Hidden polygons/objects should be identified upstream • Note: occlusion culling algorithms are usually heavy, should be used with HUGE scenes
Occlusion culling: HOM • Hierarchical Occlusion Map (Zhang, Manocha, Hudson e Hoff 1997) • Preprocessing: • OCCLUDER identification (probable occluder) • Quite big, possibly not too many polys • Creation of the OCCLUDER db • Depending on size and distance from the VP, at run-time some occluder are extracted • For each object a depth test is performed to check if it is behind an occluder
Occlusion culling: HOM • Which depth test is made? • Minimal depth-test: a plane behind the occluder is tested: if the object is behind this plane is a good candidate to be culled
Occlusion culling: HOM • Smart run-time phase: • First, only the occluders are drawn in white. A grey scale hierarchical map is retrieved (cluster 2x2 -> 1 pixel with averaged color) • Objects BVs are tested against the map (startingwith the coarsest level): • If the BV falls inside a white zone the object MAY be occluded: the depth-test will take place • If the BV falls inside a zone with even ONE non-white pixel, the immediately finer level is checked • Aggressive (non conservative) culling: the depth-test takes place even after a certain grey threshold (this means that objects might be “almost” occluded)
Potentially Visible Sets • Hi-leveltechniqueforarchitectural VE • Environmentsubdivided in: • CELLS: portions of space (usually BOXes) • PORTALS: 2D area connecting two cells • In architecturalVEs: • CELL = Room • PORTAL = Door, Window, Mirror • Twocells can seeeachotherthrough a portal • Potentiallyvisible set: • Set ofcells “visible” from a certainviewpoint
Potentially Visible Sets • Building the PVS: • Active cell (where the observer is) is in the PVS • The cells visible from the active cell are in the PVS • The cells not inside the PVS are culled • Inside the PVS standard visibility techniques might be used • Not suitable for all the VEs (with some modifications can be adapted to outdoor VEs)
Simplification • Operate on the modelcomplexity • The idea isthat, in some circumstances, simplifiedmodels can beusedwithouthmodifyingtoomuch the finalresult • Generallythereis a loss ofdetails: non-conservativetechniques • Techniques: • LevelofDetail • ImageBasedRendering
Level of Detail • Objects far from the VP do notneedtoomanydetails, asthey are notvisible • They can do simplifieddepending on distance and angulationfrom the observer • LODs are alternative versionsof the samemeshwithdifferentlevelsofcomplexity
Level of Detail • LOD can becreated: • Off-line (maximumcontrol, prefixedcomplexity) • Run-time (variablecomplexity) • run-time: progressive meshes • Dynamiclods • OnlyΔs are stored • Optimalfor network distribution
Image Based Rendering • Culling and LOD tecnhiquesaimto reduce the polygonal budget • IBR aimstosubstitutepolygonswithimages • Veryeffectiveifusedtogetherwith the othertechniques • Methods: • Static (Database Approach, Sprites) • Dynamic (Impostors)
Billboards • Texturesallowto simulate complexvisualdetails on simpleshapes. • Evenonlyonepolygon! • Billboards are texturedquadsthat rotate so astoalways face the viewpoint • Goodapproximationforsymmetricobjects • Simmetry: • Cylindric: axial rotation = arccos(Vd•Bn) • Spheric: two rotation axes
Database Approach • Basic idea: • All the possible views of an object are rendered and, at run-time, the one corresponding to the current VP is chosen • Actually, only a limited set of VPs are used. At run-time: • The image corresponding the the closest VP is renderd • Images are interpolated (morphing)
Impostors • IMPOSTORS: • the viewof the objectisgrabbedduring the run-timephase so asto exploit the frame-to-framecoherence: probably in the next frame the objectwillhave (almost) the sameappearance
Impostors • Impostors are view-dependent: the grabbed image is a faithful representation of an object only in a certain viewpoint V • In a range R of viewpoints around V the impostor is still a good approximation, outside the image can be very different • Outside R either the object must be rendered again or a new impostor must be created
Impostors • An impostorisvalid in the frame whenitiscreated • The impostorisvalidif the observerperformsonly ROTATIONAL movements (the projection on the viewplaneisnotaffected) • Fortranslationalmovements, the representationchanges. Beyond a certainDs lateral or forward, the errorbecomestoo big. After a certainthreshold a newimpostormustbecreated
Impostors: errors • Objects are notanymore 3D • Thisleadstoerrors in intersectingobjects • Possiblesolution: layeredimpostors