HW6

quad(정점이 4개) vs grid(100개의 quad)

-Gouraud Shading (PerVertexShading)

-Phong Shading (PerPixelShading)

-Multiple Lighting (MPerPixelShading)

차이점을 비교해본다.

lighting

사용자 삽입 이미지
Ambient/Diffuse/Specular (From left to right: diffuse; ambient; diffuse + ambient; diffuse+ambient+specular) from lighthouse3d.com

사용자 삽입 이미지Light sources (From left to right: directional; point; and spotlights) from lighthouse3d.com

z-fighting

Z-fighting, also called stitching, is a phenomenon in 3D rendering that occurs when two or more primitives have similar values in the z-buffer.  This problem is usually caused by limited sub-pixel precision and floating point and fixed point round-off errorshttps://en.wikipedia.org/wiki/Z-fighting

 

Comparison of depth precision

There is very high precision at the near plane, but very little precision at the far plane. If the range [-n, -f] is getting larger, it causes a depth precision problem (z-fighting); a small change of ze around the far plane does not affect on zn value. The distance between n and f should be short as possible to minimize the depth buffer precision problem.

http://www.songho.ca/opengl/gl_projectionmatrix.html

 

Camera & View Matrix

lab10-GeometryPositionColorOrthoPerspective

lab10-GeometryPositionColorOrientationCamera

Perspective & Orthogonal Projection Matrix

Projection = glm::perspective(g_fovy, g_aspect, g_zNear, g_zFar);

Projection = glm::ortho(-5.0f, 5.0f, -5.0f, 5.0f, g_zNear, g_zFar);

 

Camera & View Matrix

camera

camera class를 사용하여 x/y/x축 카메라의 위치이동과 x/y/x축 카메라의 방향이동
F1&F2 – x축 카메라 위치이동
F3&F4 – y축 카메라 위치이동
F5&F6 – z축 카메라 위치이동
F7&F8 – x축 카메라 방향이동 (PITCH)
F9&F10 – y축 카메라 방향이동 (YAW)
HOME&END – z축 카메라 방향이동 (ROLL)

// main.cpp ——————————————
Camera camera1(FLY);void init( void )
{
// 중간생략..
View = camera1.lookAt(g_eye, g_at, g_up);}void display( void )
{// 중간생략..
View = camera1.View();}void specialkey(int key, int x, int y)
{
if (key == GLUT_KEY_F1)   // x-movement
camera1.strafe(0.5);
else if (key == GLUT_KEY_F2)
camera1.strafe(-0.5);
else if (key == GLUT_KEY_F3) // y-movement
camera1.fly(0.5);
else if (key == GLUT_KEY_F4)
camera1.fly(-0.5);
else if (key == GLUT_KEY_F5) // z-movement
camera1.walk(0.5);
else if (key == GLUT_KEY_F6)
camera1.walk(-0.5);
else if (key == GLUT_KEY_F7) // yaw (by y-axis)
camera1.yaw(2.5);
else if (key == GLUT_KEY_F8)
camera1.yaw(-2.5);
else if (key == GLUT_KEY_F9) // pitch (by x-axis)
camera1.pitch(2.5);
else if (key == GLUT_KEY_F10)
camera1.pitch(-2.5);
else if (key == GLUT_KEY_HOME) // roll (by z-axis)
camera1.roll(2.5);
else if (key == GLUT_KEY_END)
camera1.roll(-2.5);
else if (key == GLUT_KEY_LEFT) // same as town
camera1.yaw(2.5);
else if (key == GLUT_KEY_RIGHT)
camera1.yaw(-2.5);
else if (key == GLUT_KEY_UP)
camera1.walk(0.5);
else if (key == GLUT_KEY_DOWN)
camera1.walk(-0.5);
glutPostRedisplay();
}

http://dis.dankook.ac.kr/lectures/cg12/entry/OpenGL-Camera