-
-
Save shelllee/90a8a1d5ae18f30786dce177189d2368 to your computer and use it in GitHub Desktop.
Spiral Blur modified to sample Custom depth buffer for soft object outlines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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