UE4 CustomDepth





SceneTexture PostProcess input



PostProcessing volume : make post processing active before tonemapping



Screen Position x,y to R,G

SceneTextureLookup(UV,14,false).xyz * Color;


Custom RenderDepth

static const float PI2 = 3.14159265359f;
int CDIndex = 13;
Steps = clamp(floor(Steps), 1, 128);
RadialSteps = clamp(floor(RadialSteps), 1, 128);
float stepSize = Radius /Steps;
float radialStepSize = PI2/ RadialSteps;
float result = 0.0f;
for (int i = 1; i <= Steps; ++i)
{
  float currStep = i * stepSize;
  for (int j = 0; j < RadialSteps; ++j)
{
     float angle = j * radialStepSize;
     float2 coord =    float2(cos(angle), sin(angle)) * currStep + UV;
float sample = SceneTextureLookup(coord, CDIndex, false);
result += (MaxDistance - clamp(sample, 0, MaxDistance)) / MaxDistance;
  }
}
return result/ (RadialSteps * Steps);




















static const float PI2 = 3.14159265359f;
int CDIndex = 13;
int CSIndex = 24;
Steps = clamp(floor(Steps), 1, 128);
RadialSteps = clamp(floor(RadialSteps), 1, 128);
float stepSize = Radius /Steps;
float radialStepSize = PI2/ RadialSteps;
float result = 0.0f;
float stencil = 0.0f;
for (int i = 1; i <= Steps; ++i)
{
  float currStep = i * stepSize;
  for (int j = 0; j < RadialSteps; ++j)
{
     float angle = j * radialStepSize;
     float2 coord =    float2(cos(angle), sin(angle)) * currStep + UV;
float sample = SceneTextureLookup(coord, CDIndex, false);
result += (MaxDistance - clamp(sample, 0, MaxDistance)) / MaxDistance;
stencil = max(stencil, SceneTextureLookup(coord, CSIndex, false));
  }
}
return float2 (result/ (RadialSteps * Steps),stencil);

댓글

이 블로그의 인기 게시물

About AActor!!! "UObject" has no member "BeginPlay"

UNREAL Android build information

C++ 생성자 위임 (delegating constructor)