Implement a Sphere mask in HLSL

Hi, I have a render target which I will use to store certain locations in world space. I want to extract those coordinates, put each of them through a sphere mask with the World Position being the other parameters and then use that output texture.


This is the situation where there is only one location, so a param is used, The 3 vector param will be replaced with a texture/ render target node and the Sphere mask will be replaced with a custom node that will simulate this graph for every position written in the texture.

I can extract the coordinates from the texture, but I don’t know how to implement the sphere mask functionality in HLSL. Is it possible?

Greetings,
Try this:

float ClampedRadius = max(0, Radius);
return saturate((ClampedRadius - distance(A, B)) / (ClampedRadius * (1.0 - clamp(Hardness, 0, 1))));

Like this?

Thank you for this reply, it would have helped me if i hadn’t already solved it. Basically this material is supposed to a post processing material, so i used your code but in node mode