'glNormal'에 해당되는 글 1건

  1. 2011.10.18 glNormal()
Programming/openGL2011. 10. 18. 23:14
glNormal()은 점이나 면에 대해서 법선 벡터를 정하는 함수이다.
이러한 법선 벡터는 빛의 반사를 계산하는데 쓰이는데 설정하지 않았을 경우 기본값은 (0,0,1)로 지정이 된다.
nomalize는 단위벡터로 입력을 받는 기능인데 기본적으로 꺼져 있으나 과도하게 큰 값이 들어가면
흰색이나 검은색으로 보이기도 하니, 되도록이면 평준화 시켜서 사용하는 것이 좋을듯 하다.

void glNormal3b( GLbyte   nx,  GLbyte   ny,  GLbyte   nz);
void glNormal3d( GLdouble  nx,  GLdouble ny,  GLdouble  nz);
void glNormal3f( GLfloat   nx,  GLfloat   ny,  GLfloat   nz);
void glNormal3i( GLint   nx,  GLint   ny,  GLint   nz);
void glNormal3s( GLshort   nx,  GLshort   ny,  GLshort   nz);

void glNormal3bv( const GLbyte *   v);
void glNormal3dv( const GLdouble *   v);
void glNormal3fv( const GLfloat *   v);
void glNormal3iv( const GLint *   v);
void glNormal3sv( const GLshort *   v);

nx, ny, nz
Specify the x, y, and z coordinates of the new current normal.
The initial value of the current normal is the unit vector, (0, 0, 1).

Description

The current normal is set to the given coordinates whenever glNormal is issued. Byte, short, or integer arguments are converted to floating-point format with a linear mapping that maps the most positive representable integer value to 1.0 and the most negative representable integer value to -1.0 .

Normals specified with glNormal need not have unit length. If GL_NORMALIZE is enabled, then normals of any length specified with glNormal are normalized after transformation. If GL_RESCALE_NORMAL is enabled, normals are scaled by a scaling factor derived from the modelview matrix. GL_RESCALE_NORMAL requires that the originally specified normals were of unit length, and that the modelview matrix contain only uniform scales for proper results. To enable and disable normalization, call glEnable and glDisable with either GL_NORMALIZE or GL_RESCALE_NORMAL. Normalization is initially disabled.
 
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glNormal.xml

glNormal()은 쉐이더와 조명의 영향을 받는다.
glEnable(GL_LIGHTING)
glEnable(GL_NORMALIZE)

GL_LIGHTi
If enabled, include light i in the evaluation of the lighting equation. See glLightModel and glLight.

GL_LIGHTING
If enabled and no vertex shader is active, use the current lighting parameters to compute the vertex color or index. Otherwise, simply associate the current color or index with each vertex. See glMaterial, glLightModel, and glLight.

GL_NORMALIZE
If enabled and no vertex shader is active, normal vectors are normalized to unit length after transformation and before lighting. This method is generally less efficient than GL_RESCALE_NORMAL. See glNormal and glNormalPointer.
[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glEnable.xml

glShadeModel(GL_FLAT)
glShadeModel(GL_SMOOTH)

[링크 : http://www.opengl.org/sdk/docs/man/xhtml/glShadeModel.xml

[링크 : http://www.codeguru.com/cpp/g-m/opengl/article.php/c2681]
2011/10/13 - [이론 관련/3D 그래픽 관련] - vertex normal - 버텍스 노말

'Programming > openGL' 카테고리의 다른 글

GLSL 관련 링크  (0) 2011.11.12
gluUnProject / glRenderMode(GL_SELECT)  (0) 2011.10.19
glut Menu 관련 함수들  (0) 2011.10.10
glutAttachMenu()의 Linux용 버그  (2) 2011.10.10
GLUT에서 더블클릭은 음..  (0) 2011.10.10
Posted by 구차니