February 13, 2015, 1:11pm
in the JME code , I noticed blinn was implemented that way :
vec3 H = (viewdir + lightdir) * vec3(0.5);
return pow(max(tangDot(H, norm), 0.0), shiny);
compared to implementations I found on the web , I was wondering about some differences like
why mult by 0.5 ? to get a quarter vector ?
why tangDot instead of dot ?
February 13, 2015, 1:51pm
IMO that’s just wrong, H should be normalize(viewdir + lightdir)
tangDot actually returns dot unless you use Vtangents
Note that Vtangents and blinn phong has been removed from master it’s now standard phong only.
1 Is probably an attempt to get the half-angle vector:
Maybe it works IDK
February 13, 2015, 2:43pm
Yeah half vector is still a direction, so it has to be normalized…makes no real sense to multiply it by 0.5
If the incoming vectors are unit vectors I guess it works out to the same thing as normalizing (maybe, I’m to tired to work it out). So instead of calcualting sqr to get the length as in N+V/|N+V| you just do N+V/2. But no, don’t do that even if it works out to be the same
February 13, 2015, 3:20pm
Actually that’s a pretty neat optimization
I guess that’s why it’s like this.
No, it is a mistake and it doesn’t work, whoever did it (me …) is a very bad boy.
Anyways, blinn-phong should always be used which is:
vec3 H = normalize(V + L);
float HdotN = max(0.0, dot(H, N));
float spec = pow(HdotN, shininess);
February 13, 2015, 5:08pm
I’ve set lighting to standard phong which is
vec3 R = reflect(-lightdir, norm);
return pow(max(dot(R, viewdir), 0.0), shiny);
Blinn phong was what we had when LOW_QUALITY was defined and we agreed" we should remove it.
February 13, 2015, 6:14pm
OK after some talk with Kirill, we’re going to switch to blinn-phong in 3.1
It appears that we use phong since a long time, because we thought it was the other way around.