Search Unity

Finding objects with incorrect UVs

Discussion in 'Global Illumination' started by jsadler, Jul 29, 2016.

  1. jsadler

    jsadler

    Joined:
    May 31, 2013
    Posts:
    10
    I have a large city scene with thousands of objects and everything seems to be working great. I've picked up a few free items from the asset store and found that the lightmapping UVs are out of bounds on some of them. Easy enough to fix with 'Generate Lightmap UVs'.

    However the only way to be able to determine if there are incorrect UVs is in the editor log, BUT, the editor log doesn't tell me which object has the incorrect UVs. Does anyone know of a way to quickly find these types of objects easily.

    e. g. from log: "Enlighten warning: 'Input UVs are slightly outside [0-1], please supply normalised UVs and do not use atlassing.'"

    I've noticed that when UVs are OOB, Final Gather seems to run haywire even to the point where it's crashed the OS with out of memory.

    Thanks for reading.
     
  2. Thomas-Mountainborn

    Thomas-Mountainborn

    Joined:
    Jun 11, 2015
    Posts:
    501
    If there isn't a built-in way of discovering models with out of bounds lightmap uvs, you can extend the editor to do so. To start, you need to create an editor script that gets called from a menu item. The script then needs to get all MeshRenderers in the scene using FindObjectsOfType<>(). Then, on every mesh in that list, go over all uv2's. If one of those coordinates is out of bounds, log the mesh (and/or game object) name in the console, and move to the next mesh. This'll give you a list of all meshes with out of bounds lightmap coordinates.

    To make the search more efficient, remove any duplicates from the list of meshes before looping over the uv coordinates.
     
  3. jsadler

    jsadler

    Joined:
    May 31, 2013
    Posts:
    10
    Thanks Thomas.

    I had already started down that path. Just seeing if there was a quicker way.

    As a side, should I also go over uv3s for realtime?

    Thanks.