djPFXUVs with history

david | animation,python,tutorials | Wednesday, October 17th, 2012

A few people have asked me if there is a way to use my uv layout script, djPFXUVs, on a paint FX mesh that is animating. The answer is "yes". Keep reading if you are interested in knowing how...

When you convert paintFX to polygons the resulting poly mesh retains the paint FX stroke as part of its history. This means that any animation on the paint FX propagates to the poly mesh. You need this if you want your trees or grass to bend and sway in the wind.

Now if you use djPFXUVs to layout the uv's on the leaves of an animating tree, blades of animating grass, that new uv layout will be lost as soon as you change frames on the timeline. This happens because the paint FX stroke is still in the history of the poly mesh. When the paint FX stroke changes shape the poly mesh is recomputed and that includes resetting the uv's.

So instead of doing a one time uv layout we need a way to add the uv layout to the poly mesh history, and we need it to come after the paint FX conversion.

The solution is to make a copy of the poly mesh. This should be just a simple duplicate, without duplicating the input connections. To put it another way, we make a static copy of the poly mesh - static because that copy has no history. Then we do the uv layout on the static mesh. Now we have a static mesh with good uv layout and an animating mesh with the not so good, original paint FX uv layout.

Finally we can use "Transfer Attributes" from the mesh menu to copy the good uv layout from the static mesh to the animating mesh. Simply select the static mesh first and shift-select the animating mesh, then do "Transfer Attributes" with the following options:


This will create a transferAttributes node in the animated mesh's history that links it to the static mesh. Since the transferAttributes comes after the paintFX conversion every time the mesh is recomputed, the transfer of the uv layout will follow.

Thats it. We now have a useful uv layout on an animating mesh.

There is unfortunately one more thing I should mention. Having the transferAttributes node in the animating mesh's history has a significant impact on playback speed. The slowdown will be more or less noticeable depending on how many polys you are working with. It is not ideal, but if you want animated trees and grass and the type of extra texturing advantages of a good uv layout, you may be prepared to live with it. A strategic work flow might be to have some kind of shelf button switch (or marking menu) so you can make the static mesh visible while you are working on the scene and testing renders, and make the animating mesh visible for final renders.

Here is a simple example scene.




  1. Holy Diver that was fast! Seriously, words can not express how much help you and your custom tools have been to me with my latest personal project. This fix alone has probably saved about 2 months of my work, thank you so much!

    Comment by BubbaRay — October 18, 2012 @ 11:30 am

  2. I get this error message when running the script. I am follwoing Alex Alverz tutorial on PX for trees.
    I am using Onyx tree software to generate Maple trees.

    I selected the geo for the leaves and ran the script and get the error message below?

    import djPFXUVs; djPFXUVs.leafLayout(3)
    djPFXUVs leafLayout start
    **** uv set 3 not found.

    djPFXUVs leafLayout done

    Comment by bldrnr — January 18, 2013 @ 1:46 am

  3. The problem is you are using the old command syntax with a new version of the script. The new version of the script has a UI that can be launched like this...

    import djPFXUVs

    If you wanted to run it without the UI (as part of your own pipeline script maybe) then the syntax for leaf layout would be...


    In fact there are other keywords you can specify now... uvSet, sep, uvSetTarget
    You can get a better idea about how it works by opening the script in a text editor and looking at the comments.

    You may have missed this post too...

    Let me know if you still have problems though.

    Comment by david — January 20, 2013 @ 12:13 am

RSS feed for comments on this post.

Leave a comment

You must be logged in to post a comment.

Powered by WordPress | Based on a theme by Roy Tanck