PDA

View Full Version : Create Weight Based On Density



Nigel
10-17-2010, 05:07 AM
Hey guys.

I've spent some time searching the net, and the forum, but cant find anything, so I thought I'd ask here. Is there a tool or technique to create a weight map based on vertex density? I have an object of varying density, on which I need to clone spheres, but I need the spheres to be smaller in the denser areas, and larger in the sparser areas, and the only way it seems I can control their scale, is via a weight map.

Any tips would be appreciated.

Thanks :)

adk
10-17-2010, 10:22 PM
Heya Nigel,

Thought I'd give it a shake since I thought I might also find this handy somewhere down the track. Quick outline of how I did it ... (Keep in mind I did this for a terrain type mesh, so if you have a complex 3D object to weight this technique might not work for you 100%)

1. Displace the mesh in Y with DPont's Poly Move node using Nearest Point node. Denser point distributions will displace less than the sparse ones. Save this transformed mesh.

2. In modeler UV this mesh using Planar map type, along either X or Z axis. This will give you a nice spread from valley to peak.

3. Using UV to Weight, select your UV texture, create a new weight map, and use V as the projection.

That will give you a weight map from 0 to 100 where peaks are 100 and valleys are 0. Stretch it 200% in UV viewport (from the highest peak) to give you a range from -100 to 100. Negative scale value gets you the inverse & is the map in the animated gif.

It's not 100% perfect I think but might be worth your while. Let me know if anything is unclear & good luck :thumbsup:

Nigel
10-18-2010, 03:18 AM
awesome man, I think that may just do the trick, the results look like what I'm after. The wealth of knowledge some guys have continues to amaze me :)

Thanks for the tip man, much appreciated.

adk
10-18-2010, 03:39 AM
No probs. Glad to help out :)
This might be tricky to get to work on something like a sphere I think, but on a something that's quite planar it should work ok.

In the image I posted the outside edges might be (seem a little) problematic so you might need to use 2 instances of the same mesh & make the displaced one a tiny bit smaller than the one you're driving it with (in Nearest Point node it's the one you select)

Just holler if you have any hassles getting this to work & I'll post something more visual & comprehensive if needed :thumbsup:

adk
10-18-2010, 07:45 PM
After a bit of mucking about I found that that technique won't work too well for complex 3D shapes.

But here's another way to clone stuff that's even easier :) and it works on any object.

Simply use Denis Pontonnier's brilliant instancing plugin :thumbsup: and use the Nearest Point node right inside the Instance Node Editor to control both the density & size. DP Instance absolutely rocks.

Nigel
10-19-2010, 02:04 AM
Dude .... you are officially a legend in my books :) The first technique didnt quite work for me, but this new stuff you posted, looks exactly like what I need. I have a flag of varying vertex density, and have to clone a bunch of balls on it, with smaller ones in denser areas, larger ones in less dense areas. This will work perfectly. Thanks mate! :thumbsup:

adk
10-19-2010, 02:15 AM
No probs & nahhh, whatever I know is all from good folks like yourself, right here in these forums. I'll post you a scene when I get home in a few hours :) as it might save you some time / give you other ideas.

Boris Goreta
10-19-2010, 03:11 AM
Hey, I tried using nearest point but I don't get symmetrical results on a sphere. Bottom hemisphere looks good but in the upper part instances get bigger instead of smaller.

adk
10-19-2010, 06:26 AM
I've run out of time tonight, sorry guys, but will check back in tomorrow.

adk
10-19-2010, 11:22 PM
I found a gotcha/issue with my previous setup, my underlying mesh was actually displaced using Nearest Point node (from another test I was doing) and that actually appeared to make the whole process work. Without displacement it failed to clone as expected in point distribution mode (Poly mode worked fine)

So here's a scene using latest DPKit & DPInstance, which uses a the newer Nearest Point node & Neighbor only option. Works just fine without any need to displace the mesh.

Boris Goreta
10-20-2010, 04:30 AM
Thanks for the scene files, it works !

Nigel
10-20-2010, 05:30 AM
I found a gotcha/issue with my previous setup, my underlying mesh was actually displaced using Nearest Point node (from another test I was doing) and that actually appeared to make the whole process work. Without displacement it failed to clone as expected in point distribution mode (Poly mode worked fine)

So here's a scene using latest DPKit & DPInstance, which uses a the newer Nearest Point node & Neighbor only option. Works just fine without any need to displace the mesh.


Thanks bud, that works perfectly now. I was going to ask you this morning if your object had a weightmap, cause try as I might, I couldn't get it working, unless, as you say, I was distributing the instances in poly or surface mode. This works a treat! Thanks again for the effort.

Nigel
10-21-2010, 03:35 AM
Do you think it would be possible to briefly explain what does what in this setup, like what each field controls, because all of this would obviously change if your object is larger, or smaller than your test mesh right?
Would be great to have a better understanding of whats going on there.

Thanks :)

adk
10-21-2010, 10:03 PM
Heya Nigel,

In the DPInstance panel...

Distribution tab - Instance number obviously does what Denis describes in the notes. In this case if you dial this number down (from 1062 - the number of points on the mesh) then the smaller clones start to disappear.

Nodal tab - Logic node. If you dial down [B] then the larger clones start to disappear. So between those two controls you have some pretty good fine tuning of where the clones will appear. Operation less than or equal to [B] defines the way the mesh density is processed. In this case anything less than a certain distance will produce a point with a clone. Greater than will give you the inverse situation.

So if you have a much larger mesh with larger relative distances between points then you'll need to increase [B] accordingly.

True - controls the sizes of the clones for the ranges defined by the if/then statement. (Remove the animated envelope I put there as it will make testing easier)

False - controls the sizes of the clones for the ranges outside that defined by the if/then statement.

So effectively mucking about with [B] & the True / False numbers gives you a sort of gain control on both the sizes & placement.

Happy to help so yell out if you need anything further with this mate.