mattyjrogers Posted February 15, 2018 Share Posted February 15, 2018 Hi there, I have got a complex script but I am now looking at making it more complex by being able to control the density of the points. Are there ways to be able to control the density of points by attractor points maybe like my example image? (From grasshopper) Thanks! Quote Link to comment Share on other sites More sharing options...
Sean-R Posted February 15, 2018 Share Posted February 15, 2018 You can control the density of scattered points by an attribute, the scatter SOP defaults to a "density" attribute but you can use whatever you like. For the distribution that you have in your top image you could make a black to white gradient on a grid then replace "density" with "Cd" in the Density Attribute parameter. Quote Link to comment Share on other sites More sharing options...
mattyjrogers Posted February 15, 2018 Author Share Posted February 15, 2018 Thanks for the reply! How do I create a black to white density on a grid? Is this using an image file or something? Also do you know if there is a way with an attractor point?? Thanks! Quote Link to comment Share on other sites More sharing options...
toadstorm Posted February 15, 2018 Share Posted February 15, 2018 density_ramps.hip 3 1 Quote Link to comment Share on other sites More sharing options...
mattyjrogers Posted February 15, 2018 Author Share Posted February 15, 2018 That is amazing Henry! Thanks a lot, I am just wondering if you might be able to explain how it works and how I might be able to control quite easily where exactly those dense areas occur? Thanks! Quote Link to comment Share on other sites More sharing options...
toadstorm Posted February 15, 2018 Share Posted February 15, 2018 I added some notes in the VEX code to explain what's going on, but I can elaborate a little further. The first two examples are doing exactly the same thing, one in VEX and one in VOPs: generating a @density attribute based on the Y position of each point on the grid, relative to the bounding box. The `relbbox` function returns a vector with components ranging between 0 and 1, based on where the point is relative to the bounding box of the object on each axis. The y-component of that vector is used as the lookup value for a ramp, using the `chramp` function. The ramp parameter is auto-generated by the point wrangle if you click the little "+" button next to the VEX code. You can then use this ramp to control the value of the @density attribute, which exists on the points of the grid. If you want to visually see the results, you can use a Visualizer SOP to view density as color. The Scatter SOP by default will look for a @density attribute to determine where to prioritize scattering points, but you could use other attributes if you like; density is just a convention. The third example is using the "attractor points" you were asking about. A number of points are scattered on the grid; these are the attractors. In the point wrangle, which runs over all points of the grid simultaneously, the nearest attractor point to the current iteration's point position is found using `nearpt`, and then the `point` function is used to get the position of that attractor. The distance between the current grid point and the nearest attractor point is computed and fit to a 0-1 range based on the "max_dist" channel, which is user-defined. The resulting 0-1 value is used with a ramp attribute lookup, and the result is bound to @density, same as the other examples. You could change the falloff ramp and the max distance to adjust exactly how the density is mapped to the grid points. If you wanted to solve this without VEX, you could try scattering a few points onto a grid, giving them all a @density value of 1 or some other positive value, then using an Attribute Transfer to transfer this attribute back to the grid points. Then use a Scatter SOP as before. 2 Quote Link to comment Share on other sites More sharing options...
mattyjrogers Posted February 16, 2018 Author Share Posted February 16, 2018 Henry, you are the man, that is clear! Thanks a lot, you have saved my bacon. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.