# How to Turn a Cube into a Mathematically Precise Sphube to the Limits of Numerical Precision Using Vector Displacement?

A sphere is given by the graph of the equation $$\lvert x\rvert^2+\lvert y\rvert^2+\lvert z\rvert^2=1$$.

If you increase the exponents to something larger than 2, then the graph of the equation becomes more cubular, and is called a sphube, which is a 3D version of a squircle.

How do you use vector displacement to turn a cube into a mathematically precise sphube to the limits of numerical precision with volume half way between that of the cube and a sphere of the same size?

According to this article, the exponent should be 3.43184, but that number could be rounded off, and I need the exponent to have single-precision floating point precision.

• Just out of interest: Why don't you just use the Round Cube from the Add Mesh Extra Objects? Aug 21, 2022 at 13:10
• So are you just asking for a more precise exponent?
– J.G.
Aug 21, 2022 at 15:59
• @quellenform i noticed from his previous questions that it's out of curiousity, so not really related to a problem he needs solved. so using round cube is out of the question ;) Aug 21, 2022 at 16:05
• If you goal is just more precision on the exponent, then this is a pure math question, not a blender question (ie suitable to a different SE site). If I understand the article you linked correctly, the code just above the block with the 3.43.. gives you the code to compute that number. So putting that code/ formula into a suitably mathy programming language will give you as much precision as you want. Aug 21, 2022 at 17:39
• @Harry McKenzie It is not only out of curiosity. Aug 21, 2022 at 22:29

I can't find a parametric expression for your surface: as far as I can see the sphube described in this paper is not the same as yours? (I could be mistaken)

Here's a shot at it in Geometry Nodes. The strategy is to create your object as an isosurface, (limited by the resolution of Blender's volumetrics) and then shrinkwrap a subdivided cube on to it for better topology:

There will be inaccuracies on the way, but maybe not effectively worse than placing the vertices of a polygonal mesh parametrically. Here, powers of 2, 3.43184, 20.

Blender 3.3b +

• Thank you, but I do not how to do adaptive subdivision with geometry nodes. A reason I was asking about doing it with vector displacement is so I could use adaptive subdivision with the base geometry. Aug 21, 2022 at 21:32
• @BlenderUser9000, I don't think procedurally-based adaptive subdiv is possible outside a Cycles render. (You could render the volume. there) Which means the geometry is not accessible. If you thought the sphube in the referenced paper was yours, we could go that way.. but still not strictly adaptive. What do you need this object/image for? Aug 21, 2022 at 22:10

If you are looking for an artistic rendition of cube transitioning to sphere, this can be done with shape keys. It is not mathematically precise though.

First, create a cube with a sphere inside it

Then use the shrink wrap modifier to wrap it to the sphere

Apply the modifier as a shape key, and you can use it to displace between the two.

• I need the sphube to be mathematically precise to the limits of numerical precision. Aug 21, 2022 at 1:21