float dist = xyzdist(1,@P);
float distremap = fit(dist,ch("near"),ch("far"),0,1);
f@density *= distremap;
This gives a vdb a falloff based on how close it is to the original object's surface.
Stick the VDB into a volume visualisation and then plug that into input 0
Put the original geo into input 2.
Now you can "blur"
Showing posts with label volume. Show all posts
Showing posts with label volume. Show all posts
Friday, 25 October 2019
Tuesday, 13 March 2018
simple vector field avoidance
based on this vid's ideas...
https://www.youtube.com/watch?v=MWJ0E1Rdoiw
As an example case: You have a grid space with some cylinders scattered about. On the X side of the grid space you have a bunch of particles being emitted. We want the particles to flow through the space avoiding said cylinders.
https://www.youtube.com/watch?v=MWJ0E1Rdoiw
As an example case: You have a grid space with some cylinders scattered about. On the X side of the grid space you have a bunch of particles being emitted. We want the particles to flow through the space avoiding said cylinders.
- We make a Volume that encompasses the whole area in question. We give it a vector value and name it Vel. For velocity.
- We make a volume VOP. The volume we just made goes into input 1. The cylinders go into input 2.
- Inside the VOP we make a constant vector value of (1,0,0). This is the direction we want the particles to go in. That's X.
- We make an XYZdist node and plug our Position and Input 2 bits in. We're getting the distance to the nearest faces with this.
- We want the Normal attribute of the faces. To get this, add a Primitive Attribute node. Plug in the relevant parts from XYZdist. Remember to feed in Input 2, for the "file" input. Change the attribute to N. We now have the Normal. Add a Normalize node to keep the maths clean.
- Do a cross product between the constant X and our normalized Normal. Normalize this too.
- Do another cross product between the normalized cross product and our normalized normal. This is a bit fiddly, but it's all about 90 degree angles and getting to what we want.
- Normalize the result and plug it into a Bind Export with the attribute named Vel.
We now have the basis of a vector field.
However it'd be nice to use the distance from the cylinders as a blending function. So if you're in a bit of the field not close to a cylinder, you'd just go on about your way.. Only as you got closer would you be affected. To do this............
- Go back into the VOP. Connect the Dist output from the XYZdist node into a Fit Range Node.
- Promote the Source Maximum input. We'll set this later outside of the VOP.
- Plug the output of the Fit Range into a Ramp parameter. Set the ramp to a linear type.
- The output of the ramp can go into the Bias input of a Mix node.
- Constant X goes into input A of the Mix. The normalized result of the 2 crossproducts goes into input B. The output of the Mix can now be plugged into the Bind Export we made before.
Finally.. this can be used in a POP network now, to override a particle system's velocity!
Friday, 23 June 2017
latticing VDBs/volumes
Bring in your VDB however you need to.
Plug it into a VolumeVOP and create an addpoint node. Plug P into the ptvalue input.
Next create a setattrib node and plug your addpoint's ptnum output into the setattrib's i1. Plug your density into the value node and name the parameter "density". Jump back out of the VOP.
This will have made a volume grid of points that represent your VDB, each containing the corresponding density value. The number of points created is dependent on the resolution of your VDB, although I guess you could duplicate points and hope that they interpolate nicely?
Next, add a Timeshift node after the VOP and freeze your volume at the point you think it occupies the most space. Eg. if it's a trail of cigarette smoke, it's last frame. Create a Bound node for this.
This is now the lattice you can transform and deform.
Then make a Lattice node and plug your Volume VOP into the first input, the output of the Bound into the 2nd and then finally whatever your transform/deforms are into the 3rd.
So far, we've transformed a bunch of points, that hold our density values.. Now we have to recreate our volume..
Connect a Bound node to your deformed points. We're making an empty volume that encompasses the limits of your deformed sequence. Add an Iso Offset to this, set the Output Type to Fog Volume, Mode to Ray Intersect and name it Density. You control the effective resolution with the sampling. Next let's copy the density back into your empty volume.
Make a volume VOP, plug the Iso Offset into the first input & the lattice into the second. Jump in and make a Point Cloud Open node. Connect the P to the P and the OpInput2 into the File input.
Create a Point Cloud Filter and set it's signature to Float Channel and label the Channel "density". Plug the Point Cloud Open's handle into the Point Cloud Filter's handle input. Finally plug the value into the volumevopoutput's Density..
Your blank volume now has a deformed version of the original's density!
Sit back, relax and pretend you're resimming now.
Plug it into a VolumeVOP and create an addpoint node. Plug P into the ptvalue input.
Next create a setattrib node and plug your addpoint's ptnum output into the setattrib's i1. Plug your density into the value node and name the parameter "density". Jump back out of the VOP.
This will have made a volume grid of points that represent your VDB, each containing the corresponding density value. The number of points created is dependent on the resolution of your VDB, although I guess you could duplicate points and hope that they interpolate nicely?
Next, add a Timeshift node after the VOP and freeze your volume at the point you think it occupies the most space. Eg. if it's a trail of cigarette smoke, it's last frame. Create a Bound node for this.
This is now the lattice you can transform and deform.
Then make a Lattice node and plug your Volume VOP into the first input, the output of the Bound into the 2nd and then finally whatever your transform/deforms are into the 3rd.
So far, we've transformed a bunch of points, that hold our density values.. Now we have to recreate our volume..
Connect a Bound node to your deformed points. We're making an empty volume that encompasses the limits of your deformed sequence. Add an Iso Offset to this, set the Output Type to Fog Volume, Mode to Ray Intersect and name it Density. You control the effective resolution with the sampling. Next let's copy the density back into your empty volume.
Make a volume VOP, plug the Iso Offset into the first input & the lattice into the second. Jump in and make a Point Cloud Open node. Connect the P to the P and the OpInput2 into the File input.
Create a Point Cloud Filter and set it's signature to Float Channel and label the Channel "density". Plug the Point Cloud Open's handle into the Point Cloud Filter's handle input. Finally plug the value into the volumevopoutput's Density..
Your blank volume now has a deformed version of the original's density!
Sit back, relax and pretend you're resimming now.
Thursday, 20 October 2016
Checking if a point is inside a volume
This can be done with a point wrangle, but for those that prefer VOPs...
create a point VOP, connect the geometry you wish to test into the first input. connect the volume you want to test with into the second.
Enter the VOP, create a volumesample. Connect P and OpInput2 into this node.
The value it returns (bind export this to something) indicates how "deep" within the volume the point is. A negative value means the point is within the volume & a positive value means it is outside of the volume.
create a point VOP, connect the geometry you wish to test into the first input. connect the volume you want to test with into the second.
Enter the VOP, create a volumesample. Connect P and OpInput2 into this node.
The value it returns (bind export this to something) indicates how "deep" within the volume the point is. A negative value means the point is within the volume & a positive value means it is outside of the volume.
Tuesday, 4 October 2016
velocity volume fields like Maya
It's possible to make a piece of geometry, pump it through a PointVOP and give it some velocity, using constants, curl noise or whatever method you like.
Then convert the polygon to a VDB, using the V point attribute. Name the field "vel".
Within POPs/dynamic network use an advect with volume operator. The defaults should keep the velocity's affect within the volume created.
If this doesn't work as expected you might need to use a Geometry Wrangle (within the POP/Flip/dynamics)
Using the code below, you'll want to set the 2nd input (in the input tabs) to the velocity volume created earlier.
vector vel = volumesamplev(1,0,@P);
v@force += vel * ch("scale");
v@a = vel;
Basically we're affecting the velocity via a force, rather than adding directly to it - to avoid overly strong changes in velocity. We also have extra control with a scale slider & the "a" attribute is a little debug value to watch out for in the Geometry Spreadsheet.
Note - you might have to really crank up the velocity values, depending on the current velocity of the existing particles/fluid/whatever.
*NOTE* The Geometry Wrangle should be plugged into the particles tab of the solver! (2nd one)
Then convert the polygon to a VDB, using the V point attribute. Name the field "vel".
Within POPs/dynamic network use an advect with volume operator. The defaults should keep the velocity's affect within the volume created.
If this doesn't work as expected you might need to use a Geometry Wrangle (within the POP/Flip/dynamics)
Using the code below, you'll want to set the 2nd input (in the input tabs) to the velocity volume created earlier.
vector vel = volumesamplev(1,0,@P);
v@force += vel * ch("scale");
v@a = vel;
Basically we're affecting the velocity via a force, rather than adding directly to it - to avoid overly strong changes in velocity. We also have extra control with a scale slider & the "a" attribute is a little debug value to watch out for in the Geometry Spreadsheet.
Note - you might have to really crank up the velocity values, depending on the current velocity of the existing particles/fluid/whatever.
*NOTE* The Geometry Wrangle should be plugged into the particles tab of the solver! (2nd one)
Labels:
field,
geometry wrangle,
maya,
vdb,
velocity,
velocity field,
volume
Subscribe to:
Posts (Atom)