Home Technical Talk

Mirroring UVs and cubemap/normalmap behaviour in UDK

chrisdekitchen
polycounter lvl 17
Offline / Send Message
chrisdekitchen polycounter lvl 17
Im in the process of UV mapping a weapon for UDK and was wondering if someone here knows if its possible to use mirrored UV surfaces in UDK and still get the cubemaps and normalmaps to look right on the "wrong side" of the mirrored parts.

I actually do think its possible by assigning say a vertex color to the "mirrored/flipped" side of these parts and have that as a mask for flipping the normal direction in the shader... But I haven't tried this in practice, anyone know if it works? Better yet, anyone have a screenshot of a working shader set-up they could share?

I'd save tons of UV space flipping say the left-right side of the magazine in the UVs... it's just that I'm worried the cubemaps might end up upside down on one side.. and normalmaps will create seams.

Replies

  • Mik2121
    Options
    Offline / Send Message
    Mik2121 polycounter lvl 9
    Uhm? I might be understanding this the wrong way, but say you made half model, UV unwrapped, baked the normals for that model and then used symmetry... that should work just fine in UDK. What you need to take care is of flipping the green channel if you baked from 3dsmax or anything like that.

    Either way, the fastest way would be to make a test model and just import it into UDK to see if it works the way you want.
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    @chrisdekitchen
    Even if this was the case you would probably just use the lightmap uv set to apply the cubemap since it is unique.
  • Ben Apuna
    Options
    Offline / Send Message
    I don't know about cube maps but maybe this thread will help clear things up for you.

    IIRC it's more of an issue of baking the lighting info, maybe a dynamically lit object such as a typical weapon won't suffer from these problems.
  • chrisdekitchen
    Options
    Offline / Send Message
    chrisdekitchen polycounter lvl 17
    Thanks for your replies guys, I read through that thread before I posted and basically I was looking for a way to get around the whole you can't or shouldn't flip/mirror UVs and stack them when exporting for UDK. You can stack things in the UVs, that's fine...but you shouldn't mirror/flip stuff afaik. You'll always get a seam, even though it might be possible to hide it somewhat using different techniques.

    And since it's a weapon it'll be dynamically lit, and lightmaps wouldn't help covering up the seam. I guess using a second UV channel for the cubemap would work, but then again I'd have to add another UV channel. Maybe it's not a big deal, I just like to optimize stuff as much as possible. :)

    I believe, and I might be wrong, that the lighting resulting from the UVs on the flipped side will look inverted/wrong and cause seams where the UVs are mirrored.

    Say a character that has his hands mirrored+stacked in the UVs might get incorrect lighting on one of his hands due to the fact that the normalmap is rendered based on the tangent direction of the verts on the other hand.

    What I was thinking however, is that there might be a way around this if you detach those faces on the "mirrored" hand in order to get double the amount of vertices with different tangents for the seam area. Which you can then use to set a specific vertex color to those vertices and then mirror the UVs horisontally using that vertex color as a mask in the shader. Then both hands would in theory look correct? Assuming the geometry is completely mirrored as well so there's no difference in vert, tangents between the left and right hand.

    I made a character that I imported into UDK that had a bare chest with mirrored arms and had tons of problems trying to cover up seams resulting from flipped normals and inverted cubemaps in his shoulder area. I guess I could have designed around the problem had I known it was a problem before I tried it.

    Sorry for long post... I might just be overthinking this and should probably just go try it out in the editor. :P

    It might not be the greatest of problems, maybe it won't be noticable. Maybe I can hide seams and stuff.... I was mostly curious if someone had tried this before.
  • EarthQuake
    Options
    Offline / Send Message
    Well the first thing you will need to do is fix your art content, and that means doing the bake in the correct way. You can't just delete half the mesh, bake, flip and merge, this will result in a seam.

    What you need to do is simply offset the overlapping uvs on one side extra 1 unit in the uvs, this will ensure that everything bakes without fuss, and that you're using the correct mesh normals when baking to produce a seamless result.
  • chrisdekitchen
    Options
    Offline / Send Message
    chrisdekitchen polycounter lvl 17
    I did bake it correctly, and none of the mesh was deleted. In fact the character mesh I made looks right in most renderers even Marmoset Toolbag I think can handle it. It's just UDK that doesn't seem to support mirroring in a good way and I was curious if there was a way around it. I'll see if I might be able to post some examples later to clarify.
  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    EarthQuake wrote: »
    Well the first thing you will need to do is fix your art content, and that means doing the bake in the correct way. You can't just delete half the mesh, bake, flip and merge, this will result in a seam.

    What you need to do is simply offset the overlapping uvs on one side extra 1 unit in the uvs, this will ensure that everything bakes without fuss, and that you're using the correct mesh normals when baking to produce a seamless result.

    I've found that in max 2010 and up you don't even need to do this. It seems to bake just fine if you have overlapping UVs. Of course if you're using a different baking tool then that may not work.

    You shouldn't have to worry about the UVs for a reflection map as it should be using the reflection vector transformed into coordinates as UVs. A relfection won't look right if you use the regular UVs.
  • chrisdekitchen
    Options
    Offline / Send Message
    chrisdekitchen polycounter lvl 17
    Ah, you're right about the reflection vector, I think I might have forgot a world transform node after the reflection vector that might have made things confusing.. I read somewhere it was needed. On the other hand, is a world transform node needed for a dynamically lit object? Tbh. I have no idea what it really does. Still don't think it'll completely solve the NM issues I was having though but might very well reduce it. I don't totally know how I had that shader set-up so the cubemap issues might be an error on my end.

    Umm, I'll just do some research and get back to you if I find something interesting. :) Thx for your help.
Sign In or Register to comment.