Search Unity

Problem with UVs when importing models from .blend or .fbx file

Discussion in 'Asset Importing & Exporting' started by theguga96, Oct 22, 2019.

  1. theguga96

    theguga96

    Joined:
    Sep 22, 2019
    Posts:
    4
    Hi guys, I'm new to Unity and I'm trying to make assets for my videogame using Blender but I've encountered a problem when importing the models either from the .blend file or from an .fbx file Unity isn't loading UVs in the correct way. I've applied rotation,scale and position in Blender to the model but it isn't working. I've also tried to import a simple cube with no transformation applied and it doesn't work either.
    I've tried messing around with settings in Unity (swap Uvs, weld vertices, keep quads....) but nothing changed.
    Am I missing something?
    In addition I've added an image showing the shader I'm using (it makes the edges of my cubes emit light) and an image showing the shader applied to a cube made in blender (the left one) and one made in unity (the right one).
     

    Attached Files:

  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    I've never had trouble with UVs going from Blender to Unity. Are you sure that your UVs were correct in Blender to begin with?
     
  3. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    Can you show your UV map in Blender for the model...I'm hoping you aren't applying materials using generated/automatic UVs in Blender, as those things don't get applied to the actual model and are only used when rendering and previewing in Blender. You should be able to snap a screenshot of the UVs of the model if you've done it right. If not, feel free to clarify so we can help.
     
  4. theguga96

    theguga96

    Joined:
    Sep 22, 2019
    Posts:
    4
    sorry for the late response, yes I've checked the uv in blender and it is correct. I've exported the uv, drawn on it and used it as texture and it works.
    I've tried using the same texture in unity and it works as well. The problem rises only when using the shaders
     
  5. theguga96

    theguga96

    Joined:
    Sep 22, 2019
    Posts:
    4
    to generate the uv in blender I've tried either using the smart uv project and manually putting seams on the edges. none ot them worked. as I said previously, if I aplly a texture in blender it is also recognized in unity, the problem rises only when using shaders.
     
  6. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    Show your UV layout like kburkhart84 suggested. If I understand your graph correctly, the shader will only work properly if your cube is mapped the same way as the unity cube. Specifically, you need to have each side of the cube encompassing the entire texture space.
     
  7. theguga96

    theguga96

    Joined:
    Sep 22, 2019
    Posts:
    4
    Basically what wanted to achieve is to have the border of my model to emit light. But in this way, it can't be applied to a model that isn't a cube I imagine.
     

    Attached Files:

  8. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    It can work just like you want, but you have to UV map every quad of your model so that it square fits inside of it.

    The square is basically a texture map. Imagine putting your UV layout on top of the square that you generated like this image.
    square_uv.jpg
    You see that two squares intersect part of the border, and the rest miss completely. That's why your cube looks the way it does in your first screen shot. You have to scale-up each uv island so that it covers the whole square. That means that each of the squares will all be on top of each other.

    By the way, Unity's built-in cube is already mapped this way, and that's why your shader works on it. You can test this by putting any texture on the built-in cube: you will see the whole texture duplicated on each side.
     
    fanuk3679 likes this.
  9. MadMarcProductions

    MadMarcProductions

    Joined:
    Dec 13, 2020
    Posts:
    3
    Last edited: Dec 21, 2023
  10. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    Always post a new thread if you have a question.

    Why is your tiling set to 2,2 and not 1,1? Why is your offset set to anything other than 0,0?
     
  11. MadMarcProductions

    MadMarcProductions

    Joined:
    Dec 13, 2020
    Posts:
    3
    It was just from moving it around to see what was going on. It didn't line up by that method. So I found an FBX version on Sketchfab by a different artist with the exact same animations. All I had to do was turn the model 180 degrees in Blender for Emerald AI to work. I imported it into Unity and big smile, everything was great.
    Now that tells me that it has something to do with the model from before being a glb file, importing it into Blender and exporting as an FBX. I don't know. What are your thoughts?
    Thanx for responding. This is fun, eh? :)
     
  12. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
  13. MadMarcProductions

    MadMarcProductions

    Joined:
    Dec 13, 2020
    Posts:
    3
    You haven't? They're all over Sketchfab
    https://sketchfab.com/vang807
    There's an example. Go to download any of these and you'll see all the file types Sketchfab offers.
    Oh thanx, I know about Unity's file type support.
     
  14. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,635
    Firstly, the reason I posted the list is that if a file type is not on the list (like glb) there's no reason to expect it to work properly or even at all.

    I assume glb is probably related to OpenGL, though, so if the only problem you're having is with the texture, I'd try maybe opening the texture in an image editing app and flipping it vertically. If I recall OpenGL interprets UVs upside down compared to other APIs.