-
Notifications
You must be signed in to change notification settings - Fork 13
[Note] Program 2.2 _OpenGL pipeline
Juhwi Eden Kim edited this page Oct 15, 2019
·
1 revision
- Tessellation : OpenGL 4.0은 삼각형들을 (주로 그리드 형태로) 생성, 조작하는 tessellator를 제공
- Tessellation stage는 프로그래머가 모델 전체에 모든 정점에 동시에 접근할 수 있게 해줌
- Tessellation Shader
- vertex processing -> primitive (triangle) processing
- Tessellation (computer graphics)
- primitive assembly : geometry 단계에 오기 전에 파이프라인은 정점(vertex)들을 삼각형으로 그룹핑
- Geometry Shader : per-primitive 프로세싱, 프로그래머가 위에서 그룹핑된 모든 삼각형의 세 정점에 접근할 수 있게 해줌, C++에서 버퍼를 통해 전송되는 모든 임의 모델 정점 액세스 권한 제공
- Geometric primitive
- What is the exact difference between tessellation shader and geometry shader?
- raster : 2D 모니터 구성요소, 픽셀의 직사각형 배열
- Rasterization : 개체의 primitive를 fragment로 변환
- interpolating : 래스터화의 시작, 삼각형의 3 정점 사이를 매움 => wireframe rendering
-
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
: option for wireframe - 위 코드 삽입하지 않거나 GL_FILL (GL_LINE 대신) => full rasterization
- Fragment Shader : 픽셀의 출력 색상을 해당 위치에 놓음 (gl_Position -> gl_FragCoord), 각각의 픽셀 색 지정
- Pixel Operations : hidden surface removal, HSR
- 오픈지엘은 칼라 버퍼와 깊이 버퍼 (z-buffer) 를 제공
- fragment shader의 pixel color는 color buffer에 저장됨
- HSR (z-buffer algorithm) : scene이 렌더되기 전에, 깊이 버퍼는 최대 깊이 값으로 채워짐 -> fragment shader에 의해 pixel color가 출력되면 뷰어로 부터의 거리 계산 -> 계산된 거리가 해당 픽셀의 깊이 버퍼에 저장된 거리보다 짧으면 픽셀 칼라가 color buffer의 color 대신함, 계산된 거리를 깊이 버퍼에 저장 -> 더 길면 픽셀 삭제 (숨겨진 표면이 삭제됨)
- z-buffer algorithm :
Color[][]colorBuf = new Color [pixelRows][pixelCols];
double[][]depthBuf = new double [pixelRows][pixesCols];
for (each row and column) // initialize color and depth buffers
{ colorBuf[row][col] = backgroundColor;
depthBuf[row][col] = far away;
}
for (each shape) // update buffers when new pixel is closer
{ for (each pixel in the shape)
{ if (depth at pixel < depthBufvalue)
{ depthBuf[pixel.row][pixel.col] = depth at pixel;
colorBuf[pixel.row][pixel.col] = color at pixel;
} } }
return colorBuf;