# Edit SOP (spherify)?

## Recommended Posts

I have this oval shape that I would like to be more rounded. I have tried selecting some points and increasing the Soft Radius in the Edit SOP but that just does not give me the result I am looking for.

Basically I would like to push the points out from the center sphereically.

Can this be done with the Edit SOP or is there a better node for that?

Edited by Atom

##### Share on other sites
`@P = normalize(@P); //turns your mesh into a sphere`

##### Share on other sites

Thanks, that kind of works but it also kind of messes up some of the edges. Does this also remove scale? It seems like my overall size diminished quite a bit.

##### Share on other sites
27 minutes ago, Atom said:

Does this also remove scale?

Yes, it places all points exactly one unit away from the world center.

A compromise would be interpolating between the current state and a spherified shape.

`@P = lerp(@P, normalize(@P), chf('mix'));`

While it might lead to geometrical collisions, you can for sure create really cute baby pigs with it

• 1

##### Share on other sites

Not fixing the overlapping edges of course, but a revised version of the code could be

```vector _min, _max;
getbbox(0, _min, _max);

vector _ctre = _max - ((_max - _min) * 0.5);    // compute centroid
vector _size = _max - _ctre;    // find longest distance to centroid

@P -= _ctre;    // realign to centre of the world
@P = lerp(@P, normalize(@P) * _radius, ch("bias")); // spherify
@P += _ctre;    // reposition in world```

It will spherify any object wherever it is in the world while maintaining a sense of scale.

• 1

##### Share on other sites

Cool, thank you both for those additional options.

##### Share on other sites
1 hour ago, iamyog said:

It will spherify any object wherever it is in the world while maintaining a sense of scale.

Useful idea. I compressed the code a little..

```vector center = getbbox_center(0);
float size = max(getbbox_size(0));
vector sphere = center + normalize(@P - center) * 0.5 * size;
@P = lerp(@P, sphere, chf('spherify'));```

##### Share on other sites

btw: Another option would be offsetting the spherification center.

```vector center = getbbox_center(0) + chv('offset');
float size = max(getbbox_size(0));
vector sphere = center + normalize(@P - center) * 0.5 * size;
@P = lerp(@P, sphere, chf('spherify'));```

Edited by konstantin magnus
• 1

##### Share on other sites

I like the addition of the vector. It is like having an invisible metaball influence you can move around.

## Create an account

Register a new account