|
|
请问问使用 per-vertex lighting 后,为什么物体还看上去不平滑.
[VP]-----------------------------------
attribute vec4 position;
attribute vec3 normal;
varying vec4 color;
void main(void)
{
vec3 P = vec3(gl_ModelViewMatrix * position);
vec3 L = normalize((gl_LightSource[0].position.xyz)-P);
vec3 N = normalize(gl_NormalMatrix * normal);
vec3 E = normalize(-P);
vec3 H = normalize(E+L);
vec4 Idiff = vec4(0.7, 0.7, 0.7, 0.7) * max(dot(N,L), 0.0);
vec4 Ispec = vec4(0.7, 0.7, 0.7, 0.7) * pow(max(dot(N,H),0.0), 32);
color = gl_FrontLightModelProduct.sceneColor + Idiff + Ispec;
gl_Position = gl_ModelViewProjectionMatrix * position;
}
[FP]--------------------------------------
varying vec4 color;
void main (void)
{
gl_FragColor= color;
}
我试使用glShadeModel(GL_SMOOTH);,但图片看上去就不平滑,请大家指点一下.
|
|