본문 바로가기
이펙트 (FX)/이펙트 팁 : Unreal

[Unreal/Material] 부드러운 윤곽선 포스트 프로세스 제작

by Minkyu Lee 2023. 10. 10.

노드 구조

 

커스텀 코드

float3 CurColor=0;
float2 NewUV = UV;
int i=0;
float StepSize = Distance / (int) DistanceSteps;
float CurDistance=0;
float2 CurOffset=0;
float SubOffset = 0;
float TwoPi = 6.283185;
float accumdist=0;

float2 texelSize = View.ViewSizeAndInvSize.zw * Distance;

if (DistanceSteps < 1)
{
  return SceneTextureLookup(ViewportUVToBufferUV(UV), PPI_CustomStencil, false); // 14 == PostProcessInput0
}
else
{
  while (i < (int) DistanceSteps)
  {
    CurDistance += StepSize;
    for (int j = 0; j < (int) RadialSteps; j++)
    {
      SubOffset +=1;
      CurOffset.x = cos(TwoPi*(SubOffset / RadialSteps)) * texelSize.r;
      CurOffset.y = sin(TwoPi*(SubOffset / RadialSteps)) * texelSize.g;
      NewUV.x = UV.x + CurOffset.x * CurDistance;
      NewUV.y = UV.y + CurOffset.y * CurDistance;
      float distpow = pow(CurDistance, KernelPower);
      CurColor += SceneTextureLookup(ViewportUVToBufferUV(NewUV), PPI_CustomStencil, false)*distpow;
      accumdist += distpow;
    }
    SubOffset +=RadialOffset;
    i++;
  }
  CurColor = CurColor;
  CurColor /=accumdist;
  return CurColor;
}

 

참고자료

1번 자료의 버그를 수정한 것이 2번 자료이다.

바뀐 것은 SceneTextureLookup 부분과 texelSize 부분이다.

 

3번 자료는 각기 다른 방법론을 5개 제시한다.

 

https://www.tomlooman.com/unreal-engine-soft-outline/

 

Rendering Soft outlines in Unreal Engine

Create soft blurred outlines using SpiralBlur Material Function in Unreal Engine. Includes source code for outline material.

www.tomlooman.com

https://youtu.be/453mdZhaC0w

https://ameye.dev/notes/rendering-outlines/

 

5 ways to draw an outline

🖍️ Explaining multiple techniques for rendering outlines and highlights for real-time applications. This includes vertex object-space as well as screen-space methods. This can be used to render outlines in Unity or Unreal. Outlines can be used for gam

ameye.dev

 

댓글