Creating High Res Polygonal Models
Manual process for laying out UVs on high res polygonal models using shader groups as selection sets.
1. Assign different colored shaders to the low res mesh based on which direction they are facing
2. Smooth the mesh to level two using the polySmoothFace
3. Select the contents of each shaderGroup one at a time and project onto it from the most advantageous direction.
4. Set the polySmoothFace.divisions attribute back down to zero
5. Select the projections one at a time and move them apart. Try to pack the shells in as tightly as possible.
6. Assign a single shader to the entire mesh at the object level.
7. Delete unused nodes.
This process works fine and can definitely be used to create UVs on smoothed polygonal characters. However going through and assigning shaders to each face on a model by hand is labor intensive and monotonous at best. Creating projections from these shaders one at a time again is repetitive and slow. By using MEL to do these tasks for us we can spend more time painting textures and less time laying out UVs.
Mel scripts for laying out UVs:
autoColor:
Creates six shaders Xpositive, XNegative, Ypositive, Ynegative, Zpositive, and Znegative. Automatically evaluates the direction of the normal for each face on a polygonal object and assigns one of six shaders to that face based on the results.
autoShellAssign:
Breaks up the shaders created by autoColor. Creates a separate shader for each shell on a polygonal object. Retains the color information which will be used to direct the projections created by autoProjection
autoProjection:
Automatically projects the faces in each autoColor shaderGroup based on the direction determined by the shader. For example faces in the Xpositive shader Group are projected from the X positive direction.
GraphFaceMaterials:
Graphs the material on a polygonal face. Maya's default Graph Materials button will graph all the shaders on a polygonal object even if only one face is selected. This script graphs only the materials on the selected faces.
scrollUp:
Selects the next projection in the history of a polygonal object.
scrollDown:
Selects the previous projection in the history of a polygonal object.
selectProjection:
Selects the autoColor projection that a face belongs to. Select a single face on the shell you want to move. Execute selectProjection. The shell's corresponding projection is selected.
Automated Process for Laying out UVs on high res polygonal models using custom MEL scripts.
Example File: PrimitiveMan_Example_01.mb

1. Run autoColor on the low res polygonal mesh. This will assign color coded shaders to the faces of the polygonal object. Each shader represents a projection. The color represents which direction the projection will come from. For example the Zpositive Shader is light blue. looking at the mesh an artist can quickly tell that the faces that are light blue will be projected from the front.
2. Edit the assignments of the faces to optimize the shells. At this point you should stop and look at the color of the faces in the mesh. Make sure that each face will be projected from the direction you want. If a face seems like it would be better off getting projected with a different shader group select that face and assign the other shader. Try to reduce the amount of seams that will occur. Remember that the autoColor script is intended to be used only as a starting point. The real decisions about direction should be made by you at this stage.
3. Run autoShellAssign to assign a separate shader to each shell of UVs that will be created. If you try smoothing the mesh and running autoProjection after step 2 you willl notice that 6 projections are created. You will have accurate UVs and little to no texture stretching. However You will also notice that the UVs for parts of your model will be overlapping. This will cause areas of the map to repeat. Reusing areas of your texture map by overlapping UVs is good if you mean to do it. That isn't the case at this stage. We need to be able to move each shell of UVs created individualy so that we can move areas that overlap apart.
The MEL script autoShellAssign assigns a separate shader to each shell of UVs that will result from the projections we create. Because each of these shaders will eventually become a projection we will be able to use these projections to prevent overlapping UVs. Although this will not eliminate all overlapping it will eliminate the vast majority of the problem.
4. Combine any shells that can use the same projection without overlapping. Use the MEL script graphFaceMaterials to find the shaders on individual shells. Although autoShellAssign is useful to prevent overlapping it has a tendency for overkill. Not every shell on an object needs to have it's own projection. In fact if it did we would quickly end up with an insane amount of history on our character. At this stage you should go back and use the graphFaceMaterials script to determine which shader is on each shell and try to combine as many of them as you can into as few shaders as possible.
5. Smooth the mesh to level two using the polySmoothFace node. Be sure to use the exponential smooth algorithm as the linear algorithm will not update the UVs correctly once they are projected. Note that the whatever smooth level the model is at when it is projected will be the maximum smooth level for the model. Usually the highest you will want to go is level 2.
6. Run autoProject to create projections based on the shaderGroup assignments. The autoproject script selects the faces contained in each ShaderGroup on the object one at a time and creates a projection onto those faces based on the name of the shader. For example the Z negative shader will be projected from the negative Z direction. Note that because the script works based on the names of the shaders you should not rename any of the shaders. Doing so may cause the script to fail.
7. Set the polySmoothFace.divisions attribute back to zero. Smooth level two is usually pretty heavy you will want to set the divisions attribute back down to zero while you move the projections apart.
8. Use the MEL scripts scrollUp scrollDown and selectProjection to select each projection individually and move them apart so that they no longer overlap. Use the projection size attribute to pack the shells in as tightly as possible. Depending on the complexity of your model and how careful you were when combining shaders during step 4 you should now have quite a few projections in the history of your mesh. The History of your object should have the polySmoothFace node first then the projections after it.

If you look in the UV texture editor you will see that the UVs for your mesh have been created. However because the Image center X and Y attributes of all the projections are set to 0.5 the projections are all piled up on top of each other. Also there is a good chance that the scale of each of the shells is either too big or too small for the UV texture space.

If you select your mesh and look in the channel box you will notice that a projection size attribute has been added underneath visibility. This attribute now controls the scale of all the projections created by autoProjection. By adjusting it up and down you can scale the UVs of the mesh to fit the UV texture editor. Keeping all the projections the same size will keep the scale of the UV shells proportional to each other. This will keep the scale of the texture map uniform across the entire surface of the mesh. It will also help reduce the appearance of texture seams.

If you click on the first projection in the chain and hit the T key you will notice that the projection's move handles will show up in the UV texture editor. Use these handles to move the projections apart so that their UVs no longer overlap. By using these handles to move the projections apart instead of selecting individual UVs we can ensure that this UV set will function on any smooth level. This is because by moving the projection handles we are actually moving the projection in relationship to the UV texture editor and not the UVs. Notice that no polyTweakUV nodes are added when you move these handles.

Attempt to pack the UV texture editor as tightly as possible. This will ensure that your texture maps have sufficient resolution.
Example File: PrimitiveMan_Example_02.mb
Do not select individual UVs and move them. Do not sew any edges. Do not hit Layout UVs. Doing so will cause your UV set to go totally wacky when you change the smooth level of the mesh.
Once you have the first projection selected you can use the scrollUp and scrollDown scripts to quickly select the next or the previous projection in history. I assign these scripts to hotkeys so I can scroll up and down quickly. I use Alt+1 for up and Alt+2 for down. ScrollUp selects the next Projection ScrollDown selects the previous one.
you can also use the selectProjection script to tell you which projection contains a specific face. Select a face on the shell you want to move and execute selectProjection. It's corresponding projection will be selected. Again I assign this script to a hotkey, Alt+3, so I can get to it quicky.















