Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

To stupid to use Generate Cubemap the right way?

Discussion in 'Editor & General Support' started by Whimsical, Oct 26, 2009.

  1. Whimsical

    Whimsical

    Joined:
    Mar 29, 2008
    Posts:
    155
    Hi folks!

    Today is just another day with me feeling completely stupid because of a Unity editor functionality that I just can't wrap my head around. It's the Generate Cubemap functionality in the Texture Importer.

    The documentation only states "Generate Cube Map - Generates a cubemap from the texture using different generation methods.", frankly not very much information on how to use it right. ;)

    What I was able to find out until now is that generating a cubemap only works on squared textures. What I was NOT able to find out is what mode to use and how to format the texture so that it works right.

    What I was doing is that I opened a squared latitude-longitude reflection texture (something like this, only squared: http://xsi.jankin.com/anisotropic_patterns/environment.jpg) and tried out all the available methods (Spheremap, Cylindrical, SimpleSpheremap and NiceSpheremap), but none of them served me the desired result.

    The results I got were like this:
    Spheremap - Looks kind of OK, but the Back (-Z) is pinched to it's center.
    Cylindrical - Returns only six black images
    SimpleSpheremap - The result looks very good, but it's mirrored in the center. I really don't understand that result at all.
    NiceSpheremap - The result is mirrored in one direction PLUS it has a very prominent seam into the other direction. That's not ok at all.

    Since I wasn't really able to find any solution in this forum I am tempted to say that I am using a wrongful image as source. Probably I'm doing something wrong here.

    Or is it a bug that no one cares enough about, who knows.

    I'd be really happy for any hint into any direction on how to use this tool correctly. And if it is just plain broken: What tools do you guys use to convert a latitude-longitude environment map to these six cube map parts that Unity is using?

    I appreciate any help. :)
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Does this page in the manual help you out at all?
     
  3. Whimsical

    Whimsical

    Joined:
    Mar 29, 2008
    Posts:
    155
    No, it does not, to be frank. I have no problem with understanding what a cubemap is and how to use it. My problem is the result of the "Generate Cubemap" functionality of Unity. I think that there's something wrong either with it or with me, that's what I'm trying to find out :)

    To make myself a little more clear I have composed a "little" image for you to visualize what I meant in my initial posting. See for yourself:

     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    OK, I'll run this by the techies. The relevant person might be busy with Unite at the moment, but hopefully you'll get a reply soon.
     
  5. madproducer2k

    madproducer2k

    Joined:
    Jan 19, 2010
    Posts:
    47
    Hello out there. I was wondering if it was me also?I cant seem to get it to work also.Its not cutting up the pic right.Is it in the works to be fixed? thank you for your time.
     
  6. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There do seem to be some issues with that script. Another approach might be to use the skybox generator script from the Unify wiki.
     
  7. davebuchhofer

    davebuchhofer

    Joined:
    Nov 9, 2007
    Posts:
    126
    I'm curious how others do this also, I have a huge library of LatLong hdr's and skydomes that I'd like to be able to use in unity.

    currently, I see two ways to get them in, neither of which work very well.

    1A: Open the LatLong image in HDRShop, image pulldown, Panoramic Transformations, and convert from a LatLong to a Mirrored Ball.

    1B: the mirrored ball can be loaded into unity directly, and use the built in 'Generate Cubemap - Spheremap' in unity. This works alright for reflection maps, but poorly for environment skymaps due to the pinching in the unwrapping.

    2A: Open the LatLong image in HDRShop, image pulldown, Panoramic Transformations, and convert from a LatLong to a Cube Cross.

    2B: Open the cube cross in ati's CubeMapGen, save cubemap to images, and load into the unity cubemap

    This gets rid of the pinching

    On the plus side, you can do your diffuse convolve here for the ambient cubemap, on the minus side, there is black lines where the map didn't quite transform correctly!

    and the +Y and -Y maps or rotated by 180 degrees ---- I SEE! This can be fixed by exporting from cubemapgen with an OpenGL Cube layout.

    there is an 'edge fixup' check there, that can infill the missing pixels as a sort of fix. but only for the blurred/convolved cubemaps.

    Someone please tell me there's a better way :)
     
  8. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    I used Flexify 2 for doing all my conversions to mirror balls then via Unity's Texture Importer as a Reflection->Sphere mapped.

    It works in Photoshop and is cross-platform which suits my work flow perfectly. Though it isn't free but very good value.

    http://www.flamingpear.com/flexify.html

    Cheers.
     
  9. swade

    swade

    Joined:
    Sep 1, 2012
    Posts:
    1
    All right, so I know this thread is freaking ancient but I found it in the search for answers. So I'll leave my mark here in the hope that the next guy (some parallel future-me) can save some time.

    For those curious, if you look at Whimsical's second post where he tries to apply that texture as a cube map it is failing because the texture does not tile. The answers below are ways that he can manipulate his existing texture into one that does tile (in the specific box-like way a cube map needs).

    I'm not familiar with any of the programs mentioned by other responses, however I am very familiar with photoshop and I know how cube maps work for Unreal.



    So basically the above image is what Unity needs to make a cube map. It needs the sides of a cube. The photo is good but no matter how you stretch or tile it, you're going to have bad seams, especially where the top and bottom faces come together.

    Now, the reason I made sure I had extra room on the top and bottom of the center "row" of cubes was because I wanted to be sure things would tile correctly on the top and bottom. Using photoshop I pulled directly from the areas above and below those faces to "assemble" the tops and bottoms.



    Only the edges of the top and bottom are really important. These need to match up with the other faces so that there is no seam. The stuff in the center of these faces can easily just be painted in by hand or sampled if you're using a sharper (more photo-quality) image.

    Once you've done that, all you need to do is save off the faces as individual files then assign them. This can be a bit tricky just because the order you saved these out in might not be 100% correct. So as I found, my Top (+Y) and Bottom (-Y) were actually rotated. You can either rotate these in photoshop or assign your other faces to match.

    Here are the cube map images, I can't attach them as the upload limit is 5 (and there are 6 images).

    You'll notice from the preview that there is still a slight seam from the custom painted top part. How you're using the cube map will determine if that is a problem. On something that isn't a mirror-like surface it'll likely be irrelevant. Examples.

    Now the programs talked about above may essentially do this for you, I don't know. Heck, they may even do it better or faster. But in the even someone comes here just looking for the files, here you go and here's how I made it.
     
    Nition likes this.