glLightModel

Name 函数名

glLightModel — set the lighting model parameters 设置光照模式参数

----------------------------------------------------------------------------------------------------------------

C Specification C风格函数

void glLightModelf(GLenum  pname,  GLfloat  param);

void glLightModeli(GLenum  pname,  GLint  param);

Parameters 参数

pname

Specifies a single-valued lighting model parameter.GL_LIGHT_MODEL_LOCAL_VIEWER,GL_LIGHT_MODEL_COLOR_CONTROL, and GL_LIGHT_MODEL_TWO_SIDE are accepted.指定单一的光照模式参数。接受GL_LIGHT_MODEL_LOCAL_VIEWER、GL_LIGHT_MODEL_COLOR_CONTROL和 GL_LIGHT_MODEL_TWO_SIDE作为参数。
param

Specifies the value that param will be set to.设置param的值。

---------------------------------------------------------------------------------------------------------------
C Specification C风格函数

void glLightModelfv(GLenum  pname,  const GLfloat *  params);

void glLightModeliv(GLenum  pname,  const GLint *  params);

Parameters 参数

pname
Specifies a lighting model parameter.GL_LIGHT_MODEL_AMBIENT,GL_LIGHT_MODEL_COLOR_CONTROL,GL_LIGHT_MODEL_LOCAL_VIEWER, and GL_LIGHT_MODEL_TWO_SIDE are accepted.指定光照模式参数。接受GL_LIGHT_MODEL_AMBIENT、GL_LIGHT_MODEL_COLOR_CONTROL、GL_LIGHT_MODEL_LOCAL_VIEWER和GL_LIGHT_MODEL_TWO_SIDE作为参数。
params
Specifies a pointer to the value or values that params will be set to.为一个或多个参数值指定一个指针来设置它们的取值。
Description 描述
glLightModel sets the lighting model parameter.pname names a parameter and params gives the new value.There are three lighting model parameters:glLightModel设置光照模型参数。pname指定参数,params为这个参数设置一个新的值。

GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_AMBIENT
params contains four integer or floating-point values that specify the ambient RGBA intensity of the entire scene.Integer values are mapped linearly such that the most positive representable value maps to 1.0,and the most negative representable value maps to  -1.0.Floating-point values are mapped directly.Neither integer nor floating-point values are clamped.The initial ambient scene intensity is (0.2, 0.2, 0.2, 1.0).params由四个整型或浮点型值构成,它们指定了整个环境的环境光RGBA强度。整数值被线性的从最大正数映射到1.0、最大负数到-1.0。浮点型的值被直接映射。整型和浮点型的值都不是clamped的。(这个clamp怎么翻译?意思是跟给指定的值有一定的偏差?)初始的环境光强度为(0.2, 0.2, 0.2, 1.0)。
GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_COLOR_CONTROL

params must be either GL_SEPARATE_SPECULAR_COLOR or GL_SINGLE_COLOR.GL_SINGLE_COLOR specifies that a single color is generated from the lighting computation for a vertex.  GL_SEPARATE_SPECULAR_COLOR specifies that the specular color computation of lighting be stored separately from the remainder of the lighting computation.  The specular color is summed into the generated fragment's color after the application of texture mapping (if enabled).  The initial value is GL_SINGLE_COLOR.参数只能为GL_SEPARATE_SPECULAR_COLOR或者GL_SINGLE_COLOR。GL_SINGLE_COLOR表示从一个点的光照计算产生单色。GL_SEPARATE_SPECULAR_COLOR表示光照的镜面颜色计算是与剩下的光照计算分开存储的。在应用纹理贴图之后(如果启用纹理贴图的话),镜面颜色被归入以生成的颜色片段中。(这句是这么翻译么?)初始值为GL_SINGLE_COLOR。
GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_LOCAL_VIEWER
params is a single integer or floating-point value that specifies how specular reflection angles are computed.If params is 0 (or 0.0), specular reflection angles take the view direction to be parallel to and in the direction of the -z axis,regardless of the location of the vertex in eye coordinates.Otherwise, specular reflections are computed from the origin of the eye coordinate system.The initial value is 0.参数是一个整型值或者浮点型值,它表明了镜面反射角度是如何计算的。如果参数是0(或者0.0),无论视点坐标的位置,镜面参数角度都将把视觉方向设置为平行并朝向Z轴的负方向。否则,镜面反射角的计算将取决于视觉坐标系统的原点。初始值为0.
GL_LIGHT_MODEL_TWO_SIDE  GL_LIGHT_MODEL_TWO_SIDE
params is a single integer or floating-point value that specifies whether one- or two-sided lighting calculations are done for polygons.It has no effect on the lighting calculations for points,lines,or bitmaps.If params is 0 (or 0.0), one-sided lighting is specified,and only the front material parameters are used in the lighting equation.
Otherwise, two-sided lighting is specified.In this case, vertices of back-facing polygons are lighted using the back material parameters and have their normals reversed before the lighting equation is evaluated.Vertices of front-facing polygons are always lighted using the front material parameters,with no change to their normals. The initial value is 0.参数为一个整型或浮点型值,它表明了多边形是一面还是两面进行了光照计算。它对点、线、位图的光照计算没有影响。如果参数是0(或者0),将指定单面的光照,并且只有朝前面的材质参数值会在光照方程中使用。否则,会指定两面都有光照。在这种情况下,多边形反面的点将使用反面的材料参数值进行光照计算,并且在光照方程计算前它们的法线会被反转。多边形前面的点将仍旧使用前面的材料参数值进行光照计算,并且不用改面它们的法线。初始值为0。

In RGBA mode, the lighted color of a vertex is the sum of the material emission intensity,the product of the material ambient reflectance and the lighting model full-scene ambient intensity,and the contribution of each enabled light source.Each light source contributes the sum of three terms:ambient, diffuse, and specular.
The ambient light source contribution is the product of the material ambient reflectance and the light's ambient intensity.The diffuse light source contribution is the product of the material diffuse reflectance,the light's diffuse intensity,and the dot product of the vertex's normal with the normalized vector from the vertex to the light source.The specular light source contribution is the product of the material specular reflectance,the light's specular intensity,and the dot product of the normalized vertex-to-eye and vertex-to-light vectors,raised to the power of the shininess of the material.All three light source contributions are attenuated equally based on the distance from the vertex to the light source and on light source direction, spread exponent, and spread cutoff angle.All dot products are replaced with 0 if they evaluate to a negative value.在RGBA模式下,一个点的光照颜色是材料发散强度、材料环境的反射与全局环境光照强度的共同效果、每一个可用的光源的总和。每一个光源都会对环境光、散射光和镜面光产生影响。材料的环境光反射值和光源的环境光强度共同形成了环境光。发散光是由材料的反射因子、光源的反射强度、一个点相对于光源的标准化向量共同作用的结果。(这一句语法的翻译不下去了……)

The alpha component of the resulting lighted color is set to the alpha value of the material diffuse reflectance.
        
In color index mode,the value of the lighted index of a vertex ranges from the ambient to the specular values passed to glMaterial using GL_COLOR_INDEXES.Diffuse and specular coefficients,computed with a (.30, .59, .11) weighting of the lights' colors,the shininess of the material,and the same reflection and attenuation equations as in the RGBA case,determine how much above ambient the resulting index is.

Notes
GL_LIGHT_MODEL_COLOR_CONTROL is available only if the GL version is 1.2 or greater.

Errors
GL_INVALID_ENUM is generated if pname is not an accepted value.
GL_INVALID_ENUM is generated if pname is
GL_LIGHT_MODEL_COLOR_CONTROL and params is not one of
GL_SINGLE_COLOR or GL_SEPARATE_SPECULAR_COLOR.
GL_INVALID_OPERATION is generated if glLightModel is executed between the execution of glBegin and the corresponding execution of glEnd.

Associated Gets
            glGet with argument GL_LIGHT_MODEL_AMBIENT
        
            glGet with argument GL_LIGHT_MODEL_COLOR_CONTROL
        
            glGet with argument GL_LIGHT_MODEL_LOCAL_VIEWER
        
            glGet with argument GL_LIGHT_MODEL_TWO_SIDE
        
            glIsEnabled with argument GL_LIGHTING

------------------------------------------------------------------------------------

        See Also
            glLight,
            glMaterial

------------------------------------------------------------------------------------

Copyright
            Copyright © 1991-2006
            Silicon Graphics, Inc. This document is licensed under the SGI
            Free Software B License. For details, see
            http://oss.sgi.com/projects/FreeB/.
       

展开阅读全文

没有更多推荐了,返回首页