Vertex Shaders, Fragment Shaders
[ Vertex Shaders, Fragment Shaders ]
Vertex Shaders
A vertex shader is a shading program designed to replace the fixed vertex processing stage of the pipeline.
Vertex Shader는 파이프라인의 고정된 vertex processing 단계를 대체하도록 설계된 셰이딩 프로그램입니다.
It will be executed on every vertex sent into the pipeline, and is responsible for producing all the information needed by later stages in the pipeline; minimally, it must output the vertex itself, transformed into clip space by the projection and modelview matrices.
파이프라인으로 보내지는 모든 vertex에서 실행되며 파이프라인의 이후 단계에서 필요한 모든 정보를 생성하고, 최소한 projection 및 model-view 매트릭스에 의해 clip space로 변환된 vertex 자체를 출력해야 합니다.
Clip space is the coordinate space used throughout the rest of the OpenGL pipeline. All vertices must be transformed into this space before they are used.
Clip space는 나머지 OpenGL 파이프라인 전체에서 사용되는 좌표 공간입니다. 모든 버텍스는 사용하기 전에 이 공간으로 변환되어야 합니다.
Beyond this basic functionality, a vertex shader can also associate a color with the vertex, can generate or transform texture coordinates for later use in the pipeline, and can even use lighting information and surface normals at the vertex.
이러한 기본 기능 외에도 vertex shader는 컬러를 vertex에 연결하고, 나중에 파이프라인에서 사용할 텍스처 좌표를 생성하거나 변환할 수 있으며, vertex에서 라이팅 정보 및 surface normal을 사용할 수도 있습니다.
Vertex shaders are able to access this information through the use of special built-in global variables initialized by the OpenGL implementation and pass the modified data to the rest of the pipeline through another set of global variables.
Vertex shader는 OpenGL 구현에 의해 초기화된 특별한 내장 전역 변수를 사용하여 이 정보에 액세스할 수 있고, 다른 전역 변수들을 통해 수정된 데이터를 나머지 파이프라인으로 전달할 수 있습니다.
Fragment Shaders
Like the vertex shader, a fragment shader operates on information residing in the pipeline and produces modified data for use by the rest of the pipeline’s stages.
Vertex Shader와 마찬가지로 Fragment Shader는 파이프라인에 있는 정보에서 작동하며 파이프라인의 나머지 단계에서 사용할 수 있도록 수정된 데이터를 생성합니다.
As the name implies, fragment shaders operate on the rasterized vertex and pixel information, called fragments.
이름에서 알 수 있듯이 fragment shader는 래스터화된 vertex 및 픽셀 정보, 즉 fragments라고 하는 정보에서 작동합니다.
The fragment shader will be executed once for each fragment coming through the pipeline; depending on how the primitive has been rasterized, the fragment shader may be executed many more times than the vertex shader.
Fragment Shader는 파이프라인을 통과하는 각각의 fragment에 대해 한 번씩 실행되며, primitive가 래스터화된 방식에 따라 fragment shader가 vertex shader보다 여러 번 실행될 수 있습니다.
At a minimum, a fragment shader is responsible for assigning the fragment color based on the basic color of the object. However, fragment shaders are also responsible for applying textures and performing operations such as bump mapping.
최소한, Fragment Shader는 object의 basic color를 기반으로 fragment color를 할당하는 역할을 담당합니다. 그러나 fragment shader는 텍스처를 적용하고 범프 매핑과 같은 작업을 수행하기도 합니다.
[ Reference ]
Computer Graphics with OpenGL 4th edition, Hearn, Baker