Q.
화면 효과 중 DOF (Depth Of Field)를 구현하고 싶습니다.
카메라와의 거리에 따라서 Blur 효과를 주고 싶은데, 거리와 무관하게 Blur가 적용되는 것 같습니다.
I want to implement DOF (Depth Of Field) among the screen effects.
I want to give a blur effect depending on the distance from the camera, but it seems that the blur is applied regardless of the distance.
A.
AnyPortrait의 메시들은 “Transparent” 타입의 쉐이더로 렌더링됩니다.
이 쉐이더는 Z-Write를 하지 않고 Depth 맵에 기록되지 않습니다.
DOF는 Z 버퍼를 이용하므로 Opaque 타입이 아닌 AnyPortrait 메시들은 DOF의 대상이 되지 않습니다.
다음과 같이 커스텀 쉐이더를 작성하고 적용하면 DOF의 대상이 될 수 있습니다.
– 쉐이더의 타입 구문을 “Tags{ “RenderType” = “TransparentCutout” “Queue” = “AlphaTest” “PreviewType” = “Plane” }”으로 작성합니다.
– “ZWrite On” 구문을 추가합니다.
– Surface Shader를 이용한다면 “#pragma surface surf SimpleColor alphatest:_CutOff” 처럼 작성합니다.
이렇게 하면 투명도가 1과 0만 가지는 불투명한 객체가 되어 렌더링되며 DOF가 적용됩니다.
캐릭터의 이미지가 반투명하지 않는다면 시도해볼만한 방법입니다.
AnyPortrait meshes are rendered with a “Transparent” type shader.
This shader does not do Z-Write and is not recorded in the Depth map.
Since DOF uses the Z buffer, AnyPortrait meshes that are not of the Opaque type are not subject to DOF.
You can achieve DOF by writing and applying a custom shader like this:
– Write the type syntax of the shader as “Tags{ “RenderType” = “TransparentCutout” “Queue” = “AlphaTest” “PreviewType” = “Plane” }”.
– Add the “ZWrite On” syntax.
– If you use Surface Shader, write it like “#pragma surface surf SimpleColor alphatest:_CutOff”.
This will render it as an opaque object with only transparency values of 1 and 0, and will have DOF applied.
This is a method worth trying if your character’s image is not translucent.