Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Textures not rendered when model is scaled down

Discussion in 'Windows Mixed Reality' started by smenyhart, Jan 16, 2017.

  1. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    I'm having some trouble with dynamically loaded models with textures.

    Let me explain a bit about what my application does. It's a model viewer and is able to parse model data (hierarchy, transforms, meshes, textures, etc) out of files. It then dynamically loads the model using Unity's dynamic mesh generation feature.

    This is also a HoloLens application, although this problem is not HoloLens specific. It's important to note that it's a HoloLens application because I have to be able to scale these loaded models to a realistic size on the HoloLens. Some of these models are in units of mm and on the HoloLens the world coordinate system is in meters so these models need to be scaled down usually by some scale factor usually around 0.001. It's under this case I started to notice that some textures were not being shown.

    In the attached screenshots I show the same exact model as it was loaded on the same run. The only difference is that in one, some of the textures are not rendered when the scale is 0.009 (seen in the inspector on the right). In the other, where I manually changed the scale factor to 0.09 the textures all of a sudden become visible. This isn't just in the scene view. It's the same case in the player and on the HoloLens.

    Why is this happening, and how can I make this not happen without relying on having to make the scale bigger (because I don't know under what exact circumstances is it big enough). Remember that I have to be able to load arbitrary user specified model files, so I cannot rely on checking to make sure each of them works because I have no idea what files users might try to load.

    Unity-Textures-Hidden.PNG Unity-Textures-Shown.PNG
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    Hello @smenyhart,

    Can you please send in a bug report so we can investigate the issue? Also, can you post the bug number in the forum so I can look it faster?

    Thank you,
    Wesley
     
  3. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    I can create a bug report but I don't think I'll be able to create a sample project demonstrating the bug. The model that exhibits the bug is dynamically loaded and the code that does this loading I cannot share. I have been trying to create a prefab object from the dynamically loaded model but I'm not having any success. The runtime created prefab has the correct GameObject structure, but all the dynamically created meshes are missing from the prefab, even though I've saved all the meshes using AssetDatabase.CreateAsset.
     
    Last edited: Jan 17, 2017
  4. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    I've found a partial workaround. The previously missing textures render if I change the "Rendering Path" on the main camera to "Deferred". However these textures render without being correctly lit. Basically all the textures that would always render are lit up by the directional light coming from the camera, but the previously missing textures that now only render because of the "Rendering Path" change show up as dark and unlit by the spotlight. If I again increase the scale of the entire model, just like before, these textures eventually become correctly lit.

    I must also note that this "Rendering Path" change on the camera workaround only works when actually viewing the model through the camera in the Play window. The textures are still missing in the Scene window.

    Unity-Textures-CameraChange.PNG
     
  5. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    What build of unity are you using? I can't seem to reproduce this issue
     
  6. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    Version 5.4.0f3-HTP
     
  7. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
  8. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
  9. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    Thank you for submitting the bug with the sample, it looks like the graphics team will be looking at this issue shortly and see what they can do to fix it.
     
  10. unkown512

    unkown512

    Joined:
    Apr 23, 2018
    Posts:
    1
    Has this issue been solved by the graphics team? I am using Unity 2017 .2.1p2 64bit.
     
  11. unity_V16sPb0I8SVOuw

    unity_V16sPb0I8SVOuw

    Joined:
    Apr 1, 2019
    Posts:
    10
    I still have this problem using the newest version of Unity.
     
  12. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    This was never fixed as far as I know. The bug was closed and it was decided that it works as intended.
     
  13. pshah

    pshah

    Joined:
    Apr 30, 2014
    Posts:
    1
    This wasn't fixed in 2018 and is a very large issue now when using AR tooling. In many cases the occlusion meshes used in AR can't be scaled up or down and so any models used must be scaled down. Whenever a model drops below 0.0001 in terms of scale, it immediately loses all texture without workaround. However, many models need to be scaled far below this (most notably, for facial augmentation, almost every mesh has to be scaled at least to 0.001, so meshes that need to be scaled further are basically unusable due to this bug).

    I'm on 2018.3, so unsure if this has been addressed in the 2019 release. Is anyone able to test this on Unity 2019?
     
    unity_V16sPb0I8SVOuw likes this.
  14. UnDreaming

    UnDreaming

    Joined:
    Feb 5, 2013
    Posts:
    1
    In case anyone is still interested, I've encountered the same problem today on Unity 2019.2.1f1 and I've found a workaround. Setting the "Scale factor" to a low value in the model "Import settings" doesn't cause this issue. So, instead of setting the local scale in the scene to a low value, just set it in the import settings and the texture should show properly.