Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code Start
- static const float PI = 3.14159265359f;
- int CDIndex = 13;
- Steps = clamp(floor(Steps), 1, 128);
- RadialSteps = clamp(floor(RadialSteps), 1, 128);
- float StepSize = Radius/Steps; // Step size needed to get from the center to edge of the shape
- float RadialStepSize = (PI*2)/RadialSteps; // Step size needed to get around the object
- float Result = 0.0f;
- for (int i = 1; i <= Steps; i++){
- float CurrentStep = i * StepSize;
- for(int j = 1; j < RadialSteps; j++) {
- float Angle = j* RadialStepSize;
- float2 Coord = float2(cos(Angle), sin(Angle)) * CurrentStep + UV;
- float Sample = SceneTextureLookup(ViewportUVToSceneTextureUV(Coord, CDIndex), CDIndex, false);
- Result += (MaxDistance - clamp(Sample, 0, MaxDistance)) / MaxDistance;
- }
- }
- return float1 (Result / (RadialSteps * Steps));
- // Code End
Advertisement
Add Comment
Please, Sign In to add comment