calculating specular

whats the better method of calculating specular, ive seen the two following methods used

A/ float specular_amount = dot( light, reflect( -view, bumpmap ) );
B/ float specular_amount = max( dot( half, bumpmap ), 0.0 );

i remember reading that one of them was more correct and another was an faster approximate epresentation, going on that ild say (A) was the correct method. but in testing they’re both very similar and IMO ild say (B) looks better, so anyways, in short im in my normal mindstate confusion.

cheerz ed

a) Is Phong
b) Is Blinn-Phong

(Assuming you take these values and raise them to a power)

a) is usually better as it does not suffer from issues that b) does under low tessilation.

I think a) and b) need different exponents to look the same… (Also it is a good idea to clamp the dot in a)

My version of a) is here, this is what I use. BTW specValue is taken from a specularity texture.

float specular = pow(clamp(dot(reflect(-viewVec, bump), lightVec), 0.0, 1.0), specValue);

a) is usually better as it does not suffer from issues that b) does under low tessilation.
b/ seems ok if u normalize the halfvector

I think a) and b) need different exponents to look the same
yeah ive seen that

thanks for the info (and link) anyways sqrt[-1] that sums it up

noticed this link on another forum
http://people.csail.mit.edu/wojciech/BRDFValidation/ExperimentalValidation-talk.pdf

after reading the pdf, when i said “and IMO ild say (B) looks better” in the initial question it seems as if it looks better cause it is accurate, dam now ive gotta change over from A->B

dot(R,L) is the model for a fuzzy light source reflected by a perfect mirror.

dot(N,H) is the model for a perfect point light source reflected by a fuzzy surface.

Both models are valid.

Very simple math says, that:

• suppose alpha is the angle between normal and half-vector
• suppose betta is the angle between light and reflected vector
• suppose A is the angle between normal and view-vector (due to reflection bidirection it is also equal to the angle between normal and reflected vector)
• suppose B is the angle between half-vector and view-vector (due to half-vector definition it is also equal to the angle between half-vector and light)

1st equation is very simple:
B + alpha = A (or ‘A + alpha = betta’ depending on your picture)
2nd euation is also not very different:
betta + B = alpha + A (or ‘betta + A = alpha + B’)

Solve it and you get:

betta = 2 * alpha

So, the angle for Phong specular equation is twice bigger than for Blinn’s one.
Imagine, that we have a directional light looking directly from our head (V is equal to L). We see it’s reflection only if we are quite perpendicular to the surface, as Phong says. But Blinn allows us to see more reflected light, which is not very natural for a perfect mirror, but it is natural for a micro-facet fuzzy mirrored surface.

Originally posted by zed:
b/ seems ok if u normalize the halfvector
It will still have issues. The halfvector is not a linear attribute. You’ll see it sort of bend near triangle edges if the triangles are large.