Jump to content
rutra

analytical voxel displacement

Recommended Posts

Posted (edited)

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:

flooring.gif.dd92f5d15507e3210363f2b315111277.gif

Attempted point projection to floored planes:

projecting.gif.71ceb17d39978f75ccb0b0b7ca855b3c.gif

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);

// adjacent
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:

voxelisation.hipnc

Edited by rutra
fix tags

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×