Deferred Lighting Rendering Path Detail

Deferred Lighting Rendering Path Details

This page describes details of Deferred Lighting rendering path. For a technical overview of what Deferred Lighting is, see Deferred Lighting Approaches article.

Deferred Lighting is rendering path with the most lighting and shadow fidelity:
디퍼드 라이트는 라이트와 그림자에 적합한 렌더링 패스입니다. (특화된)

  • There’s no limit how many lights can affect any object.
  • 얼마나 많은 라이트가 오브젝트에 영향을 끼치는지 상관이 없습니다.
  • All lights are evaluated per-pixel. Which means that they all interact properly with normal maps etc.
  • 모든 라이트가 퍼 픽셀로 계산되며,이것은 그것들이 노말맵 등등과도 인터렉티브하게 작동된다는 것을 의미합니다.
  • All lights can have Cookies.
  • 모든 라이트는 쿠키를 가질 수 있습니다.
  • All lights can have Shadows.
  • 모든 라이트는 그림자를 가질 수 있습니다.

Deferred Lighting’s advantages:
디퍼드 라이팅의 장점:

  • Lighting cost is proportional to light size on screen. Does not matter how many objects it shines on. Small lights = cheap!
  • Consistency. All lighting for all lights is computed per-pixel; there are no lighting computations that break down on large triangles etc.
  • 라이팅 비용은 화면에서의 라이트 사이즈에 영향받습니다. 이것은 얼마나 많은 오브젝트가 빛나냐의 문제가 이닙니다. 작은 라이트는 = 쌉니다! 확실히 . 모든 라이트는 퍼 픽셀로 계산됩니다 ; 이것은 큰 삼각형 등등을 깨뜨리느냐에 대한 라이팅계산이 아닙니다.

Disadvantages:
단점:

  • No real anti-aliasing support.
  • 리얼 안티알리아싱이 지원되지 않습니다.
  • Deferred Lighting can’t handle semi-transparent objects. Those are rendered using Forward Rendering.
  • 반투명 오브젝트는 제어할 수 없습니다.
  • Limited lighting model support (Blinn-Phong). All lighting is computed the same way; you can’t have drastically different lighting models on different objects.
  • 제한된 라이트 모델 지원 (블린-퐁). 모든 라이트는 같은 방법으로 계산되어 버립니다. ; 당신은 각각의 오브젝트를 드라마틱한 다른 라이팅 모델로 계산시킬 수 없습니다.
  • No support for “receive shadows” flag and limited support light Culling Masks.
  • “리시브 쉐도우” 플레그를 지원하지 않고 라이트 컬링 마스크를 제한적으로 지원합니다.

Requirements for Deferred Lighting 디퍼드 렌더링의 요구사항

  • Requires Unity Pro.
  • 유니티 프로가 먼저 필요하고요
  • Graphics card with Shader Model 3.0 (or later), support for Depth render textures and two-sided stencil buffer. Most graphics cards made after 2004 support it: GeForce FX and later, Radeon X1300 and later, Intel 965 / GMA X3100 and later.
  • 그래픽 카드는 쉐이더 3.0 이상, 깊이 렌더 텍스쳐와 2사이드 스텐실 버퍼가 지원되어야 함. 2004년 이후 그래픽 카드는 대부분 지원함 ; 지포스 FX와 그 이후버전, 라데온 X1300과 이후버전, 인텔 965/GMA X3100과 그 이후버전.
  • Currently does not work on mobile platforms.

Performance Considerations 퍼포먼스의 주의사항

Cost of realtime lights in Deferred Lighting is proportional to number of pixels the light shines on; and not dependent on scene complexity. So small point or spot lights are very cheap to render. Point or spot lights that are fully or partially occluded by some scene objects get their pixels skipped on the GPU, so they are even cheaper.
디퍼드 렌더링에서 리얼타임 렌더링의 비용은 라이트가 현재 빛나는 , 화면의 픽셀 수에 비례합니다 ; 그리고 신의 복잡도 같은건 신경 꺼도 됩니다. 그래서 매우 작은 포인트나 스팟 라이트 같은 경우는 매우 렌더링 하기 빠릅니다. 전체 혹은 부분적으로 다른 오브젝트에게 가려진 포인트나 스팟 라이트는 GPU에서 계산이 스킵됩니다. 그래서 그들 또한 빠릅니다.

Of course, lights with shadows are much more expensive than lights without shadows. In Deferred Lighting, shadow casters still need to be rendered once or more for each shadow-casting light. And the lighting shader that applies shadows is also more expensive than one without shadows.
물론, 라이트와 그림자는 라이트와 그림자가 없을때보다 많이 무겁습니다. 디퍼드 라이팅에서, 그림자 캐스팅은 여전히 한 번 또는 한 번 이상 , 각각 그림자 캐스팅 라이트에 의해 렌더링됩니다. 그리고 그림자가 적용되는 쉐이더는 그림자가 없는 쉐이더보다 역시 많이 무겁습니다.

Implementation Details

When Deferred Lighting is used, rendering process in Unity happens like this:

  1. Base Pass: objects are rendered, producing screen-space buffers with depth, normals, and specular power.
  2. Lighting pass: lighting is computed using the previous buffers. Lighting is computed into another screen-space buffer.
  3. Final pass: objects are rendered again. They fetch computed lighting, combine it with color textures and add any ambient/emissive lighting.

Objects with shaders that can’t handle Deferred Lighting are rendered after this process is done, using RenderTech-ForwardRendering path.

Base Pass

Base pass renders each object once. View space normals and specular power are rendered into single ARGB32 Render Texture (normals in RGB channels, specular power in A). If platform & hardware supports reading Z buffer as a texture, then depth is not explicitly rendered. If Z buffer can’t be accessed as a texture, then depth is rendered in additional rendering pass, using shader replacement.

Result of the base pass is Z buffer filled with scene contents and Render Texture with normals & specular power.

Lighting Pass

Lighting pass computes lighting based on depth, normals and specular power. Lighting is computed in screen space, so it’s independent of scene complexity. Lighting buffer is single ARGB32 Render Texture, with diffuse lighting in RGB channels and monochrome specular lighting in A channel. Lighting values are encoded using logarithmic encoding to provide extended dynamic range than usually possible with ARGB32 texture.

Lighting model is fixed to Blinn-Phong.

Point and Spot lights that do not cross camera’s near plane are rendered as 3D shapes, with Z buffer test against scene enabled. This makes partially or fully occluded Point and Spot lights very cheap to render. Directional lights and Point/Spot lights that cross the near plane are rendered as fullscreen quads.

If a light has shadows enabled, they are rendered and applies in this pass as well. Note that shadows are not “free”; shadow casters need to be rendered and a more complex light shader needs to be applied.

Final Pass

Final pass produces final rendered image. Here all objects are rendered again; with shaders that fetch the lighting, combine it with textures and add any emissive lighting.

Lightmaps are also applied in the final pass. Close to the camera, realtime lighting is used, and only baked indirect lighting is added. This crossfades into fully baked lighting further away from the camera

Hugo로 만듦
JimmyStack 테마 사용 중