PDA

View Full Version : Shiness formula

grigorym
05-18-2002, 09:16 AM
Hi!
What formula does OpenGL use to calculate the specular intensity of a vertex?
I thought it is ks*ls*(r,v)^Shiness , where:
ks - specular reflectace of current material;
ls - specular intensuty of the light;
r - vector of the ideal reflectance;
v - vector from the vertex to the eye;
(r,v) - scalar product of vectors r and v;
Shiness - the GL_SHININESS paramenter i've passed...

But when i made my own rendering functions using these formulas, i got another result...

When i pass 1 as GL_SHININESS, the sphere i make with auxSolidSphere(20) is almost fully rendered with maximum intensity, only near the borders of the sphere intensity starts falling down, while using the formula i've described earlier, the spot of light is less greatly...

Can someone clear this thing out for me?

Grigory

mikael_aronsson
05-18-2002, 09:42 AM
Hi !

I don't know, but I think you will find it in the spec:
http://www.opengl.org/developers/documentation/specs.html

Mikael

grigorym
05-18-2002, 11:11 AM
Hi!
I've found a formula, that OpenGL uses... Simply speaking, instead of
ks*ls*(r,v)^Shiness , where:
ks - specular reflectace of current material;
ls - specular intensuty of the light;
r - vector of the ideal reflectance;
v - vector from the vertex to the eye;
(r,v) - scalar product of vectors r and v;
Shiness - the GL_SHININESS paramenter i've passed...

it uses

ks*ls*(n,l_plus_v)^Shiness , where:
ks - specular reflectace of current material;
ls - specular intensuty of the light;
n - normal vector of the vertex;
l_plus_v - sum of vectors l (from vertex to light) and v (from the vertex to the eye);

It's a little bit siplier, but strictly speaking, it's not correct.

harsman
05-19-2002, 12:26 AM
Sure it's "correct". Both ways are just hacks anyway. OpenGL uses blinn specular, also called half angle specular, which doesn't give identical highlights with the same specular power. It has a computational advantage in certain cases though. You're using Phong specular, which is a slightly different variant of the same thing. Google for phong and blinn specular and I'm sure you'll find lots of links on this. Or you could look here: http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00003337&forum=3dtheory&id=-1