Skip to content

Instantly share code, notes, and snippets.

@tomlooman
Last active October 7, 2021 01:44
Show Gist options
  • Save tomlooman/e75f6ef0ab0b53063677db3b7dd0ffd9 to your computer and use it in GitHub Desktop.
Save tomlooman/e75f6ef0ab0b53063677db3b7dd0ffd9 to your computer and use it in GitHub Desktop.
Spiral Blur modified to sample Custom depth buffer for soft object outlines.
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;
if (DistanceSteps < 1)
{
return Texture2DSample(CustomDepthTexture,CustomDepthTextureSampler,UV);
}
else
{
while (i < (int) DistanceSteps)
{
CurDistance += StepSize;
for (int j = 0; j < (int) RadialSteps; j++)
{
SubOffset +=1;
CurOffset.x = cos(TwoPi*(SubOffset / RadialSteps));
CurOffset.y = sin(TwoPi*(SubOffset / RadialSteps));
NewUV.x = UV.x + CurOffset.x * CurDistance;
NewUV.y = UV.y + CurOffset.y * CurDistance;
float distpow = pow(CurDistance, KernelPower);
CurColor += ceil(Texture2DSample(CustomDepthTexture,CustomDepthTextureSampler,NewUV))*distpow;
accumdist += distpow;
}
SubOffset +=RadialOffset;
i++;
}
CurColor = CurColor;
CurColor /=accumdist;
return CurColor;
}
@halfjack
Copy link

halfjack commented Oct 7, 2021

Is this a whole, functioning HLSL statement? why is Unreal asking me for Variable definitions when i plug this in to a custom node?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment