WinCNT

Shader 본문

Shader

색을 칠하는 부분

Renderer의 핵심적인 부분

 

Rendering-Pipeline의 프로그램 가능한 부분

 

그래픽스 카드들이 지원하는 버텍스와 폴리곤으로 3D를 표현하는

3D 기반에서는 특히 Vertext Shader와 Pixel Shader가 가장 중요하다

(복셀 기반 3D 등은 알아서 만들어야 한다)

 

Shader 버전별 차이

DX와 Feature Level은 완전히 일치하진 않음

 

DX9 - Moedl 2.0, 3.0

20년 정도 대세였던 모델(와우)

 

DX10 - Model 4.0

흥행 실패

 

DX11 - Shader Model 5.0

DX9의 불합리한 부분이 많이 개선되고 흥행에도 성공함

 

HLSL(Hight-Level Shader Language)

C/C++과 비슷한 문법

이전에는 어셈블리로 Shader를 코딩했지만

HLSL의 등장으로 Shader 코딩이 쉬워졌다

 

MSDN에 가장 정확한 정보가 있다

(당연히 MS가 만들었으니까)

하지만 MSDN은 맥락은 없으니 Dictionary같은 느낌으로 사용하자

 

주의점 / 이슈

MSDN 쉐이더 컴파일

FX(Effect) 사용 여부 등등

 

일치해야 하는 것들

정점 구조체

Input Layout(IA Stage)

Shader Semantics(의미소, 의미 체계)

VertextOut과 PixelIn

 

쉐이더 폭발(Explosion of Permutations)

조합 가능한 가짓수만큼 증가한다

따라서 어느 순간부터는 쉐이더가 엄청나게 증가하게 되는데 이걸 쉐이더 폭발이라고 한다

이를 방지하기 위해 우버 쉐이더(슈퍼 쉐이더)나 동적 쉐이더 링크 등을 사용할 수 있다

 

Semantics

MSDN을 보자

https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics

 

Semantics - Win32 apps

A semantic is a string attached to a shader input or output that conveys information about the intended use of a parameter.

docs.microsoft.com

실제로 구현할 때는 

IA Stage의 Input Layout
Vertex Buffer의 데이터 (구조체)
VS Semantics

는 일치해야 한다

 

Constant Buffer

https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-resources-buffers-intro

 

Introduction to Buffers in Direct3D 11 - Win32 apps

A buffer resource is a collection of fully typed data grouped into elements.

docs.microsoft.com

VB나 IB 외에 상수를 전달할 방법

Shader 내에서 전역 변수같은 느낌으로 사용한다

 

GPU 입장에서 상수처럼 변하지는 않는다(사실 그냥 버퍼라는 느낌)

Draw Call시에 변하지 않는 버퍼다

 

16바이트 정렬, Usage, 4096*16제한, Register 할당

 

DX11에서는 Effect 11 인터페이스로 간편하게 사용할 수 있다

(Dx12에는 Effect 프레임워크가 없어짐)

https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d11-graphics-reference-effects11-interfaces

 

Effects 11 Interfaces - Win32 apps

This section contains reference information for the component object model (COM) interfaces of the Effects 11 source.

docs.microsoft.com

 

SSS

'게임 프로그래밍(학습 내용 정리) > 3D Graphic Engine' 카테고리의 다른 글

PBR(Physically Based Rendering) - Regacy Model 복습  (0) 2022.07.13
SSAO(Screen-Space Ambient Occlusion)  (0) 2022.06.29
Deferred Rendering  (0) 2022.06.22
Subsystems  (0) 2022.06.10
개론  (0) 2022.06.08