 Download Download Presentation Acceleration

# Acceleration

Télécharger la présentation ## Acceleration

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Acceleration Digital Image Synthesis Yung-Yu Chuang with slides by Mario Costa Sousa, Gordon Stoll and Pat Hanrahan

2. Acceleration techniques

3. Bounding volume hierarchy

4. Find bounding box of objects Bounding volume hierarchy

5. Find bounding box of objects Split objects into two groups Bounding volume hierarchy

6. Find bounding box of objects Split objects into two groups Recurse Bounding volume hierarchy

7. Find bounding box of objects Split objects into two groups Recurse Bounding volume hierarchy

8. Find bounding box of objects Split objects into two groups Recurse Bounding volume hierarchy

9. Find bounding box of objects Split objects into two groups Recurse Bounding volume hierarchy

10. At midpoint Sort, and put half of the objects on each side Use modeling hierarchy Where to split?

11. If hit parent, then check all children BVH traversal

12. Don't return intersection immediately because the other subvolumes may have a closer intersection BVH traversal

13. Bounding volume hierarchy

14. Bounding volume hierarchy

15. Quadtree (2D) Octree (3D) Space subdivisionapproaches Unifrom grid

16. KD tree Space subdivisionapproaches BSP tree

17. Uniform grid

18. Preprocess scene Find bounding box Uniform grid

19. Preprocess scene Find bounding box Determine grid resolution Uniform grid

20. Preprocess scene Find bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell Uniform grid

21. Preprocess scene Find bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell Check that object overlaps cell (expensive!) Uniform grid

22. Preprocess scene Traverse grid 3D line = 3D-DDA (Digital Differential Analyzer) Uniform grid traversal naive DDA

23. octree Octree

24. K-d tree A A Leaf nodes correspond to unique regions in space

25. K-d tree A B A Leaf nodes correspond to unique regions in space

26. K-d tree A B B A Leaf nodes correspond to unique regions in space

27. K-d tree A C B B A

28. K-d tree A C B C B A

29. K-d tree A C D B C B A

30. K-d tree A C D B C B D A

31. K-d tree A D B B C C D A Leaf nodes correspond to unique regions in space

32. K-d tree traversal A D B B C C D A Leaf nodes correspond to unique regions in space

33. BSP tree 6 5 9 7 10 8 1 11 2 4 3

34. BSP tree 6 5 1 outside ones inside ones 9 7 10 8 1 11 2 4 3

35. BSP tree 6 5 1 5 6 7 8 9 10 11 2 3 4 9 7 10 8 1 11 2 4 3

36. BSP tree 6 1 5 5 9b 9 6 7 9a 10 11a 8 9b 11b 7 10 11b 8 9a 1 11 11a 2 4 3

37. BSP tree 6 5 1 9b 9 5 2 7 10 11b 8 8 3 6 9a 1 11 9b 7 4 11a 2 4 9a 11b 3 10 11a

38. BSP tree traversal 6 5 1 9b 9 5 2 7 11b 10 11b 8 8 3 6 9a 9a 1 11 9b 7 4 11a 2 4 9a 11b point 3 10 11a

39. BSP tree traversal 6 5 1 9b 9 5 2 7 11b 10 11b 8 8 3 6 9a 9a 1 11 9b 7 4 11a 2 4 9a 11b point 3 10 11a

40. BSP tree traversal 6 5 1 9b 9 5 2 7 11b 10 11b 8 8 3 6 9a 9a 1 11 9b 7 4 11a 2 4 9a 11b point 3 10 11a

41. Classes • Primitive (in core/primitive.*) • GeometricPrimitive • InstancePrimitive • Aggregate • Three types of accelerators are provided (in accelerators/*.cpp) • GridAccel • BVHAccel • KdTreeAccel

42. Hierarchy Primitive Transformed Primitive Aggregate Geometric Primitive T Material Shape Support both Instancing and animation Store intersectable primitives, call Refine If necessary

43. Primitive class Primitive : public ReferenceCounted { <Primitive interface> const int primitiveId; static int nextprimitiveId; } class TransformedPrimitive: public Primitive { … Reference<Primitive> instance; }

44. Interface BBox WorldBound(); bool CanIntersect(); bool Intersect(const Ray &r, Intersection *in); bool IntersectP(const Ray &r); void Refine(vector<Reference<Primitive>> &refined); void FullyRefine(vector<Reference<Primitive>> &refined); AreaLight *GetAreaLight(); BSDF *GetBSDF(const DifferentialGeometry &dg, Transform &WorldToObject); BSSRDF *GetBSSRDF(DifferentialGeometry &dg, Transform &WorldToObject); geometry // updatemaxt material

45. Intersection struct Intersection { <Intersection interface> DifferentialGeometry dg; const Primitive *primitive; Transform WorldToObject, ObjectToWorld; int shapeId, primitiveId; float rayEpsilon; }; adaptively estimated primitive stores the actual intersecting primitive, hence Primitive->GetAreaLight and GetBSDF can only be called for GeometricPrimitive

46. GeometricPrimitive • represents a single shape • holds a reference to a Shape and its Material,and a pointer to an AreaLight Reference<Shape> shape; Reference<Material> material; // BRDF AreaLight *areaLight; // emittance • Most operations are forwarded to shape

47. GeometricPrimitive bool Intersect(Ray &r,Intersection *isect) { float thit, rayEpsilon; if (!shape->Intersect(r, &thit, &rayEpsilon, &isect->dg)) return false; isect->primitive = this; isect->WorldToObject = *shape->WorldToObject; isect->ObjectToWorld = *shape->ObjectToWorld; isect->shapeId = shape->shapeId; isect->primitiveId = primitiveId; isect->rayEpsilon = rayEpsilon; r.maxt = thit; return true; }

48. Object instancing 61 unique plants, 4000 individual plants, 19.5M triangles With instancing, store only 1.1M triangles, 11GB->600MB

49. TransformedPrimitive Reference<Primitive> primitive; AnimatedTransform WorldToPrimitive; Ray ray = WorldToPrimitive(r); if (!instance->Intersect(ray, isect)) return false; r.maxt = ray.maxt; isect->WorldToObject = isect->WorldToObject *WorldToInstance; for instancing and animation

50. TransformedPrimitive bool Intersect(Ray &r, Intersection *isect){ Transform w2p; WorldToPrimitive.Interpolate(r.time,&w2p); Ray ray = w2p(r); if (!primitive->Intersect(ray, isect)) return false; r.maxt = ray.maxt; isect->primitiveId = primitiveId; if (!w2p.IsIdentity()) { // Compute world-to-object transformation for instance isect->WorldToObject=isect->WorldToObject*w2p; isect->ObjectToWorld=Inverse( isect->WorldToObject); // Transform instance's differential geometry to world space Transform PrimitiveToWorld = Inverse(w2p); isect->dg.p = PrimitiveToWorld(isect->dg.p); isect->dg.nn = Normalize(PrimitiveToWorld(isect->dg.nn)); isect->dg.dpdu = PrimitiveToWorld(isect->dg.dpdu); isect->dg.dpdv = PrimitiveToWorld(isect->dg.dpdv); isect->dg.dndu = PrimitiveToWorld(isect->dg.dndu); isect->dg.dndv = PrimitiveToWorld(isect->dg.dndv); } return true; }