tag:blogger.com,1999:blog-8350257063773144600.post5792832096480203245..comments2024-03-29T04:22:20.467-07:00Comments on Pete Shirley's Graphics Blog: BVH buildsPeter Shirleyhttp://www.blogger.com/profile/17871569418798062417noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8350257063773144600.post-44419496908962411822016-03-30T08:29:17.903-07:002016-03-30T08:29:17.903-07:00Longest axis is often good, but the adversarial ca...Longest axis is often good, but the adversarial cases are nasty as friedlinguini points out. But the real reason I did that was just a minimally simple version.Peter Shirleyhttps://www.blogger.com/profile/17871569418798062417noreply@blogger.comtag:blogger.com,1999:blog-8350257063773144600.post-30679500914503103562016-03-11T13:10:07.919-08:002016-03-11T13:10:07.919-08:00The longest axis isn't necessarily the best on...The longest axis isn't necessarily the best one for splitting object lists, because it does not necessarily produce more compact children. Imagine triangulating a long axis-aligned cylinder and then creating a BVH.friedlinguinihttps://www.blogger.com/profile/16254798224837016192noreply@blogger.comtag:blogger.com,1999:blog-8350257063773144600.post-79435722627300932902016-03-11T00:28:21.502-08:002016-03-11T00:28:21.502-08:00Why do you take random axis instead of longest one...Why do you take random axis instead of longest one? Koiavahttps://www.blogger.com/profile/16357247117249622367noreply@blogger.comtag:blogger.com,1999:blog-8350257063773144600.post-34229433403676264252016-03-10T10:05:31.050-08:002016-03-10T10:05:31.050-08:00I was not aware of those std:: features. Good ca...I was not aware of those std:: features. Good call!<br />Peter Shirleyhttps://www.blogger.com/profile/17871569418798062417noreply@blogger.comtag:blogger.com,1999:blog-8350257063773144600.post-1289451740164565302016-03-09T11:58:25.636-08:002016-03-09T11:58:25.636-08:00Orthogonal to nth_element/partition/qsort, you cou...Orthogonal to nth_element/partition/qsort, you could pass a lambda that captures the axis, removing the need for if/else if/else.<br /><br />You don't seem to be storing the axis in the BVH, so you might consider randomizing which box assigned to left or right (or, equivalently, randomly sorting primitives in ascending/descending order). That way you won't get pathologically bad results when casting a ray with a direction in the wrong octant.friedlinguinihttps://www.blogger.com/profile/16254798224837016192noreply@blogger.comtag:blogger.com,1999:blog-8350257063773144600.post-45420204502652946552016-03-08T20:16:28.437-08:002016-03-08T20:16:28.437-08:00instead of a full sort, I've used std::nth_ele...instead of a full sort, I've used std::nth_element, std::partition -- which can be slightly faster but also conveys what the splitting axis is doing.<br />i can't find the reference but a performance trick is to sort along the x,y,z axis once and re-use the results during top-down traversal. <br />scot.shindermanhttps://www.blogger.com/profile/03168553626114244851noreply@blogger.com