Jump to content
Sign in to follow this  
FishMan

[3D/2D] Setting up your Texel Density

Recommended Posts

Hello.

In this tutorial I would like to talk about texel density. 

What is texel density?

Before answering this question first of all it is necessary to define what is a texel...

 

From wikipedia:

Quote

A texel, texture element, or texture pixel is the fundamental unit of a texture map, used in computer graphics. Textures are represented by arrays of texels representing the texture space, just as other images are represented by arrays of pixels.

Texel simple language - it is a pixel of the texture. Even if these concepts are similar, but not identical, you can perceive texel the same as the pixel. And a texel density is the number of texels per unit of the squre virtual (game) space. Or, other words, the amount of pixels which are covered by a UV-Shell.

 

Why texel density is important and where?

It's simple. The higher a texel density, the more detailed the texture on the screen.

And the opposite: the less texture density, the more blurred the texture will be on the screen.

 

Where it is important? Basically everywhere! Not only iside a single asset, but also between a different assets as well.

 

Game scenes are usually composed of a plurality of objects. And because the games do teams consisting of several people, and because it is difficult to determine the size of your texture relative to other objects this may lead to the fact that each object in the scene will have varying degrees of detail. Here is an example from Internet:

Xf3p1Oh.png

As you can see on this picture walls and barrels are more crisp while the texture on the floor is very blurry. This is because they have a different texel density (pixels  in a meter). Also pay attention that walls, barrels, floor etc. - are all different assets (actors/entities), which can be made by a different people at the same time.

 

So that's why It is important that texel density should be standardized (at least for an environment assets) on the project you're working to have constistant details on every asset. Otherwise some objects in your scene will be blured while some will have a very sharp details and overall they will contrast each other.

 

But above all, it should be said that the texel density is not a mandatory rule. It can vary depending on your needs and possibilities, well at least if you know what you're doing. Experience shows that you can retreat from exact values within 25%-50% between different objects, but you should avoid this as much as possible.

 

You can vary texel density inside a single object as well to distribute texture space proportional to the number of details that you want to show.

For example if you doing a vehicle, you can double texel dencity on parts with high dencity of details like steel hawser, or for parts which player will be able to see very close (for example parts of the cabin) and you can decrese texel density for parts which is gonna be hard to reach for the player (such as the bottom) to save some texture space.

 

Here some examples:

pNLgDtC.png

IUhxmyc.png

 

And here what you gonna get if you if you do not pay enough attention to this issue:

RcmMh0c.jpg

 

Hold on, pixel in a meter? Should we say pixels in a SQUARE meter maybe?

Um, not actually. For density of 512, there are 262144 pixels in a square meter, so the density is a 262144/m^2.

Now look at this value of 262144, does it says anything to you? Me neither. Thats why we are using a "linear" or "flat" values (like for one side of our square) for measuring the texel density. For example 512/m sounds more reasonable than "mathematically correct" value of 262144/m^2.

 

But we will return to a square meters later.

 

Should we use any software for this?

 

Well, I met a couple of ways in the Internet about how to calculate it manually, when I was prepearing this material.

But I will not bring this methods here, because it's hard to imagine a person who will do it manually every time.

 

There are some free software solutions that will allow you to calculate and/or set texel density for your model.

Lets talk about them.

 

First lets talk about 3ds max.

 

How we do it in 3ds max?

 

Solution #1:

 

A small script made by me... I called it Texel Denisity Tool, yes-yes my imagination is unlimited, I know, thank you :D

Well, in truth I took "UV Normalizer" script from script spot made by Manu Pratap and rewrote it.

Now the script is more powerfull and easy to use.

 

The interface is looks like this:

texeldenstool.jpg

 

It duplicates the interface of the corresponding utility from Maya.

 

Here is a download link.

 

How to install:

Just drag and drop it on 3ds max viewport or use MaxScript->Run Script... from the main menu.

Then use Customize User Interface to assign this script to a shortcut or frop it on Toolbar. It will be in the category Custom and its called Texel Density Tool.

 

Here is a short video showing this process:

 

 

What should I do before use it?

First of all you must decide what value you will be using. And the problem is that it depends on your project.

But in today's games (at least in those that I worked) I have seen the values of 400-512-1024 pixel per meter (p/m) on average.

 

Remember: the higher a texel density on your project, the lesser you can bake on your textures and the more you'll have to rely on tiled or trim textures as well as complicated shaders with some fancy blending methods to produce an acceptable game art. And do not forget about the texture memory and perfomance, this things are not boundless. So choose wisely.

 

Lets say you choose 512/m and your engine is Unreal Engine 4.

 

Next you should set up your units (Unreal using centimeters). Here is a tutorial about how to set up centimeters in Max. Pay attention that you can leave "Generic Units" in "Units Setup" tab and only change system units to centimeters (And I suggest you to do that, because max works more handy in this case).

 

Here is the setting I'am using for example:

TYmK3rQ.png

 

Ok. Now we are ready for set our texel density.

 

So how do you use this script?

Pretty simple - you just launch this script.

Set the a desired texel density in the field to the right of the "Get" button.

Set your target map resolution and press "Set" and you're good to go.

Super simple.

 

But make sure you're added Unwrap UVW modifier to your model before use this script.

 

Solution #2:

This solution is called Advanced UV Normalizer. The only problem is that from version 2.0 it is no longer free.

I also heard that TexTools can somehow adjust texel density but I've never tried because I don't like TexTools.

 

Anyway. I've got an old free version of Advanced UV Normalizer which you can download here.

And here is an official site where you can buy a lastest version of this script in case you need it.

 

How to run?

You can drag & drop it in max viewport. Or u can select it via Scripts>Run Script.

Here is the short video:

 

So how do we set texel density for crist sake?

 

Fist of all you should add an Unwrap UVW modifier to your model and launch Advanced UV Normalizer.

Next there are two ways of getting and setting texel density.

 

First method:

Because we know that we are using 512/m, we can create a cube with size of 1 cubic meter and each side of this cube will already have a necessary texel density. Well, you know, because by default its UVs are occupy all available UV area. So it doesn't matter what texel density you choose. If you're using right texture resolution for "1 cubic meter cube" it will always have the right density (for a specific texture resolution as I said). For example: if your density should be 1024 you can create a "1 cubic meter cube" apply 1024x1024 texture on it and you good to go - this cube will have the right density.

 

Now, you can apply a checker texture on it, place your model near the cube and scale and compare UVs untill they match.  Just joking. that's how people do it in the past. But today we have this piece of software, which is allowing us to "grab" the necessary texel density and apply it to any other model.

 

To do this we should select "custom" from a drop down menu, type 512 pixels to Height and Width of Texture Size (because density is 512/m), select one side of the cube in UV Editor and press "Get Texel Density" button.

Here are the values that you should get:

trjcbuy.png

 

As you can see Ratio Geom/Pixels showing 5,12 - this mean 512/m, but because our units are set to centimeters, and because there are 100 centimeters in 1 meter it showing us 5,12 pixels (per 1 cm).

 

Ok. So now we have our texel density saved.

To apply it to a different mesh, after you get right values, you simply can select an object where you need to set a texel density, set a target Texture Size (1024x1024, or 2048x2048 for example) and press "Normalize" button and thats it - you've set a texel density for your model.

 

Here is a short video showing this process:

 

Second method:

Ok. Now after we know how this values work. I'll show you how you can set them manually.

 

Ok, lets make a scheme for our for our convenience:

flebLdo.png

 

First of all we need to select Custom from a dropdown menu [1.], then we need to set our target Texture Resolution [2.]. I should mention before its too late that "Target Texture Resultion" is a resolution of a texture that you will apply in the engine on the asset you're producing, so if you're going to use for example 1024x1024 texture for this asset, you should type 1024x1024 here.

 

And here where things become a little bit complicated.

We need to set our units [5]. Pay attention that units must be squared. So in our case we are using centimeters, it's mean that we should take 100 centimeters (one meter) and square it, so the final value will be one with four zeroes (10000).

 

For pixels [6.] we should do the same but insted we should square our density. I suggest you to use calculator for this. In our case we are using 512/m so 512*512=262144. If you, for example, want to use density of 1024/m, you should use 1024*1024=1048576.

 

If you done everything right you should get 5.12 or 10.24 in Ratio Geom/Pixels section [7.] or whatever the the density you've chosed.

 

Pay attention that "Target Texture Resultion" does not affect any of this calculation, you need it only for setting the density for UV-Shells.

 

Here a screenshot with right values for density of 512/m:

mRZwya6.png

 

So now after you do all settings right you can apply your texel density to any model you're doing over there.

 

And here is a short video showing the whole process:

 

Pretty complicated, right? But nothing can be done. It just how this program works.

And the bad news is that you'll have to do this every time you close Advanced UV Normalizer.

 

In newest versions of this software, you can set Ratio Geom/Pixels directly and save a presets so you don't have to do this "piloting of a spaceship" crap every time. So I suggest you to buy a new version. Here is a screenshot of an Advanced UV Normalizer 2.3.0 just for a demontration:

fgt7nKy.png

 

What about Maya?

Oh, this is one of the few features of Maya, in which it is better than Max.

 

I'm not 100% Maya user, but afaik starting from Maya 2017 (with all updates installed) Autodesk added a native instruments to work with texel density.

To start working with it you should just open the UV Editor, open a Transform section and roll down untill you see "Texel Density (px/unit)".

 

KUuYxl0.png

 

The Interface is similar to a script that I was talking at the beginning of this tutorial.

Pretty much this is is where I took it from.

 

It works exactly the same:

Set the a desired texel density in the field to the right of the "Get" button.

Set your target map resolution and press "Set" and you're good to go.

Super simple as well.

 

Pay attention that this tool is setting density for pixels per unit.

Its mean that for different system units you'll have to type different values for texel density.

 

For example for meters it will be 512, but for centimeters it will be 5.12

 

Here is a short video showing a process of setting up system units in Maya and using a texel density tool:

 

 

Usefull links:

All You Need to Know about Texel Density - Leonardo Iezzi

Maya: Texel Density (TD) tutorial

Texel Density for game art

UE4 - Texel Density

Edited by FishMan

Share this post


Link to post
Share on other sites

n1 FishMan, very interesting.

 

I use Lightwave3D to build models and map the UV's. Once i've created the UVmap i can then go in and move things around and even re-size the mapped polly's within the UV space.

Would that amount to roughly the same thing? (if not actually calculated?)

Share this post


Link to post
Share on other sites

Um... Didn't get it...

Can you explain in detail what you mean?..

 

Quote

Once i've created the UVmap i can then go in and move things around and even re-size the mapped polly's within the UV space.

If you changing scale of the mesh, or scaling UV's, or adjusting the scale (or proportion) of your texture sheet you should of cource keep in mind that texel density has changed as well. As I said TD - is how many pixels on square centimeter on the surface of your model. When you change the scale of your model the world around and player (what is more important) remain the same. This mean if you made the model to be bigger, then you should do TD more dense. And the opposite: smaller model = should be less TD. This this is true only in case if you are need average TD. And when I said average I mean TD that used as a standard on your project (e.g. 512 pixels/meter). Of cource you can't change UVs and texures every time when you changing scale of some model (well at least by hand) but for average scale you should use an average density, so your enviroment has the same amount of details on every surface.

 

maya-Checker-Size-Tool.jpg

Edited by FishMan

Share this post


Link to post
Share on other sites

Hi FishMan,

 

what i meant was:

1. i build a model

2. create the UV of the model

3. have the UV in 2d viewport next to the model in a 3d viewport (split-screen)

4. i can now adjust the pollys in the UV space and see the pollys on the model in the 3d viewport

this allows me to "fit" the UV pollys into the UV space better, by scaling and moving them around.

this also allows me to rotate pollys to allign them with a texture.

 

basically what you are doing with the unwrapper, but inside Lightwave itself.

what it does not do is allow direct control of the Actual Dimensions of the UV pollys (that i know of) so its all done by-eye. so i can set things out Propotionally which i think generally works ok.

however, i am just starting to learn how to manipulate the UV's, mainly because i am getting wildly different scaling when applying materials/textures to my models in UE4.

part of the issue stems from Lightwave, like most porgrams, not being able to work in Centimeters, as it works to the ISO/METRIC standard of the Meter and i work at the Millimeter level using a 100mm snap as standard (although LW has an acuracy down to 5um). this scale issue means i have to "Size" up my models by 10,000% to achieve CM resolution for UE4. so i Size-up and then create the UV's, so i dont get any errors in UE4 from scaled UV's. after that i can adjust them so small, less visible bits can be shrunk (less res./lessTD) and larger or more visible/important bits can be scaled up (more res./higherTD) - just not accurately calculated, as you do.

 

having to do similar with the LightMapUV part of UE4: having to manually adjust the UV's in LW to allow much more space between pollys, for the UV1(lightmap ref.) channel. thinking of having a UV2 just for the textures and leaving the UV1's purely for reference for UE4 to build the LightmapUV's from, that way i can have a really dense Texture UV and a spaced, low res Lighting UV with no leaking lighting.

 

ill post a screenie when i get the chance ;)

 

 

.LJ

 

 

 

Share this post


Link to post
Share on other sites
9 hours ago, LaughingJack said:

part of the issue stems from Lightwave, like most porgrams, not being able to work in Centimeters, as it works to the ISO/METRIC standard of the Meter and i work at the Millimeter level using a 100mm snap as standard (although LW has an acuracy down to 5um). this scale issue means i have to "Size" up my models by 10,000% to achieve CM resolution for UE4. so i Size-up and then create the UV's, so i dont get any errors in UE4 from scaled UV's. after that i can adjust them so small, less visible bits can be shrunk (less res./lessTD) and larger or more visible/important bits can be scaled up (more res./higherTD) - just not accurately calculated, as you do.

Jesus Christ. xD 

 

Still didn't get, what is the question?

 

I'm not sure that we talking about the same things. As far as I understand you - you talking about making UVs overall, I was talking only about "Texel Density" stuff, it's not the same as scaling, rotating and etc. You are using scaling, rotating and whatever to reach good density, and this is not the same as making good UVs. Because good UV's still can have bad texel density, because TD (at least in this context) is an absolute value and this is important between several objects, not just inside a single object. And yes, you can do it by eye, using checker for example. I just talked about how to do it precise, so you can know how many pixels inside this particular UV shell.

Edited by FishMan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×