ShadedTeapotCylinderSphere (with moving light source)
11.OpenGLShadedGLUT
ShadedTeapot (with different materials)
11.OpenGLMaterialTeapot
ShadedTeapotCylinderSphere (with moving light source)
11.OpenGLShadedGLUT
ShadedTeapot (with different materials)
11.OpenGLMaterialTeapot
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
lecture12-ch5
lecture11-ch5
ShadedGeometry with Multiple Lights & Material
lab11-GeometryPositionNormalMultipleLights3 (SimpleCar, SimpleSolar, SimpleRobot, SimpleMobile, SimpleCube3d, SimpleTree)
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 errors. https://en.wikipedia.org/wiki/Z-fighting
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
lab10-GeometryPositionColorOrthoPerspective
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 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)
Orthographic Projection
template <typename T> GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> ortho ( T left, T right, T bottom, T top, T zNear, T zFar ) { tmat4x4<T, defaultp> Result(1); Result[0][0] = static_cast<T>(2) / (right - left); Result[1][1] = static_cast<T>(2) / (top - bottom); Result[2][2] = - static_cast<T>(2) / (zFar - zNear); Result[3][0] = - (right + left) / (right - left); Result[3][1] = - (top + bottom) / (top - bottom); Result[3][2] = - (zFar + zNear) / (zFar - zNear); return Result; }
Perspective Projection
template <typename T> GLM_FUNC_QUALIFIER tmat4x4<T, defaultp> frustum ( T left, T right, T bottom, T top, T nearVal, T farVal ) { tmat4x4<T, defaultp> Result(0); Result[0][0] = (static_cast<T>(2) * nearVal) / (right - left); Result[1][1] = (static_cast<T>(2) * nearVal) / (top - bottom); Result[2][0] = (right + left) / (right - left); Result[2][1] = (top + bottom) / (top - bottom); Result[2][2] = -(farVal + nearVal) / (farVal - nearVal); Result[2][3] = static_cast<T>(-1); Result[3][2] = -(static_cast<T>(2) * farVal * nearVal) / (farVal - nearVal); return Result; }
http://www.songho.ca/opengl/gl_projectionmatrix.html