

= pixel shader의 output인 pixel은 sequence of operation을 거친다
아래 요소들을 이용해 최종 rendering될 pixel color를 만들어준다.
1) Combination of pipeline state
2) pixel shader로부터 만들어진 pixel data
3) the contents of the render targets
4) the contents of the depth/stencil buffers
= GPU가 input 데이터를 렌더링하기 위해 어떻게 해석하고 처리해야 하는지를 결정하는 하드웨어 설정 or description

두가지 data 모두 output-merger stage에서 pixel이 그려질지 결정하는데 사용된다.
- depth data : 어떤 픽셀들이 camera에 가장 가까운지를 결정
- stencil data : 어느 pixel을 update할 것인가

Depth buffering (z-buffering)
= depth buffer를 이용해서 어떤 pixel들이 draw되어야 하는지 결정해준다.
- depth value가 output-merger stage에 오면 clamp된다.
z = min(Viewport.MaxDepth, max(Viewport.MinDepth, z)) 이용- clamping 후 depth-buffer value와 비교한다.
Depth Test
= per-sample operation / pixel마다 처리
= visible / hidden pixel들을 구분해준다
- object가 screen에 project 되면, 생성된 pixel들의 depth가 현재 depth buffer value와 비교된다
- pixel depth < stored depth value : 픽셀이 업데이트 되어야 하는 군
= pixel의 color와 depth value가 color buffer와 depth buffer를 update- pixel depth > stored depth value : invisible


ㄴ
= stencil buffer 값이 1인 pixel만 back buffer로 채운다.

Transition effect

Discarding UI area (reducing the number of fragments to be processed)

translucent(반투명 = partially tranparent) 물체 뒤에있으면 visible 해야 한다.
- 보통 depth text에서 pixel이 replace되거나 버려진다.
- 하지만 표면이 투명한 경우 pixel value가 combine되어야 한다. 단순히 교체 & 버리기로 안됨.
- output value가 render target에 찍히기 전에 모든 pixel shader output에 blending operation이 동작한다.
- : blended color -> 얘를 구하는 게 목표
- : pixel's opacity
- 들 : 우리가 정해줘야하는 factors
- c_src : color output from the pixel shader
- c_dst : color of the back buffer
- ▣ : blend operation
blending을 하지 않을 경우 c_dst는 c_src로 overwrite된다 / blending -> c get







= 새로운 애가 들어와도 Destination Pixel 값으로 유지한다
= ex) 항상 앞에 있어야 하는 UI

alpha component : pixel의 opacity 정도
Setting for alpha blending
- Source blend factor = D3D12_BLEND_SRC_ALPHA
- Destination blend factor = D3D12_BLEND_INV_SRC_ALPHA
- Blend Operator = D3D12_BLEND_OP_ADD

Back-to-Front order
z-buffering 때에는 순서와 상관없이 결과가 똑같았지만, Alpha blending은 순서가 중요하다.
if) 파란색 triangle이 먼저 rednering -> 빨간색이 뒤에 있어서 그냥 버려져 버림
= z 값이 큰 물체부터 그려야함
