Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static const float PI2 = 3.14159265359f * 2;
- 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 + ViewportUVToSceneTextureUV(UV,14);
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement