Home Technical Talk

What is pixel denisty in UV unwrapping?

Easton
vertex
Offline / Send Message
Easton vertex
I am confused about what exactly this is, what it does, and how to properly scale all of the unwrapped parts of my models, what is it exactly? 

Replies

  • Bek
    Options
    Offline / Send Message
    Bek interpolator
    Texel density is the term you want. It refers to the ratio/size of the texture's pixels (texels) to the physical geometry. Plenty of threads about it you can search for, and on the wiki: http://wiki.polycount.com/wiki/Texel

  • Mark Dygert
    Options
    Offline / Send Message
    Most game engines operate on the metric system with 1cm being 1unit.

    Figure out how many pixels you need per cm. Depending on the style and hardware resource requirements of your game you might have to go 1px per 1cm or even 1meter. Those games are typically large blocks of color with very little pixel definition.

    A good place to start for most games is with 4px per 1cm (4:1). 

    Example 1:
    If you have a flat plane that is 128x128cm then your texture sheet should be 4 time larger, so 512x512px.

    Example 2:
    If you have a box 128x128cm, then you need 6 512px sheets. A 1024px sheet can fit 4 512px. So you have three options:
    A You can overlap 2 of the sides and keep it on a 1024px. 
    B You can jump up to 2048x2048px which holds 16 512px sheets, overkill.
    C Scale everything down a little bit

    It's important to keep in mind that this is not an exact science but a game of approximation.
    You want to get things close enough that no one really notices. You don't want to be off that it's obvious that ultra sharp objects (props and models) are right next to ultra blurry objects (walls and floors).  

    Texel density also plays a big roll in lightmaps when baking lighting, but that's another discussion for another day under specific circumstances. =)

    I hope that helps.

  • Easton
    Options
    Offline / Send Message
    Easton vertex
    Most game engines operate on the metric system with 1cm being 1unit.

    Figure out how many pixels you need per cm. Depending on the style and hardware resource requirements of your game you might have to go 1px per 1cm or even 1meter. Those games are typically large blocks of color with very little pixel definition.

    A good place to start for most games is with 4px per 1cm (4:1). 

    Example 1:
    If you have a flat plane that is 128x128cm then your texture sheet should be 4 time larger, so 512x512px.

    Example 2:
    If you have a box 128x128cm, then you need 6 512px sheets. A 1024px sheet can fit 4 512px. So you have three options:
    A You can overlap 2 of the sides and keep it on a 1024px. 
    B You can jump up to 2048x2048px which holds 16 512px sheets, overkill.
    C Scale everything down a little bit

    It's important to keep in mind that this is not an exact science but a game of approximation.
    You want to get things close enough that no one really notices. You don't want to be off that it's obvious that ultra sharp objects (props and models) are right next to ultra blurry objects (walls and floors).  

    Texel density also plays a big roll in lightmaps when baking lighting, but that's another discussion for another day under specific circumstances. =)

    I hope that helps.

    Okay, I'm still a but confused but I imagine that's common for beginners. I was thinking it was all just basic resolutions like 1024-4k-8k, this was like "WTF is this..." , thinking I had figured it all out.

    When I scaled objects down on my UV island I noticed my checker pattern increased to big sizes, I thought it should've decreased to a smaller size, why is this?

    That does explain as to why on some scenery that people make I have seen "30cm resolution used" which is about 1 foot per pixel? So if I did 1cm per pixel then I would have a extremely high quality texture right? 


  • Axi5
    Options
    Offline / Send Message
    Axi5 interpolator
    Textures don't scale with your uv shells.

    Overlay the checker pattern in your uv editor and count how many boxes you lose or gain while scaling. 

    Taking an abstracted look at what happens when you scale UV shells. You can also think of a 1 dimensional shell to help you along. 

    If you have a number line going from 1 to 10 and you have a shell along this that goes from 3 to 7 and you shrink it by 2x then it'll occupy 4 to 6 on that line instead. 

    There's less information between 4 and 6 than there is between 3 and 7 so there isn't as much data to display. Hence why checkers get bigger, there's less space for all of the checkers so you lose some.

    Essentially, the effect is that they grow bigger because there is less data. 
  • Mark Dygert
    Options
    Offline / Send Message

    Okay, I'm still a but confused but I imagine that's common for beginners. I was thinking it was all just basic resolutions like 1024-4k-8k, this was like "WTF is this..." , thinking I had figured it all out.
    You still want to work in powers of 2 textures. 16, 32, 64, 128, 256, 512 ect. That has to do with how textures are stored and how hardware functions. You don't want to just pick a size 512px and use it on everything. Things that are huge like a building will look horrible next to a tiny soda can that you can clearly read all of the ingredients. So you try to cover your world with a fairly close texel density so everything roughly gets the same amount of pixels, not "everything gets the same texture sheet size". There are tools in most engines and 3d packages that help you visualize the texel density.

    Easton said:
    When I scaled objects down on my UV island I noticed my checker pattern increased to big sizes, I thought it should've decreased to a smaller size, why is this?
    That is working as intended. As you scale a UV object down it uses less of the texture space, meaning the pixels get bigger on the object.
    As you scale up it uses more of the space and more pixels are displayed. 

    Easton said:
    That does explain as to why on some scenery that people make I have seen "30cm resolution used" which is about 1 foot per pixel? So if I did 1cm per pixel then I would have a extremely high quality texture right? 
    I'm not sure about the "30cm resolution used" I would have to see the art in question to understand what they meant.
    1 pixel per foot seems ridiculously large. A face is less than 1ft wide so yo would have 1px to detail the entire face. Unless it is a cartoonish game with giant blocks of color or that was for something that didn't need pixels to help describe the surface.

    Even Minecraft has a much denser texel density, I think it's 16px per 100cm (1 meter) which is very blocky and clunky but that is it's style.

    4px per 1cm is fairly low but a good place to start for most PC and console games.

    1px per 1cm is probably easier to understand for learning but in practice its a little too low for most games.





  • Mark Dygert
    Options
    Offline / Send Message
    The boxes are power of 2, so 1, 2, 4, 8, 16, 32, 64, 128.


    WRONG
    With the same size texture applied to everything, the smaller blocks get way too many pixels and the largest gets barely enough.
    The smallest box, has enough pixels to paint the Mona Lisa on it, but you'll never see it, the box is too tiny.
    If we put the Mona Lisa on the largest box it will look pixelated.

    If we leave it this way and we run some kind of per pixel calculation, the tiniest box will have a massive calculation (for the amount of screen space it takes up). That calculation will ultimately go into coloring just one of your monitors pixels a certain color. What a waste...

    It's like forcing your computer to read the entire library of congress just to tell you what the first letter of the alphabet is. A lot of effort and resources go into solving something that didn't require all of that effort.





    CORRECT
    Sticking to 1px per 1cm. The smallest block gets 1px, which is just enough info on the screen to make a quick calculation and get the right color on your monitor. It also means that when the smallest box is sitting right next to the biggest, they are on equal visual fidelity. A pixel on the largest box looks just like a pixel on the smallest.

    Personally I think 1px per 1cm is too low but for learning and illustration, it might help it make more sense. What matters is that these objects are in the same ballpark, they don't have to be exact but you do want to be aware.

  • Easton
    Options
    Offline / Send Message
    Easton vertex
    Thanks for the representations! That actually made it click, being able to see what you meant.

    I further found out the answer when I started texturing one of my models in Quixel. I had a ground plane underneath my model, but did not have enough room on the UV for it, so I stuffed it into a little tiny corner and when I textured it the resolution looked utterly horrible.

    So bigger means more detail. 

    My other question, if you wouldn't mind helping, how would I fix the scenario listed above where I have a piece of my model that I cant fit in the 0,1 UV space? 

    I thought there was a solution to this but I don't remember how it is fixed. Also, I thought there was a way to add multiple UVs for one model to remedy this. What does overlapping UVs do?

    Thanks!
  • HAWK12HT
    Options
    Offline / Send Message
    HAWK12HT polycounter lvl 12
    Cool more info ! tagging this on my thread for future reference. 
    @Easton you should check it out as it may help you understanding TD more. 

    http://polycount.com/discussion/192294/texel-density-and-units-in-depth#latest
  • Mark Dygert
    Options
    Offline / Send Message
    Easton said:
    My other question, if you wouldn't mind helping, how would I fix the scenario listed above where I have a piece of my model that I cant fit in the 0,1 UV space? 
    Anything that hangs outside of the 0,1 space will tile. It is perfectly acceptable to have your UVs look like a rats nest with UVs hanging out far past the 0-1 space, IF you are using tiling textures. Below is using a tile texture and it helps to offset the UV's to help avoid repeating details.


    You can also add strategic cuts to the geometry, specifically so the UVs aren't a bear to work with. So for example you have a long rectangle that doesn't necessarily need a cut in the middle but if you add it, it makes packing two squares easier. Maybe you even overlay the squares. That little bit of geometry won't cost you much in the grand scheme of things but it makes you able to do your job quickly and efficiently so it's a huge win.

    Easton said:
    I thought there was a solution to this but I don't remember how it is fixed. Also, I thought there was a way to add multiple UVs for one model to remedy this. What does overlapping UVs do?
    You can add multiple UV channels to a model, a lot of engines use two:
    UV1: Is for your materials and they can be whatever is requires, they can hang outside of the 0-1 space, overlap and be a mess. 
    UV2: Is generally for lightmaps in engines that bake lighting. Most engines can generate these UVs for you but sometimes it goes off the rails and its better to do it yourself. There are a few rules, nothing can overlap, everything needs it's own unique space and there should be plenty of padding between the UV shells so nothing bleeds into the other shells.

    I've seen quite a few shaders that will use UV2 or 3 for something else inside the shader, like masked dirt, snow, sand and other details that get overlaid on top of UV1 which is a tiling texture. 

    Overlapping UV's is a good way to get the similar details on other parts of a model. Hopefully two parts are something that you won't see sitting right next to each other where it's obvious that it's repeating.

     So for example, a box has 6 sides but 6 squares packs like ass into a square texture, 4 would be better but we can't delete two of the sides, so we'll overlap them. 

    Now if you where to bake this asset, we would want to move the overlapping UV's one tile to the right or left outside of the 0-1 space. that way it displays the texture correctly but it won't be factored into the rendering because only UV's inside the 0-1 space get rendered. If you left them overlapping it would render both sides on top of each other and it could look bad... Although there are ways around that too, depending on the modeling package you are using.
  • Easton
    Options
    Offline / Send Message
    Easton vertex
    I'm going to have to save this for later use, thanks!

    So I could just set my UVs on top of each other in the 0-1 space if they're going to be uniform? Like if I have a wood model and a lot of 2x4s I could set all of them on top of each other because most of them would look the same, or is this a wrong way to go about it?

    The only issue I saw with having my ground texture outside of the 0-1 space is when I added textures to the model on top, it very oddly added textures in a strange random way to the ground.
  • Easton
    Options
    Offline / Send Message
    Easton vertex
    HAWK12HT said:
    Cool more info ! tagging this on my thread for future reference. 
    @Easton you should check it out as it may help you understanding TD more. 

    http://polycount.com/discussion/192294/texel-density-and-units-in-depth#latest
    Thanks! I am going to save this stuff for the near future. Right now I am just getting the basics, so a lot of detail goes right over my head until I get there myself. Making progress surely but slowly, last week I didn't know how to UV Unwrap, now I am getting into the specifics of it, hopefully in a month I'll have enough assets to figure out how to create a UE4 scene!
  • JEmerson
    Options
    Offline / Send Message
    JEmerson polycounter lvl 7
    Just wanted to come in and say thanks to @Mark Dygert. Best explanation I have seen of the concept to date.
  • Mark Dygert
    Options
    Offline / Send Message
    Easton said:
    So I could just set my UVs on top of each other in the 0-1 space if they're going to be uniform? Like if I have a wood model and a lot of 2x4s I could set all of them on top of each other because most of them would look the same, or is this a wrong way to go about it?
    You can totally do that, in fact it's one of the best ways to work.

    You can try to stack them by hand. I like to unwrap one of them, then duplicate the geometry so the UVs are already stacked perfectly on top of each other. This works best if the object has specific UVs it needs to adhere. But it really depends on the model, the texture and what you are trying to do. If your texture tiles, you will probably want to nudge the UVs around so they don't all look exactly the same.

    Easton said:
    The only issue I saw with having my ground texture outside of the 0-1 space is when I added textures to the model on top, it very oddly added textures in a strange random way to the ground.
    That depends on how your materials are set up and how the app interacts with objects. Without knowing which app or how the scene is setup it's hard to say what is going on. If I had to guess, you probably have the same material assigned to multiple objects, or faces within an object. Giving each object their own material and making sure that it is applied to every face should solve the issue. 
Sign In or Register to comment.