컴퓨터공학/Computer Graphics 15

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 m..

Tangent Space

노말매핑은 lighting에 차이를 주게 되는 결정적인 것이 surface normal이므로, 이런 차이를 미리 낼 수 있으니 적은 계산량에(texture 하나 더 사용)도 큰 차이를 보일 수 있다.단점으로는, 실제로는 high-frequency texture가 아니므로 그림자, 실루엣은 평면이다. Normal map을 사용하지않았다면, vertex의 normal에 대한 interpolation된 normal들을 사용하여 lighting을 적용한다.이러면 모든 interpolation된 normal들은 같은 평면내에 존재한다는 것이 보장되는 것이다. (삼각형 polygon이라면 같은 평면에 존재한다는것이 보장되므로)그런데, normal map을 사용하면 perturb된 normal들은, 각각 전부 다른 ..

Texture Mapping

[ Texture Mapping ]   [ Texture Mapping ]3차원 Object에 pattern을 mapping 하는 것pattern은 1차원, 2차원, 3차원 전부 될 수 있음.→ 주로 2D + image로 정의됨. [ Texture Space ]2차원 좌표계, 0에서 1사이 값을 가짐texture space를 구성하는 하나하나의 컬러들은 다음과 같은 component를 가질 수 있음.- RGBA (A : 알파, 투명도)- RGB- A single luminance value (흑백일 경우에 해당, 또는 intensity라고도 부름) 보통 축을 s, t, r로 부르는데, 1차원일 경우 s축만 사용하는 형식이다.1d texture pattern부터 알아보면서, 차원을 확장해 나가보자. [ 1..

Illumination Models and Surface-Rendering Methods - 3

[ Illumination Models and Surface-Rendering Methods - 3 ]  [ Polygon Rendering Methods ] Intensity calculations from an illumination model - 이전 챕터에서 배운 illumination model을 이용하여 모든 projected pixel position에서의 surface intensity를 구할 수 있다. - 또는, 몇개의 점들만 선택해서 illumination model을 적용하여 다른 surface position에서의 intensity는 근사값을 적용시킬 수 있다. 일반적으로 processing time을 줄이기 위해, OpenGL이나 DirectX같은 그래픽스 패키지들은 scan-li..

Illumination Models and Surface-Rendering Methods - 2

[ Illumination Models and Surface-Rendering Methods - 2 ] [ Surface Lighting Effects ]그래픽스에서 빛의 효과를 세가지로 분류. - Diffuse Reflection (난반사)표면이 거칠어 반사각이 표면에 따라 다 달라짐사방팔방으로 고르게 반사됨.ex) A4 용지의 경우 자세히 보면 엄청 울퉁불퉁해서 난반사가 일어나므로 보는 방향에 상관없이 동일한 밝기와 색깔이 나타남. - Specular Reflection (정반사)Highlight와 관련 있음.ex) 매끈한 구슬의 경우 광원이 닿지 않는 곳은 hightlight보다 intensity가 덜하기 때문에 상대적으로 어두워 보인다. - Ambient Light (주변광)직접적으로 반사되어 들..

Illumination Models and Surface-Rendering Methods - 1

[ Illumination Models and Surface-Rendering Methods - 1 ] Physical Approach와 Practical Approach로 나뉘는데,여기서 다루는 것은 Practical Approach인 Light Source Model에 해당한다. [ Light Sources ]광원 : 빛 에너지를 사방으로 방사하는 object화면에 그려진 Object를 실제로 볼려면 빛이 있어야한다.광원이 있어야 화면 상에 존재하는 모든 Object들이 lighting effect를 가지게 된다. [ Properties of light sources ]- Position (광원의 위치)- The color of emitted light (방사되는 광원의 색깔)- The emissio..

[Visible Surface Detection] Depth Buffer(Z-Buffer) Method

[ Visible Surface Dection - Depth Buffer(Z-Buffer) Method ] [ Depth Buffer Method ]가장 대표적이면서 자주 사용되는 image-space 방식Projection plane에서의 각 pixel position에 대응하는 surface의 Depth 값을 scene 전체에 걸쳐 비교한다.각 surface에 대해 개별적으로 수행되는데, 이전에 수행했던 surface들의 Depth를 순서와 무관하게 비교한다.여기서 Depth는 3D Viewing pipeline의 후반에 나왔던 View plane으로 부터의 depth를 의미한다.이전에 수행했던 surfaces 보다 가깝다면, surface color가 계산되고 depth와 함께 저장된다.Proces..

[Visible Surface Detection] Back-Face Detection

[ Visible Surface Detection, Back-Face Detection ] Clipping이후, view volume내에 있는 것들만 남게 되는데, viewing position으로 부터 화면에서 어떤 것들이 보일 수 있는지(visible) 결정하는 과정. 다른 말로 hidden-surface elimination, hidden-surface determination이라고도 한다. Visible-Surface Detection Alogrithms들은 2가지 방식으로 나뉜다.1) Object-space methods3차원 공간상에서 계산 2) Image-space methodsProjection plane상에 있는 각각의 pixel position에서 visibility를 결정. 대부분의 ..

[3D Viewing Pipeline] Viewport Transformation

이전의 Perspective Projection이 이루어진 뒤, Homogeneous Parameter로 나누어 실제 좌표로 변환했다.이로써 크기가 2인 Cube상의 좌표로 변환되었다.이제 마지막 단계인 Viewport Transformation이 남아있다.[ Trasnformation from the Normalized view volume to 3D screen coordinates ]크기가 2인 Cube가 화면으로 바뀌어야 하므로, Scaling이 사용된다. 변환될 Viewport의 size는 주어져 있다고 가정한다.Viewport는 전체화면일지, 창화면일지 알 수 없으므로 screen의 해상도로 바로 변환할 수 없다.변환될 Viewport의 좌표를 나타내는 xv max, xv min, yv max..

[3D Viewing Pipeline] Perspective Projection - 3

x p, y p, z p에서 아직 구하지 못한 s x, s y 그리고 s z, t z가 있다. x, y에 대한 scaling factor : s x, s y를 먼저 구해보자.Normalization되면서, 기존 크기 Width (xw max - xw min)에서 크기가 2인 Normalized View Volume으로 압축된다.그러므로 S x는 2 / (xw max - xw min)S y또한 기존 크기 Height (yw max - yw min)에서 크기가 2인 Normalized View Volume으로 압축되므로S y는 2 / (yw max - yw min)  [ Note : scaling에서 z는 고려하지 않는다. 그리고 앞선 2가지 가정으로 인해, Clipping Window의 중점은 (0, 0)..