djPFXUVs for maya now has a UI and does grass

david | python,rendering | Saturday, July 28th, 2012

A while back I posted a script called djPFXUVs that could be used to quickly re-layout uv's for paintFX leafs to help with the task of building and assigning more interesting textures. Today I thought I'd share an updated version of that script, which as you can see here, even has a UI.

djPFXUVs UI

Support for multiple uv sets

A new feature is the option to choose a source and optional target UV set, where the target can be either the source, any other existing set or a new one. This means textures for various material attributes do not need to be sharing the same uv's. You could use one uv set for diffuse color and another for reflectivity, and thus create even more variations amongst leave textures.

New Grass Layout Mode

UI showing grass mode

Grass Layout Mode does not create a tiled layout like the leaf modes. Instead each shell (ie each blade of grass) is scaled to the specified blade width and then randomly positioned along the U-axis in the primary uv quadrant. Here is an example showing before...

grass_uvsBefore.jpg

The nice thing about the way the original paintFX uvs are layed out is the way the tallest blades use the full V-axis while shorter blades use relatively less. djPFXUVs maintains this height relationship, so after grass layout with blade width = 0.5 we get something like this...

grass_uvsAfter.jpg

In the above image I just selected a few shells to give a clearer picture of what is happening. With thousands of blades of grass distributed randomly, all you'd see would just be a mass of lines.

Here is a snapshot of the hypershade showing a simple example of how you could take advantage of this new uv layout.

hypershade snapshot

 

colorMain is a rampTexture set to "U Ramp". Because blade of grassĀ  is randomly distributed somewhere in the U-axis, each blade will be textured with a narrow strip of this ramp and the gradation seen in this snapshot will be barely noticeable on a single blade. This ramp therefore can be thought of as a kind of probability distribution. The narrow brown strip to the right of the ramp means approximately 10% of the grass blades will get that brown color, the rest will be various shades of green.

colorBase is a rampTexture set to "V Ramp". I am using this to create a variation along the length of the grass. My grass will be browner near the base.

colorBaseMask is a rampTexture with some noise added.

I combine colorBase over colorMain using colorBaseMask in a layeredTexture (colorLayers) and the result is used as the color in a phong material. This is just a simple example. Nothing fancy. If you wanted photoreal grass you would need to make a bit more effort, but I think this example helps illustrate the idea behind grass layout mode.

Here is a quick render

grassTestRender.jpg

You can find djPFXUVs on my downloads page. This is a python script. To use it you'll need to put djPFXUVs.py somewhere in you scripts path, then run the following:

import djPFXUVs
djPFXUVs.layoutUI()

10 Comments »

  1. Amazing script! Thank you for doing this!

    Comment by Schmidt — October 9, 2012 @ 8:39 pm

  2. Hello, I came upon your fantastic script a little while ago, and it has been an absolute lifesaver so far! Unfortunately I recently ran into an issue that I so far have been unable to troubleshoot, and I was hoping that you might have a solution. As it stands, whenever the frame number changes in my scene, the UV's on my trees revert back to their original state before running the script. I would greatly appreciate any insight you might have regarding this problem. Thank you again for your otherwise amazingly helpful tool.

    Comment by BubbaRay — October 17, 2012 @ 7:51 am

  3. I've been asked this same questions a few times, and since I do have a workable solution I wrote it up in a blog post here... http://www.djx.com.au/blog/2012/10/17/djpfxuvs-with-history/

    I'm glad you are getting some use from the script, by the way, and thanks for your kind words.

    David

    Comment by david — October 17, 2012 @ 11:29 pm

  4. Thank you for doing this!

    Comment by antonyyen — December 20, 2012 @ 6:40 pm

  5. Hi David,

    Can you please tell where exactly we need to copy the script. I have tried but failed to run the script.
    I am copying the script at following place in my local drive

    C:\Program Files\Autodesk\Maya2013\scripts\others

    Let me know where I am wrong.

    Thanks
    Rupinder

    Comment by truerswalia — October 4, 2013 @ 7:29 pm

  6. You probably need to set up your python sys.path to point to that folder. Better still, use a different folder. I always advise people not to use the maya install folders. You should use one of your local scripts folders, which on windows would be something like
    C:\Users\david\Documents\maya\2013-x64\scripts

    If you do want to use a folder that maya does not see by default you can easily add it to the system path with the following lines of python...

    import sys
    p="C:/myCustomScripts"
    if p not in sys.path: sys.path.append(p)

    Comment by david — October 4, 2013 @ 10:00 pm

  7. Hi David,

    I have been using your script so often with Onyx trees. There are some trees which have leaves with a few different poly counts and UV layouts. The version of the script I have been using sometimes tears or stretches the UVs when placing them in the 3x3 grid. Is there a way to execute this script on these leaves to prevent the tearing.

    Thanks for all the support you have been providing!
    --Jeff

    Comment by jferrucci10 — October 26, 2013 @ 3:19 pm

  8. I think that my script is making the assumption that the uv's start off inside one tile. Could it be that the onyx leaves are covering more than 1 tile? Thats the only thing I can think of that would explain the stretching. If you can send me a simple scene that demonstrates the problem I can probably figure out a workaround.

    Comment by david — October 27, 2013 @ 3:43 pm

  9. Very easy to use

    Comment by zss — December 23, 2013 @ 9:11 pm

  10. nice````

    Comment by yubaqi — November 5, 2014 @ 12:05 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