Unity's Rendering Pipeline

Unity’s Rendering Pipeline

Shaders define both how an object looks by itself (its material properties) and how it reacts to the light. Because lighting calculations must be built into the shader, and there are many possible light & shadow types, writing quality shaders that “just work” would be an involved task. To make it easier, Unity 3 introduces Surface Shaders, where all the lighting, shadowing, lightmapping, forward vs. deferred lighting things are taken care of automatically.

This document describes the pecularities of Unity’s lighting & rendering pipeline and what happens behind the scenes of Surface Shaders.

Rendering Paths

How lighting is applied and which Passes of the shader are used depends on which Rendering Path is used. Each pass in a shader communicates its lighting type via Pass Tags.

Deferred Lighting path

PrepassBase pass renders normals & specular exponent; PrepassFinal pass renders final color by combining textures, lighting & emissive material properties. All regular in-scene lighting is done separately in screen-space. See Deferred Lighting for details.

Forward Rendering path

ForwardBase pass renders ambient, lightmaps, main directional light and not important (vertex/SH) lights at once. ForwardAdd pass is used for any additive per-pixel lights; one invocation per object illuminated by such light is done. See Forward Rendering for details.

Vertex Lit Rendering path

Since vertex lighting is most often used on platforms that do not support programmable shaders, Unity can’t create multiple shader permutations internally to handle lightmapped vs. non-lightmapped cases. So to handle lightmapped and non-lightmapped objects, multiple passes have to be written explicitly.

  • Vertex pass is used for non-lightmapped objects. All lights are rendered at once, using a fixed function OpenGL/Direct3D lighting model (Blinn-Phong)* VertexLMRGBM pass is used for lightmapped objects, when lightmaps are RGBM encoded (this happens on most desktops and consoles). No realtime lighting is applied; pass is expected to combine textures with a lightmap.* VertexLMM pass is used for lightmapped objects, when lightmaps are double-LDR encoded (this happens on mobiles and old desktops). No realtime lighting is applied; pass is expected to combine textures with a lightmap.

유니티 렌더링 파이프라인

쉐이더는 두 개로 정의한다. 그 자신의 메터리얼 설정에 의해 어떻게 보여지는 것과 라이트에 어떻게 반응하느냐 말이다.
왜냐면 라이팅 계산은 쉐이더에서 이루어 지기 때문이다. 그리고 거기에는 많은 타입의 가능한 조명과 그림자 타입이 있다. 제대로 움직이는 퀄리티 쉐이더를 짜는건 복잡한 테스크이다. 쉽게하려면, 서페이스 쉐이더 시작을 읽어봐라. 거기엔 라이팅, 쉐도우, 라이트 맵핑. 포워드와 디퍼드 라이팅이 자동으로 관리된다.
이 문서는 서술한다 유니티의 라이팅과 렌더링 파이프라인의 특성들(pecularities:유산, 버릇) 이 서페이스 쉐이더에서 뭔 일이 일어나는지를 말이다. 

렌더링 패스 

어떻게 라이팅이 적용되고 어떤 패스가 어떤 렌더패스에 의해 작동하는지. 각 패스는 아래의 패스 테그에 딸린 라이팅 타입으로 커뮤니케이션 한다. 

디퍼드 라이팅 : 프리페스 베이스 또는 프리패스 파이널 패스를 사용한다 
포워드 라이팅 : 포워드 베이스나 포워드 에드 패스가 사용된다. 
버텍스라이트 : 버텍, 버텍스 NMRGBM이나 버텍스 LM 패스가 사용된다. 

디퍼드 렌더링 패스 
… 아래는 일단 패스

Hugo로 만듦
JimmyStack 테마 사용 중