OpenGL
-
Library with about 670 graphic commands
-
All function names begin with "gl", for example, glClear(), glBegin()
-
Graphics commands are passed to the graphics card (or more exactly to its driver) and are running on the hardware.
- OpenGL thus allows faster display of interactive 3D graphics than pure CPU programming
- The graphics commands are implemented by the graphics card driver and are therefore independent of
-
the graphics card hardware
-
the operating system
-
the employed window manager
-
-
Graphics commands are reasonably close to the hardware and sufficient to achieve the core functionality
-
Various libraries are based on OpenGL and allow programming at a higher level of abstraction
약 670개의 그래픽 명령어가 포함된 라이브러리
모든 함수명은 "gl"로 시작함. (예: glClear(), glBegin())
그래픽 명령어는 그래픽 카드로 전달되어(또는 드라이버에게 전달됨) 하드웨어에서 실행됨.
따라서 OpenGL은 순수 CPU 프로그래밍보다 인터랙티브 3D 그래픽을 더 빠르게 표시할 수 있음.
그래픽스 명령어는 그래픽 카드 드라이버에 의해 구현되므로 다음과 독립적입니다 - 그래픽 카드 하드웨어, 운영체제, 윈도우 매니저
그래픽 명령은 하드웨어에 상당히 가깝고 핵심 기능을 구현하기에 충분함.
다양한 라이브러리가 OpenGL을 기반으로 하여 보다 높은 수준의 추상화 프로그래밍을 가능하게 함.
OpenGL Version
-
Since its introduction (1992) OpenGL has been continuously extended to support new functionality of graphics cards
-
OpenGL 1.0 (1992), OpenGL 1.1 (1997), OpenGL 1.2 (1998), OpenGL 1.3 (2001), OpenGL 1.4 (2002), OpenGL 1.5 (2003)
-
OpenGL 2.0 (2004), OpenGL 2.1 (2006)
-
OpenGL 3.0 (2008), OpenGL 3.1 (2009), OpenGL 3.2 (2009), OpenGL 3.3 (2010)
-
OpenGL 4.0 (2010), OpenGL 4.1 (2010), OpenGL 4.2 (2011), OpenGL 4.3 (2012), OpenGL 4.4 (2013), OpenGL 4.5 (2014), OpenGL 4.6 (2017)
-
-
In this lecture, OpenGL 2 is used and in later chapters OpenGL version ≥ 3.1 is utilized
-
Since version 3.1 the so-called "fixed-function-pipeline" is no longer supported, which means "shaders" must always be implemented
-
This makes it difficult to get started. Therefore, this lecture uses the "fixed-function-pipeline" (OpenGL 2) up to Chapter "GLSL Shading Language"
-
OpenGL ES is a version of OpenGL with reduced functionality
-
"ES" stands for "Enbedded Subsystem"", that is, target platforms are embedded systems such as mobile phones, televisions, tablets, etc.
-
OpenGL ES 1.0 (2003): similar to OpenGL 1.3 (fixed-function-pipeline)
-
OpenGL ES 1.1 (2004): similar to OpenGL 1.5 (backwards compatible)
-
OpenGL ES 2.0 (2007): similar to OpenGL 2.0 (but no fixed-function pipeline, always shader, not backwards compatible)
-
OpenGL ES 3.0 (2012): similar to OpenGL 3.3 (no geometry shader)
-
OpenGL ES 3.1 (2014): similar to OpenGL 4.3
-
OpenGL ES 3.2 (2015): similar to OpenGL 4.3
-
-
OpenGL ES is used for hardware-assisted graphics output on many smart phones (e.g., Apple's iPhone and Android-based devices)
-
WebGL is based on OpenGL ES 2.0 (and WebGL 2.0 on OpenGL ES 3.0) and allows 3D graphics on web pages (meanwhile supported by almost all browsers)
1992년 도입 이후 OpenGL은 그래픽 카드의 새로운 기능을 지원하기 위해 지속적으로 확장되고 있음.
이 강의에서는 OpenGL 2를 사용하고 이후 장에서는 OpenGL 버전 » 3.1을 사용함.
버전 3.1에서는 '고정 기능 파이프라인'은 지원되지 않게 되었기 때문에 '쉐이더'는 항상 구현되어야 함.
이로 인해 시작하기가 어렵움. 그래서, 본 강의에서는, 「GLSL 쉐이딩 언어」까지 「고정 기능 파이프라인」(OpenGL2)을 사용함.
OpenGL ES는 OpenGL의 기능이 감소된 버전.
"ES"는 "임베디드 서브시스템"을 의미함. 즉, 타깃 플랫폼은 휴대폰, 텔레비전, 태블릿 등의 임베디드 시스템.
OpenGL ES는 많은 스마트폰(예: Apple의 iPhone이나 Android 기반의 디바이스 등)에서 하드웨어에 의한 그래픽 출력에 사용됨.
WebGL은 OpenGL ES 2.0(및 OpenGL ES 3.0의 WebGL 2.0)을 기반으로 하며 웹 페이지 상에서 3D 그래픽을 사용할 수 있음(거의 모든 브라우저에서 지원됨)
OpenGL Utility Library (GLU)
-
OpenGL Utility Library (GLU) was part of every OpenGL implementation up to version 3.0
-
GLU extends OpenGL by some functions (approx. 50) with a higher level of abstraction
-
Functions for drawing spheres, cylinders, or circles, camera functionality, texture functionality, etc.
-
In the current OpenGL versions GLU is no longer supported
OpenGL Utility Library (GLU)는 버전 3.0까지의 모든 OpenGL 구현의 일부였음.
GLU는 일부 함수(약 50개)를 더 높은 수준의 추상화로 OpenGL을 확장함.
구체, 원통 또는 원을 그리는 기능, 카메라 기능, 텍스처 기능 등.
현재 OpenGL 버전에서는 GLU가 지원되지 않음.
이 기능은 자체 코드로 구현하거나 외부 라이브러리에서 제공해야 함. (예: glm 라이브러리 참조)
C, C++ include files
- OpenGL defines its interfaces using C functions
- For GL and GLU functions
#include <GL/gl.h>
#include <GL/glu.h>
//OpenGL은 C 함수를 사용하여 인터페이스를 정의함.
- Extensions
#include <GL/glext.h>
-
Only OpenGL 3.1 functions (no fixed-function pipeline)
#include <GL3/gl3.h>
#include <GL3/gl3ext.h>
//OpenGL 3.1 기능만 제공(고정 기능 파이프라인 없음)
OpenGL Utility Toolkit (GLUT)
-
is a possible window manager for C/C++ programs
-
is not part of a standard installation and must be typically installed separately (freeglut)
-
provides the rendering context for OpenGL in which OpenGL functions can be called
-
handles mouse and keyboard input
-
provides a platform-independent interface
- is included by
#include <GL/freeglut.h>
-
(Gl/gl.h and GL/glu.h are automatically included)
표준 설치의 일부가 아니므로 일반적으로 별도로 설치해야 함.(freeglut)
OpenGL 함수를 호출할 수 있는 OpenGL 렌더링 컨텍스트를 제공함.
마우스 및 키보드 입력 처리
플랫폼에 의존하지 않는 인터페이스 제공
OpenGL Utility Toolkit (GLUT) as Window Manager
include <GL/freeglut.h> // we use glut as window manager
class Renderer {
public:
void init() {...}
void resize(int w, int h) {...}
void display() {...}
void dispose() {...}
};
// static objects and callbacks
static Renderer *renderer;
static void glutResize(int w, int h)
{
renderer->resize(w, h);
}
static void glutDisplay()
{
renderer->display();
glutSwapBuffers();
}
static void glutClose()
{
renderer->dispose();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320, 320);
glutCreateWindow("WindowTitle");
glutDisplayFunc(glutDisplay);
glutReshapeFunc(glutResize);
glutCloseFunc(glutClose);
renderer = new Renderer;
renderer->init();
glutMainLoop();
}
① 'Renderer' 클래스 : OpenGL을 사용하여 그래픽을 렌더링하는 클래스임. 'init', 'resize', 'display', 'dispose' 메소드가 포함되어 있음.
② 'glutResize' 함수 : OpenGL 창의 크기가 변경될 때 호출되는 콜백 함수. 이 함수는 Renderer 클래스의 'resize' 메소드를 호출함. 새로 들어온 w, h로 renderer을 다시 꾸려라
③ 'glutDisplay'함수 : OpenGL 창이 다시 그려질 때 호출되는 콜백 함수. 이 함수는 Renderer 클래스의 'display' 메소드를 호출하고, 'glutSwapBuffers' 함수를 호출하여 화면을 업데이트.
④ 'glutClose' 함수 : OpenGL 창이 닫힐 때 호출되는 콜백 함수. 이 함수는 Renderer 클래스의 'dispose' 메소드를 호출함. 창을 닫아버리면 메모리에 쓰고 있던 것을 종료시켜라
⑤ 'main' 함수 : 프로그램의 진입점. 'glutInit', 'glutInitDisplayMode', 'glutInitWindowPosition', 'glutInitWindowSize', 'glutCreateWindow' 함수를 사용하여 OpenGL 창을 생성하고, 'glutDisplayFunc', 'glutReshapeFunc', 'glutCloseFunc' 함수를 사용하여 각각의 콜백 함수를 등록함. renderer 객체를 생성하고, 'init' 메소드를 호출. 마지막으로 'glutMainLoop' 함수를 호출하여 OpenGL 이벤트 루프를 실행함.
glutDisplayFunction : display 이벤트가 발생했을 때 불러일으킬 함수 넣기
glutReshapeFunc : 창 사이즈가 달라지면 괄호 안의 함수를 불러라. 함수가 실제로 실행되는 것이 아니라 함수를 연결해주는 것
glutMainLoop : 윈도우 프로그램의 특징 - 사용자의 이벤트를 계속 기다림.
The first OpenGL program : Drawing a Triangle
class Renderer {
public:
void init() {}
void resize(int w, int h) { glViewport(0, 0, w, h); }
void display() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f); // vertex on the left
glVertex3f( 0.5f, -0.5f, 0.0f); // vertex on the right
glVertex3f( 0.0f, 0.5f, 0.0f); // vertex at the top of the triangle
glEnd();
}
void dispose() {}
};
- 위 코드는 Renderer 클래스의 멤버 함수로 init, resize, display, dispose가 선언되어 있음. 이 함수들은 그래픽 렌더링을 위해 사용되며, OpenGL 라이브러리를 이용하여 그래픽을 그리게 됨.
- init 함수 : OpenGL 라이브러리를 초기화하고 필요한 설정을 하기 위한 함수. 이 예제에서는 아무런 설정이 없이 빈 함수가 선언되어 있음.
- resize 함수 : 창의 크기가 변경될 때마다 호출되는 함수. 이 함수에서는 OpenGL 뷰포트(Viewport)를 설정해주는데, 뷰포트는 창의 크기와 OpenGL 좌표계 사이의 매핑을 담당. 즉, resize 함수에서는 창의 크기에 따라 OpenGL 좌표계를 재조정하는 작업을 수행.
- display 함수 : 실제로 그래픽을 그리는 함수. 이 함수에서는 OpenGL 함수들을 사용하여 그래픽을 그림. 먼저 glClearColor 함수를 사용하여 배경색을 검은색으로 지정하고, glClear 함수를 사용하여 화면을 지움. 그리고 glLoadIdentity 함수를 사용하여 모델뷰 행렬을 초기화하고, glOrtho 함수를 사용하여 2D 좌표계를 설정. 마지막으로 glColor3f 함수를 사용하여 색을 지정하고, glBegin 함수를 사용하여 그리기 명령을 시작하고, glEnd 함수로 그리기 명령을 끝냄. 이 예제에서는 삼각형을 그리도록 작성되어 있음.
- dispose 함수 : 그래픽을 그리는 작업이 끝나면 호출되는 함수. 이 함수에서는 OpenGL 자원을 해제하고, 필요한 정리 작업을 수행. 이 예제에서는 아무런 정리 작업이 없이 빈 함수가 선언되어 있음.
**전체 코드**
#include <GL/freeglut.h> // we use glut here as window manager
#include <iostream>
using namespace std;
class Renderer {
public:
void init() {}
void resize(int w, int h) {
glViewport(0, 0, w, h);
}
void display() {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f); // vertex on the left
glVertex3f(0.5f, -0.5f, 0.0f); // vertex on the right
glVertex3f(0.0f, 0.5f, 0.0f); // vertex at the top of the triangle
glEnd();
}
void dispose() { }
};
//this is a static pointer to a Renderer used in the glut callback functions
static Renderer *renderer;
//glut static callbacks start
static void glutResize(int w, int h) {
renderer->resize(w, h);
}
static void glutDisplay() {
renderer->display();
glutSwapBuffers();
}
static void glutClose() {
renderer->dispose();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320, 320);
glutCreateWindow("GlutFirstTriangle");
glutDisplayFunc(glutDisplay);
glutReshapeFunc(glutResize);
glutCloseFunc(glutClose);
renderer = new Renderer;
renderer->init();
glutMainLoop();
}
- 헤더파일 include : OpenGL 함수를 사용하기 위해 필요한 헤더파일과 C++의 표준 입출력 함수들을 사용하기 위해 iostream 헤더파일을 include.
- Renderer 클래스 정의 : Renderer 클래스는 OpenGL을 사용하여 그래픽을 그리는데 필요한 함수들을 정의함. init() 함수는 초기화 함수, resize() 함수는 화면 크기 조정 함수, display() 함수는 그래픽 그리기 함수, dispose() 함수는 마무리 함수로 사용됨.
- Renderer 클래스의 객체를 생성하고 초기화함.
- glut 콜백 함수 정의 : OpenGL을 사용하여 그래픽을 그리기 위해서는 GLUT 콜백 함수를 정의해야 함. 이 코드에서는 resize(), display(), dispose() 함수를 정의한 Renderer 클래스의 멤버 함수를 호출하기 위해 각 콜백 함수를 정의하고 있음.
- 메인 함수에서 윈도우 생성과 콜백 함수 등록 :
OpenGL as a State Machine
-
While drawing, OpenGL behaves like a state machine, where the current state influences the output
-
For example, the instruction glColor(...) sets the current drawing color
-
This state remains active until it is changed by another graphics command, e.g, until the next call of glColor(...)
-
OpenGL can push certain combinations of states by glPushAttrib() onto a stack and later re-active them by popping them from the stack with glPopAttrib()
이는 OpenGL이 상태 기계(state machine)로 작동한다는 것을 의미함.. 즉, 현재 상태가 출력에 영향을 미침
예를 들어 glColor(...)명령은 현재 도면 색상을 설정함.
이 상태는 다른 그래픽 명령에 의해 변경될 때까지 활성화되어 있음. (예 : glColor(...)의 다음 호출까지)
OpenGL은 GlPushAttribution()을 통해 특정 상태의 조합을 스택에 저장하고 나중에 glPopAttribution()를 사용하여 스택에서 꺼내 다시 활성화할 수 있음. 이를 통해 미리 저장된 상태를 쉽게 재사용할 수 있음.
OpenGL은 state machine을 사용하여 현재 상태에 대한 정보를 갖고 있음.
디폴트 값이 내가 원하는 것이 아니면 지정을 해야 함.
... // draw something here
glPushAttrib(GL_LINE_BIT);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_LINE_STIPPLE);
glPushAttrib(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
glDisable(GL_DITHER); ... // drawing something special here
glPopAttrib(); // restore GL_COLOR_BUFFER_BIT
glPopAttrib(); // restore GL_LINE_BIT
... // draw more here
- 위 코드는 OpenGL을 사용하여 렌더링할 때 그래픽 상태를 변경하는 방법을 보여줌. OpenGL은 상태 기계로 작동하며, 현재 상태를 출력에 영향을 미침.
- glPushAttrib(GL_LINE_BIT) : 현재 라인 상태를 스택에 저장
- glEnable(GL_LINE_SMOOTH), glEnable(GL_LINE_STIPPLE) : 스택에 저장된 현재 라인 상태를 변경
- glPushAttrib(GL_COLOR_BUFFER_BIT) : 현재 색 버퍼 상태를 스택에 저장
- glEnable(GL_BLEND), glDisable(GL_DITHER) : 스택에 저장된 현재 색 버퍼 상태를 변경
그 다음은 특별한 그래픽을 그리기 위한 코드임.
- glPopAttrib() : 스택에서 저장된 상태를 다시 복원. glPushAttrib()가 호출될 때마다 호출해야 하며, 스택에 저장된 상태를 마지막 호출된 glPushAttrib()와 반대로 역순으로 복원. colo는 디폴트 값으로 되고, 선 설정은 변화없다
- glPopAttrib() : 호출된 두 번째 glPushAttrib()에서 저장된 현재 색 버퍼 상태를 복원한 후 첫 번째 glPushAttrib()에서 저장된 현재 라인 상태를 복원함. 선 설정도 디폴트 값이 됨.
따라서 이 코드는 OpenGL을 사용하여 그래픽 상태를 변경하고 복원하는 방법을 보여줌. 이 기술을 사용하면 특정한 그래픽 요소에 대한 상태를 쉽게 변경하고, 이전 상태로 복원할 수 있음.
OpenGL Pipeline
Framebuffer
-
The framebuffer is the "canvas" on which OpenGL draws
-
The framebuffer is a raster graphics, i.e., it has a certain width and height and contains pixels that are arranged on a fixed grid
-
Later, we will learn that OpenGL can draw in multiple attached framebuffers at the same time
프레임 버퍼는 OpenGL이 그리는 "캔버스"임.
프레임 버퍼는 일정 폭과 높이를 가지며 고정 그리드 상에 배열된 픽셀을 포함하는 래스터 그래픽임.
나중에 OpenGL이 여러 개의 연결된 프레임 버퍼를 동시에 가져올 수 있다는 것을 알게 될 것임.
Vertex Data
-
A vertex is a coordinate point of graphic object, such as a line, triangle, or polygon
-
With glVertex(...) the vertices are passed individually
glBegin(GL_TRIANGLES);
glVertex3f(-0.5f, -0.5f, 0.0f); // vertex on the left
glVertex3f( 0.5f, -0.5f, 0.0f); // vertex on the right
glVertex3f( 0.0f, 0.5f, 0.0f); // vertex at the top of the triangle
glEnd();
-
Later in this lecture, we will get to know techniques that will allow us to pass large memory blocks containing vertex data to the OpenGL pipeline
- 이 코드는 삼각형을 그리는 코드임. 'glBegin(GL_TRIANGLES)'으로 시작되며, 이후 각각의 꼭짓점 좌표를 'glVertex3f(...)'로 전달함. 각 좌표는 세 개의 float 값으로 이루어져 있음. 마지막으로 'glEnd()'로 종료함.
- 위 코드에서는 삼각형을 그리기 위해 세 개의 꼭짓점 좌표를 지정함. 첫 번째 좌표는 (-0.5, -0.5, 0.0)으로, 이는 삼각형의 좌측 하단에 위치함. 두 번째 좌표는 (0.5, -0.5, 0.0)으로, 이는 삼각형의 우측 하단에 위치함. 마지막으로 세 번째 좌표는 (0.0, 0.5, 0.0)으로, 이는 삼각형의 상단 중앙에 위치함.
- 삼각형을 그리기 위해서는 세 개의 꼭짓점 좌표가 필요함. 이 코드에서는 이 세 개의 꼭짓점 좌표를 'glVertex3f(...)' 함수로 전달하고, 'glBegin(GL_TRIANGLES)'과 'glEnd()' 사이에 위치시켜 삼각형을 그리는 것.
정점은 선, 삼각형, 다각형 등 그래픽 객체의 좌표점
glVertex(...)를 사용하여 각각의 정점 전달할 수 있음.
이 강의 후반부에서는 정점 데이터를 포함한 대용량 메모리 블록을 OpenGL 파이프라인에 전달하는 기술에 대해 설명함.
정점 데이터 = 좌표 값
Per-Vertex Operations
- In this step, a series of operations is performed for each vertex
-
When using the fixed-function pipeline these comprise, for example,
-
The transformation from the global world-coordinate system in the camera coordinate system and projection in the camera image plane
-
Generation of normals or texture coordinates and their transformation
-
Calculation of a vertex color for a given lighting
-
-
When using shaders, this step is implemented by means of a so-called vertex shader
이 단계에서는 각 정점마다 일련의 작업이 수행됨.
고정 함수 파이프라인을 사용할 때, 예를 들어, 이것들은 다음과 같이 구성됨
- 카메라 좌표계에서의 전역 좌표계로부터의 변환과 카메라 영상 평면에서의 투영
- 법선 또는 텍스처 좌표의 생성 및 변환
- 특정 조명의 정점 색상 계산
셰이더를 사용할 때 이 단계는 이른바 정점 셰이더를 사용하여 구현됨
Primitive Assembly & Per-Vertex Post-Processing
-
While assembling primitives the vertex data can be used in different ways. This dependents on the argument that is passed to glBegin(...)
-
Furthermore, in this step, 3D clipping operations are performed. By clipping, additional vertex points can be generated.
-
Then a perspective division is performed, which generates the perspective 2D projection of the objects
-
Hidden primitives can be removed
-
Then the 2D coordinates are scaled and/or shifted according to the selected image resolution and position
-
The generated primitives now know their 2D coordinates (real numbers) in the frame buffer and are transferred to the 2D rasterizer
프리미티브를 조립하는 동안 정점 데이터는 다양한 방법으로 사용될 수 있음.
이것은 glBegin(...)에게 전달되는 인수에 의존함.
또한 이 단계에서는 3D 클리핑 작업이 수행됨. 클리핑을 통해 추가 정점을 생성할 수 있음.
그런 다음 물체의 투시 2D 투영을 생성하는 투시 분할이 실행됨.
숨겨진 프리미티브를 제거할 수 있음.
그런 다음 선택된 이미지의 해상도와 위치에 따라 2D 좌표가 조정 및/또는 이동됨.
생성된 프리미티브는 이제 프레임 버퍼의 2D 좌표(실수)를 알고 2D 래스터라이저로 전송됨.
Pixel Data
-
OpenGL is able to process raster graphics
-
In addition, raster images are often used as textures ("color wallpaper")
-
It is also possible to use the image from the frame buffer as input for a secondary rendering pass
OpenGL은 래스터 그래픽을 처리할 수 있음
또한 래스터 이미지는 텍스처("색상 배경화면")로 사용되기도 함.
프레임 버퍼의 이미지를 보조 렌더링 경로의 입력으로 사용할 수도 있음
Pixel Operations
-
Pixel data are converted from the main memory of the computer into a particular OpenGL storage format
-
Image manipulations can be performed such as zoom in, zoom out, turn the image, manipulate color values, apply filters, etc.
-
Many of these operations are part of the fixed-function pipeline and are nowadays generally realized by texture and framebuffer objects
픽셀 데이터는 컴퓨터의 메인 메모리에서 특정 OpenGL 스토리지 형식으로 변환됨.
확대, 축소, 이미지 회전, 색상 값 조작, 필터 적용 등의 이미지 조작을 수행할 수 있음.
이러한 작업의 대부분은 고정 기능 파이프라인의 일부이며, 현재 텍스처와 프레임 버퍼 객체에 의해 일반적으로 실현되고 있음.
Texture Assembly
-
Pixel data can also be used as textures
-
Textures are stored in texture objects, which are equipped with an ID (key) and can be referenced and reused
-
That is, for generation of a texture the pixel data must be transferred only once from the computer's main memory onto the graphics card memory and stays available there
-
The graphics card hardware supports fast access to textures
픽셀 데이터는 텍스처로도 사용할 수 있음
텍스처는 텍스처 객체에 저장되며 ID(키)를 갖추고 있어 참조 및 재사용이 가능함.
즉, 텍스처를 생성하기 위해서는 픽셀 데이터를 컴퓨터의 메인 메모리에서 그래픽 카드 메모리로 한 번만 전송하고 거기서 사용 가능한 상태로 유지해야 함.
그래픽 카드 하드웨어는 텍스처에 대한 빠른 액세스를 지원함.
Rasterizer
-
The rasterizer converts the processed vertex or pixel data in so-called fragments
-
Even on modern graphics hardware (with programmable shader units) the raster conversion is still realized by dedicated hardware
-
Each fragment knows its interpolated color value, depth value, and possibly other interpolated attributes, such as its texture coordinate or surface normal
래스터라이저는 처리된 정점 또는 픽셀 데이터를 소위 fragment로 변환함.
현대의 그래픽 하드웨어(프로그래밍 가능한 셰이더 유닛 포함)에서도 래스터 변환은 여전히 전용 하드웨어에 의해 실현된다
각 조각은 보간된 색상 값, 깊이 값 및 텍스처 좌표나 표면 법선 등의 기타 보간된 속성을 인식함.
Per-Fragment Operations
-
Before the fragment data ends up as pixel values in the framebuffer, a series of operations for each fragment is performed
-
When using the fixed-function pipeline these comprise, for example,
- Texturing
- Color generation or manipulation
- Fog
-
When using shaders, this step can be implemented by means of a so-called fragment shader
-
The resulting fragment is then passed through a few more (optional) processing steps until the information reaches the framebuffer:
- Scissor-Test
- Alpha-Test
- Depth-Test
- Stencil-Test
- Blending
- Dithering
- Logical operations
프래그먼트 데이터가 프레임 버퍼의 픽셀 값으로 끝나기 전에 각 프래그먼트에 대한 일련의 작업이 수행됨.
고정 함수 파이프라인을 사용하는 경우, 이것들은 텍스처링, 컬러 생성 또는 조작 및 포그로 구성됨
셰이더를 사용할 때 이 단계는 이른바 프래그먼트 셰이더를 사용하여 구현될 수 있습니다
그런 다음 정보가 프레임 버퍼에 도달할 때까지 결과 플래그먼트는 몇 가지 (임의) 처리 절차로 더 전달됩니다:
'전공 > 컴퓨터 그래픽스' 카테고리의 다른 글
OpenGL 기본 틀 (2)_입력 모드 (0) | 2023.04.09 |
---|---|
OpenGL 기본 틀 (1)_그래픽 입력장치 (0) | 2023.04.09 |
그래픽 컬러처리(3)_컬러 모드 (0) | 2023.04.07 |
그래픽 컬러처리(2)_컬러 모델 (0) | 2023.04.07 |
그래픽 컬러처리(1)_컬러 이론 (0) | 2023.04.06 |
댓글