Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static const float PI2 = 3.14159265359f * 2;
  2. int CDIndex = 13;
  3. int CSIndex = 24;
  4.  
  5.  
  6. Steps = clamp(floor(Steps), 1, 128);
  7. RadialSteps = clamp(floor(RadialSteps), 1, 128);
  8.  
  9. float stepSize = Radius / Steps;
  10. float radialStepSize = PI2 / RadialSteps;
  11.  
  12. float result = 0.0f;
  13. float stencil = 0.0f;
  14.  
  15. for (int i = 1; i <= Steps; ++i)
  16. {
  17.     float currStep = i * stepSize;
  18.    
  19.     for (int j = 0; j < RadialSteps; ++j)
  20.     {
  21.         float angle = j * radialStepSize;
  22.         float2 coord = float2(cos(angle), sin(angle)) * currStep + ViewportUVToSceneTextureUV(UV,14);
  23.         float sample = SceneTextureLookup(coord, CDIndex, false);
  24.         result += (MaxDistance - clamp(sample, 0, MaxDistance)) / MaxDistance;
  25.        
  26.         stencil = max(stencil, SceneTextureLookup(coord, CSIndex, false));
  27.     }
  28. }
  29.  
  30. return float2(result / (RadialSteps * Steps), stencil);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement