OpenGL

[OpenGL] orthographic프로젝션와 Perspective프로젝션

usingsystem 2024. 5. 8. 16:11
728x90

Orthographic Projection (직교 투영):

  • Orthographic projection은 객체를 카메라에서 동등한 비율로 투영합니다. 즉, 원근감이 없는 투영입니다.
  • 이는 3D 객체를 2D 화면에 표시할 때 크기만 변경되고 모양은 유지되는 것을 의미합니다.
  • 이는 일반적으로 2D 렌더링, CAD 응용 프로그램 또는 게임에서의 2D 스프라이트와 같은 경우에 유용합니다.
  • Orthographic projection 행렬을 만들 때는 glOrtho() 함수를 사용합니다.
void glOrthoRH(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
void glOrthoLH(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal);
  • left, right: 왼쪽 및 오른쪽 clipping plane의 x 좌표입니다.
  • bottom, top: 아래 및 위 clipping plane의 y 좌표입니다.
  • nearVal, farVal: 뷰 포트 내에서 객체가 보여지는 가까운 및 먼 clipping plane의 z 좌표입니다.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left, right, bottom, top, nearVal, farVal);
glMatrixMode(GL_MODELVIEW);

 

Perspective Projection (원근 투영):

  • Perspective projection은 객체를 원근 감각으로 투영합니다. 즉, 멀리 있는 객체는 작게 보이고 가까이 있는 객체는 크게 보입니다.
  • 이는 실제 세계의 시각적 효과를 모방하기 위해 사용됩니다.
  • 주로 3D 게임, 시뮬레이션, 가상 현실 등의 분야에서 사용됩니다.
  • Perspective projection 행렬을 만들 때는 glFrustum() 또는 gluPerspective() 함수를 사용합니다.

view frustum ( view volume)

Near plane와 Far plane 사이의 오브젝트만 랜더링 한다.

 

 

 

728x90

'OpenGL' 카테고리의 다른 글

[OpenGL] Shading과 illumination model  (0) 2024.07.01
[OpenGL] Viewport와 Scissor Box  (0) 2024.05.10
[OpenGL] LookAt Approach  (0) 2024.05.07
[OpenGL] 카메라와 뷰잉(viewing)  (0) 2024.05.03
[OpenGL] VRAM와 VBO(Vertex Buffer Objects)  (1) 2024.04.18