# Surface Area Heuristic

5 replies to this topic

### #1chhenning

New Member

• Members
• 9 posts

Posted 10 November 2009 - 10:08 PM

Hi there, I have a question regarding the surface area heuristic ( SAH ) mentioned here:

http://www.devmaster...eries/part7.php

It says that the surface area is calculated as:

area = 2 * width * height * depth

But when I look at the provided source code it much different. Although, probably not incorrect. Here it's:

real SAV = 0.5f / (a_Box.w() * a_Box.d() + a_Box.w() * a_Box.h() + a_Box.d() * a_Box.h());

Did Jacco forgot to update is article or is the change based on some optimization?

Thanks,
Christian

### #2poita

Senior Member

• Members
• 322 posts

Posted 11 November 2009 - 12:23 AM

Well the first calculation for surface area is obviously false as that's clearly calculating the volume and doubling it.

The second formula appears to be calculating the inverse surface area.

w=width, h=height, d=depth

Surface area
= 2 * (wh + wd + hd)

Inv. surface area
= 1 / (2 * (wh + wd + hd))
= 0.5 / (wh + wd + hd)

The inverse surface area is more useful as you can just multiply by it to divide by the surface area. As you should know, dividing is quite significantly more expensive than multiplying, so you'll often see people storing inverses for performance reasons.

### #3roel

Senior Member

• Members
• 698 posts

Posted 11 November 2009 - 08:31 AM

http://ompf.org/foru...4&t=1377#p14684

### #4chhenning

New Member

• Members
• 9 posts

Posted 11 November 2009 - 04:57 PM

Thanks guys that cleared it up for me.

### #5gloVA10

New Member

• Members
• 4 posts

Posted 21 January 2010 - 04:24 PM

Hello, im a bit confused about what are
Ctraversal and Cintersect in the article that you speak of. Any hints??
thx

### #6Reedbeta

DevMaster Staff

• 5310 posts
• LocationSanta Clara, CA

Posted 21 January 2010 - 05:15 PM

They are heuristic "cost" values that you can tune to get the best performing tree. Ctraversal is the cost of splitting a node into child nodes and Cintersect is the cost of computing a ray-triangle intersection. The ratio of the two controls how deep the tree gets. The idea is to stop splitting nodes when it would be more expensive to do so than just to intersect all the triangles in that node.
reedbeta.com - developer blog, OpenGL demos, and other projects

#### 2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users