I have an SDF of a sphere which I distort with unity’s snoise function that returns the gradient. What I need help with is using that gradient to calculate the new normal of the sphere. Before distorting the sphere, the normal would just be the sampling point normalized, but since distorting the sphere also distorts the sample point, I need to calculate a new normal. I hope that made sense, and here is the code:
private readonly VolumeOutput SphereSDF(in float3 sample)
{
float leng = length(sample);
float distance = leng - Height; // sphere sdf
float noise = noise.snoise(sample, out float3 gradient);
distance -= noise; // distorted spehre sdf
float3 norm = normalize(gradient); // very bad normal, I need help with this!
return new VolumeOutput(distance, noise, norm); // return the sdf data
}

