0

我如何设置opengl shininess float,所以我可以在着色器程序中使用它gl_FrontMaterial.shininess

我试过了glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 100f);,但亮点并没有变小,所以我猜 shinines 没有改变。

编辑: 这是我使用它的片段着色器程序:

varying vec4 varyingColor;
varying vec3 varyingNormal;
varying vec4 varyingVertex;
varying vec2 varyingTexCoord;
uniform sampler2D my_color_texture;
varying vec3 varyingEyeVec;

void main() {
    vec3 vertexPosition = (gl_ModelViewMatrix * varyingVertex).xyz;
    vec3 surfaceNormal = normalize((gl_NormalMatrix * varyingNormal).xyz);
    vec3 lightDirection = normalize(gl_LightSource[0].position.xyz - vertexPosition);
    float diffuseLightIntensity = max(0, dot(surfaceNormal, lightDirection));
    gl_FragColor.rgb = diffuseLightIntensity * varyingColor.rgb;
    gl_FragColor += gl_LightModel.ambient;
    vec3 reflectionDirection = normalize(reflect(lightDirection, surfaceNormal));
    vec3 eyeVecNormal = normalize(varyingEyeVec);
    float specular = max(0.0, dot(eyeVecNormal, reflectionDirection));
    if (diffuseLightIntensity != 0) {
        float fspecular = pow(specular, gl_FrontMaterial.shininess)*gl_LightSource[0].specular.rgb;
        gl_FragColor += fspecular;
    }
    gl_FragColor = texture2D(my_color_texture, varyingTexCoord)*gl_FragColor;
}
4

1 回答 1

5
于 2013-03-12T16:03:05.780 回答