Skip to content

Instantly share code, notes, and snippets.

@shelllee
Forked from tomlooman/SpiralBlurCustomDepth
Created November 14, 2017 11:20
Show Gist options
  • Save shelllee/90a8a1d5ae18f30786dce177189d2368 to your computer and use it in GitHub Desktop.
Save shelllee/90a8a1d5ae18f30786dce177189d2368 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment