While working on the next video tutorial I appear to have found a bug. The drop sheets over primitives and figures are clearly okay, but when I re-created a conforming costume this caused the plugin to crash unexpectedly.
I was able to narrow the problem down to the costume mesh. The mesh must be triangulated before converting it into a conforming costume. The previous example with the Long Green Dress was triangulated but the new test costume was not.
The 0.0498 release version of the plugin removes the quads / triangle mode but this problem is more likely related to how the facet mesh moves through the modifier stack. The real cause is as yet unclear. The fix is to make sure to manually triangulate the mesh.
After the public release of the latest code for the Cloth Deformer I wanted to revise the results I posted last year and re-create them with some video tutorials.
A drop sheet is always the most basic test to run – if that fails to work then the simulator is worthless. So for the second tutorial I wanted to drop a bed sheet over a moving figure and then I decided to try and push the simulator and keep the figure moving under the sheet for at least 10 seconds.
It took a several draft simulations to get it right. There were a few problems when the hands moved into the sheet and then proceeded to push through it – so I had to adjust the animation to avoid this problem and keep the hands out of the way. Since the simulation result is not known until it has run, getting a hand to interact with the cloth part the way through is just too complex.
Something to keep in mind with cloth simulation is that in reality you can be constrained by clothing and cloth. Tight non-stretch pants won’t allow you to run easily and when you’ve been double wrapped up all cosy in a bed sheet and quilt it is hard to suddenly spring out of bed without kicking and fighting your way out.
I also used different settings from the tutorial video. I needed to set much higher friction and dampening values – otherwise the sheet slid off the figure and half the way off the bed by the end of the simulation to leave her exposed. Also in the tutorial video some kooky key frames had got in and turned her elbows into bent straws. I didn’t notice that until it was too late and uploaded, so hopefully the focus is all on the cloth.
Each simulation took at least 4 hours to run. I spent at least 4 hours on key framing the animation (which isn’t that great) and the rendering took almost 4 hours as well – so running the simulation (while I slept) wasn’t really that big an issue in the production time.
The twitching in the animation was much lower than I expected but I’m still more personally interested in the potential of the still frame results with my plugin.
What really worked surprisingly well was when she turns over to one side and also how the legs moved under the sheet.
A final note was that I might have made the animation physics even more interesting by using the Jiggle Deformer but alas it is not currently compatible with the Cloth Deformer. The trouble is that Jiggle will not produce the same results when it is run at 150 fps as when it is run at 25 fps. I will have to add a new recording mode into JIggle to use it with Cloth. This would need to allow the results to be saved and played back without recalculation.
One of the features of the new version of the Cloth Deformer is Grab Zones. Interaction with hands and other moving objects that need to grab the cloth can be faked by using a spherical zone(s) at the start of the simulation to grab any number of vertices of the cloth. When the grab object is moved the held vertices move with it to maintain the same local position in the zone, so they rotate as well as translate.
This animation shows a Michael 5 figure for Genesis trying to get attention by waving a slightly ripped t-shirt. The cloth was given 4 seconds of animation to drape before starting to wave it about. Some proxy objects were used on his arms and hand to prevent any possible collisions with him and get a very fast simulation result. The shirts self-collisions all work well – but moving at that speed it’s hard to see any poke-thrus anyway.
In future I’d like to be able to have the grab zones turn off somehow to release their held vertices. Also to be able to grab vertices during the simulation would be important. That will be easy to code but a special ‘zone’ primitive is something I’ll need first so that it can have the right on/off switches in the properties interface.
More demanding simulations, such as a full length dress, push my plugin to its limits. That doesn’t mean it can’t get results though. While also trying out Carrara 8.5’s stability with a Genesis 2 figure this simulation took about 2 hours to run, allowing about 5 seconds to go from a zeroed pose to being seated and then drape. Again it is the still image that I am very happy with here, worth spending some extra time to do a little embroidery on the dress.
What is hidden in this render is that the collar of the dress sort of broke when the character’s neck bent. The bent elbow is also a dangerous area for any practical simulation because the cloth can end up with nowhere to go. Use of simple primitives under the skin is a good safety precaution. Unlike certain other simulators, when mine goes wrong it doesn’t end up in a disaster.
The current code looks at all of the possible collisions of a thick vertex with an assumed convex surface – an elbow pit or neck is a concave surface. The treatment of more complex surface interactions is what I hope to code next. When viewed as an animation the fabric actually twitches a lot between frames, here and there. If the surface collisions can be processed with more consistent results this should diminish. With simple primitives there is never any twitch.
The arbor prop was not used for collisions, a few cubes were placed into the scene and then hidden for the bench seat and arm rest.
The conforming hair is not dynamic but morphed to get it out of the way for the render. Such a hair style could possible work with draping too. The simulation can handle layered cloth over cloth. Internal cloth to cloth collisions are still treated as particle to particle hits to push them apart.
What is also on display here is the new Subdivider plugin. You can get this in my Laboratory to try out. It implements Loop(s) subdivision which is optimized for a triangular mesh. Carrara uses Catmull-Clark subdivision which works with quads. The Subdivider can be applied at the end of the Modifier stack when the simulation is finished to get 4 times the facets while smoothing out the cloth.
My plan for the plugin was always to expect that where it was to fit the figure’s torso to keep it as a conforming actor then allow for dynamics when it came to capes and dresses etc. Again this simulation example did break but maybe the next version and my theories about concave and convex surfaces will work…The good thing now is that with the simulation timeout problem fixed I can run many more of them than before.
As I started to try out more complex simulations with full figures and drop cloths and costumes a serious issue with the Cloth Deformer emerged. A task switch in windows or a screen saver timeout would totally kill the simulation. The only way to keep it going was to start the simulation and then make sure to give the mouse a shake every few minutes. If I was away for too long then hitting escape to stop the simulation would immediately bring up my blank screen saver letting me know it had died.
I could not find an answer or get much help with this and had to try and carry on without being able to run longer simulations then walk away or leave them overnight. I had to be there at the desktop or nearby and keep an eye on the clock.
I was looking for a solution in the wrong places and wasting precious time too. I assumed it was a Carrara SDK issue and that I was doing something wrong. It was really only when I noticed that after running a big demanding render on multiple cores that upon returning to a word document, after leaving it open on the desktop untouched for an hour, that as I typed there was no response to my keystrokes. After more than a few seconds I could start to type okay.
So I seem to have finally understood and hopefully fixed this problem. Windows is deciding that despite it working hard and doing millions of calculations that my simulation is not important or not responding and then making it, or the system, idle after a certain time period. Only by calling WINAPI SetThreadExecutionState(…) with the right flags, very frequently, in all of the simulation loops, can the plugin now be left to run on its own.
Here is a link to the old WIP Thread over on the archived DAZ 3D Forum.