Frayed Wallpaper Peeling Using nCloth, help

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2013
Is there a difference in the end result if you use a tearable constraint vs. the weld adjacent borders? I've definitely ran into problems with the tearable constraint ( my most recent troubles ) and am wondering if I should just try switching my methodology. Great thread btw, thanks for all the info.
  03 March 2013
Im still having no luck with weld, reducing max distance reduces the constraint to not enough points to tear anything, and when there is enough it just distorts, its probably because im still painting verts which can't be a good method. Still trying to figure out this workflow.
pfunk, that test looked amazing, the colorAtPoint script sounds very interesting. I read you used a fractal to define where the tears occured, to do this would you have to make the entire mesh part of the constraint and use the fractal as a glue strength map. Is this the correct workflow?
Because i want my mesh to tear in so many places to select each vert on something so high res would take ages.
  03 March 2013
Originally I used a fractal in the nComponent for the tearable constraint, but since that requires the whole mesh to be a part of the constraint, I changed to my approach of creating a quick select set of the verts above a defined white value in a texture and adjusting the glue strength on the constraint. Here's what I was doing >>

string $obj = "pSphere1"; // obj to be ripped
string $tex = "file1"; // file texture where you want rips
string $cpm = "CPM_tear"; // need to create a closestPointOnMesh or
// nearestPointOnMesh and connect mesh to it

int $numVerts[] = `polyEvaluate -v $obj`;

float $threshold = .7; // define white value threshold
string $tearVtx[];
clear $tearVtx;

for ($v = 0; $v < $numVerts[0]; $v++) {
string $vtx = ($obj + ".vtx[" + $v + "]");
float $pos[] = `pointPosition -w $vtx`;
setAttr ($cpm + ".inPositionX") $pos[0];
setAttr ($cpm + ".inPositionY") $pos[1];
setAttr ($cpm + ".inPositionZ") $pos[2];

float $u = `getAttr ($cpm + ".parameterU")`;
float $v = `getAttr ($cpm + ".parameterV")`;

float $color[] = `colorAtPoint -o RGB -u $u -v $v $tex`;
if ($color[0] < $threshold) {
$tearVtx[(`size $tearVtx`)] = $vtx;


print ("NUM VTX = " + $numVerts[0] + "\n");
print ("TEARABLE VTX = " + (`size $tearVtx`) + "\n");

sets -name "tearableVtx" -text "tearableVtx" $tearVtx;

Hope it helps!
  03 March 2013
Wow pfunk, what a handy piece of code. Been trying to get it to work, having some problems though. Just to check i've got this right; im running: createNode closestPointOnMesh -n CPM_tear;
Then in the connection editor im hooking up nCloth outMesh to closestPointOnMesh input mesh. I then get this error(and whenever selecting plane): menuItem: Object 'goToConnectedMenuItem' not found.
Not sure if this is the reason?
Then upon running the code everything executes fine but the vert selection is kind of messed up like the closestPointOnMesh node isn't running correctly, sometimes it selects all or none of the verts despite there being a ramp etc then sometimes i get things similar to this: Untitled-1.jpg
Any ideas, am i missing something? Nearly got it all working, getting this working would be a massive help though, especially to sim times. Thanks
Attached Images
File Type: jpg Untitled-1.jpg (78.5 KB, 41 views)
  03 March 2013
Close, just connect the nCloth outMesh.worldMesh to closestPointOnMesh.inMesh. If there are still problems you can always just try switching to the nearestPointOnMesh node instead and see if that makes a difference. Hope it works!
  03 March 2013
Perhaps instead of the closest point on mesh node it might be better to directly get the uvs for the verts. It can be complicated as a vertex may have different uvs for different faces. However the following will get the first uvs for each vertex:
string $obj = "pSphere1";
int $numVerts[] = `polyEvaluate -v $obj`;
for ($v = 0; $v < $numVerts[0]; $v++) {
string $vtx = ($obj + ".vtx[" + $v + "]");
string $comp[] = `polyListComponentConversion -fv -tuv $vtx`;
float $uv[] = `polyEditUV -q $comp[0]`;
print ("UV = "+$uv[0]+" "+$uv[1]+"\n");
Here is a little more on this:

Also... something that I suppose could be useful for this sort of thing... one could write a script that selects points or edges based on a texture. One could then use this selection when creating a tearable constraint. Note that edge selections are a bit better for tearable constraints as points will essentially tear all connecting edges. To do an edge texture selection script one might only select an edge if both vertices for the edge are over the texture threshold.

Last edited by Duncan : 03 March 2013 at 05:43 PM.
  03 March 2013
Wow, interesting. Works great and seems to be faster than plugging things through the closestPointOnMesh node. Thanks Duncan!

Also if you are concentrating the tears in a certain area ( currently I'm ripping only the front of a mesh ) you can limit either of these scripts to just using the selected verts and make it run a lot faster. It can get pretty slow with high res meshes so if you can lower the number of verts running through the script definitely try and do it.
  03 March 2013
maybe i throw in some technic that i use to simplifie some things..

i got good results importing b/w textures on paint selection and
create selection sets out of this to tear and shatter...


ohh and Mister Duncan, can you lighten up my mind and get in some detail to my
post from side 1 ?
  03 March 2013
Quote: Close, just connect the nCloth outMesh.worldMesh to closestPointOnMesh.inMesh.

Sorry bit of confusion here on my part, by this do you mean:
connectAttr outputCloth1.worldMesh CPM_tear.inMesh; ?

Quote: Perhaps instead of the closest point on mesh node it might be better to directly get the uvs for the verts..

How would you work this into selecting verts based on texture without going through the closestPointOnMesh node? I had a quick go merging the two scripts, am i along the right lines in thinking that you would still need the colorAtPoint node to query the colour at each vert then, like pfunks, based on threshold, pop them into a set? Its just working it into obtaining the uvs for each vert - will keep trying.

So much information in this thread, wish i knew enough to get it all wholly.
  03 March 2013
yup still need colorAtPoint, just use the UV values derived from the script that duncan posted.

string $obj = "GEOM_head";
string $tex = "tearableStrength";
float $threshold = .7;
string $tearVtx[];

int $numVert[] = `polyEvaluate -v $obj`;

for ($v = 0; $v < $numVert[0]; $v++) {
string $vtx = ($obj + ".vtx[" + $v + "]");
string $comp[] = `polyListComponentConversion -fv -tuv $vtx`;
float $uv[] = `polyEditUV -q $comp[0]`;
float $color[] = `colorAtPoint -o RGB -u $uv[0] -v $uv[1] $tex`;
if ($color[0] < $threshold) {
$tearVtx[`size $tearVtx`] = $vtx;

sets -name "tearableVtx" -text "tearableVtx" $tearVtx;
  03 March 2013
Cheers pfunk, managed to get it working last night (slight proud moment hehe).
Gonna try and do as Duncan says and get it working so that it will select the edge in between if both verts are under the threshold.
Out of curiosity, what kind of resolution geometry should i be aiming for? Its still looking sort of chunky on some edges, yours looks really 'stringy' and smooth around its edges, did you use a lot of stretch? Wondering if i can use a texture to fray edges more?
  03 March 2013
Originally Posted by flares: ...Wondering if i can use a texture to fray edges more?

This technique might help you (see attached scene).

1.Create a toon line node for the output nCloth mesh(after applying the tearable surface constraint).
2.On the toon line node turn off profile and crease lines, so there are only border lines. Also set border break angle to zero and turn on resampleBorder.
3. Map line width such that it is zero on borders edges you wish to be clean and noisy where you want jagged edges.
4. Assign a default pfx brush to the toon line and set flatness1 to 1.0 on the brush.
5. Convert the toon line to poly (pfx to poly) and assign the same shader you are using for the cloth.
6. Go to a frame where the cloth is ripped. On the toon node adjust line Width. Lower maxSegmentLength for finer tessellation. With a noisy map and fine tessellation you can get thread like roughness, while with a smoother map you can get something more like torn paper.

One can also assign pfx brushes with tubes to the toon line for 3d frayed threads.
Attached Files
File Type: zip (8.9 KB, 77 views)
  03 March 2013
GREAT idea! I used toon lines to emit particles on tearing stuff but never thought to add detail to the edge with it.
  03 March 2013
This is brill, thanks a bunch Duncan!
  03 March 2013
Just wanted to add my appreciation, Duncan, and to everyone contributing to this thread.

reply share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 08:29 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.