# analytical voxel displacement

## Recommended Posts

Is it possible, analytically to voxalize a surface by displacing P along N to floored P planes? Analytically meaning not using Ray or intersect() but in shading for example.

Basic flooring: Attempted point projection to floored planes: On a simple circle/sphere, I would need to iterate over neighbouring cells (a'la vornoi loop) and check if P is above or below the plane? Then there is a question of tight bends where the normal doesn't intersect any floored planes. Currently I'm stuck at projections being clipped by voxel size in all directions. The script belwo is as far as I got (also included HIP). Initially I had a feeling that there is a elegant/simple solution but now I suspect there is a simple proof/example that its impossible.

VEX Wrangler prototype:

```vector P = v@P;
vector N = -v@N; // tangent in case of a curve

vector floorX = set(floor(P.x), P.y, 0);
vector floorY = set(P.x, floor(P.y), 0);

vector dirX = floorX - P;
vector dirY = floorY - P;

// theta
float tX = dot(normalize(dirX), N);
float tY = dot(normalize(dirY), N);

// hypotenuse length
float lX = length(dirX) / tX;
float lY = length(dirY) / tY;

float planesMin = min(lX, lY);
v@P = v@P + (N * planesMin);```

scene:

Edited by rutra
fix tags
##### Share on other sites

Heyo,
I'm not sure I've completely understood what you want to do, but I've managed to make a "voxelized" sphere using this little vex snippet:

`v@P = lerp(v@P, floor(v@P), chf('Lerp'));`

Adding the lerp since I assumed based on the gifs that you wanted to animate the transformation over time. You could also change out the "floor" function for the "rint" function if you'd like the positions to snap to the nearest whole value instead of always rounding down.

However, the advanced math you are doing in your VEX code is making me doubt whether or not I've understood what you actually want to do, haha.

Hope it can help!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible. ×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×