Harlock
February 13, 2015, 1:11pm
1
Hello,
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 ?
regards
nehon
February 13, 2015, 1:51pm
2
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.
nehon
February 13, 2015, 2:43pm
5
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
nehon
February 13, 2015, 3:20pm
7
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);
1 Like
nehon
February 13, 2015, 5:08pm
9
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.
nehon
February 13, 2015, 6:14pm
10
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.