Deviant Art is a place where people all around the world can share their artwork or literature and even photography together. And in the more recent years a lot of other incredibly magnificent creative projects/work/funzies.
In this tutorial I'll go through the concept of texel density (TD) and also show you how to use my texel density MEL-script for Maya (available for download). The script rescales all the UV-shells of a selected mesh so that they get exactly the same amount of TD (texel density). It works for Maya 2008 to 2012.
Posted by Niteshade on Mar 11th, 2012
:: Intro ::
This tutorial will show you a little about texel density (TD) and how to use the TD-script I've uploaded.
This simple MEL-script for Maya will rescale all the UV-shells of a selected mesh so that they get exactly the same amount of TD (texel density).
:: What is texel density? ::
First we must answer: what is a texel?
Texel stands for TEXture ELement and is the fundamental unit of texture space. Textures are represented by texels in the same way that pictures are represented by pixels. They are the smallest "puzzle piece" of a texture. They are not the same thing as pixels because a texel is a container for the pixels.
So naturally, texel density is the amount of texture resolution on a mesh. A high TD equals a detailed texture with lots of information (density) while a low TD equals blurryness - even if you have a high resolution on your monitor or on your texture, the TD can still make it very blurry.
The TD is ofc affected by the size of the texture, but there are also more factors that determine the TD. These three factors are:
If you change any of these, the TD is also changed.
:: Why is texel density important? ::
When working in game development teams it's important that the group decides what model scale, texture sizes and texel density to use on the art assets - or things will not be proportional.You can't have an artist producing over-sized model or over-detailed textures in an environment where the other assets are not of the same scale and/or quality. So the best thing to do is to agree on a TD-range that everyone will use.
Now, it's important to remember that this isn't something you should just stick to blindly. It's quite common in game development that you have different TD on different art assets. Characters andweapons that are close up to the camera (such in an FPS game) usually have higher TD than the environment (floor, ceilings, etcetera). It's also common to have a higher TD in the face of a character - because that's where the player usually look. If you take a look at the game "RAGE" by id Software you will notice that the TD fluctuates A LOT from model to model - even in the environment. This is okay. It's also okay to set a lower TD for things that the player -usually- will not notice: such as things that are far off in the distance (skybox models, backdrops, etc), or under a car.
The Half-Life 2 muscle car (the yellow one) is a great example. On that model, you have a higher TD on the dash board than on the chassis because that particular part of the car gets much closer to the camera once the player enters the car. At the same, the underside of the car has a much lower TD than the chassis - because the player rarely see this part of the model. Remember to think about this when UV-unwrapping your models. "Is there some area of my model that is unlikely to be visible?" - if the answer is yes, then scale down that shell so it gets less texture space (and thus: less texel density).
:: The TD script ::
I'm going to demonstrate this TD script and explain what it does. So first you will need to install the script.Install the script like any other Maya script. You can download it from my ModDB profile here:
Download, unzip and place the *.mel file in your script folder. Use any of the below paths:
C:\Documents and Settings\ -username- \My Documents\maya\ -version- \scripts
X:\Autodesk\Maya -version-\scriptsNow you are ready to try out the script.
Here in this first picture I've created a simple primitive: the cube.I've also UV-unwrapped it in a VERY dumb way as seen here in the second image
As you can see, the different UV-shells of this cube have totally different size, resulting in very different texel densities.
Here in picture 3 above, I've applied a new lambert material and assigned the UV checker -image to it (included in my download). By now you should have a clear understanding of what TD is. Notice how the upper left side of the cube looks blurred while the one below has much, much higher detail. The TD is waaaay off on these two sides. We are going to fix that with this TD script.
First you need to select the mesh (optional: and open up the UV-texture editor). Then you use the (bottom left input field) and make sure it is set to "MEL". It should NOT say "Python". Now write:setTexelDensity...as seen in the below picture.
A new window labeled "Set Texel Density" will appear and ask you to enter a TD value and a texture resolution. Feel free to experiment here if you want, you can always step back and "Undo" this action. If you don't know what to write here then just type in anything. For this demonstration I wrote 3.0 and 64.0 (screenie says 1.0 but that is false). Now the script will rescale all the UV-shells so that they get exactly the same TD.
On a cube it's easy to see that the TD is fixed - all sides are of equal size. But on a complex mesh it's a lot harder to do so. You may apply a UV-checker texture and "eyeball" the TD by manually scaling each UV-shell, but that way you will put more work into this than you really have to.
Now last but not least. If you don't want to type "setTexelDensity" every time you want to run the script, you can always create a new button on the "Custom shelf" in Maya. Simply switch to the custom shelf - it's where all the tabs are (labeled nCloth, Fur, Rendering, Polygons and so on) - see the below picture.
Next up, write "setTexelDensity" in the command line just as before - without the quotation marks ofc. But this time DON'T PRESS ENTER. Simply mark the entire row/word "setTexelDensity", click with the middle mouse button (Mouse 3) and move the mouse cursor to the custom shelf and voila - you have a custom script button.
I hope that you found this tutorial useful. And as always, subscribe/track to my user for more future tutorials.