Home Unreal Engine

Rotating models in UDK (lighting issue)

Hey guy's

I'm having a problem with my lighting in UDK,
This happens after bake and before, there is nothing wrong with the model or lightmaps. (that i'm aware anyway) :)

Here the specular is working correctly between the 2 tiles
fixedlight.jpg

But after rotating this the lighting is reacting totally wrong? i need to rotate these tiles as i'm trying to make something modular any ideas?

brokenlight2.jpg

brokenlight1.jpg

Thanks! (oh p.s ignore the messy textures hehe)

Replies

  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
    I'm actually having the exact same problem right now. It's to due with the fact that you are rotating the normals, so they get a new light direction.

    I'm just thinking out loud here, I don't have that much experience with UDK yet, but wouldn't it be possible to:
    Split up the model with different material ID's.
    Make a material where you set up a parameter so you can rotate the normal 90 degrees.
    Make an instance of the material, and apply it to each material ID with a different rotation.

    PS. If this is possible, please share how you'd go about doing it exactly.
  • Oranghe
    i did check unreals assets and i thought the material editor had something fancy in it but when i removed everything and it was a standard material it was still fine, i saw somewhere if you changed the UV channels it may help so i will test this and your suggestion and let you know thanks for your reply.

    Also going to try rotating a clean static mesh then applying a texture to it so hopefully its fine.. but will see.
    Would still love some more help though! :D
  • WarrenM
    Offline / Send Message
    WarrenM Polycount Sponsor
    I wish I knew the reason but this has to do with the normal map. How did you generate it? There's a right way and a wrong way, and the wrong way will give you what you're seeing here. The right way can be freely rotated without problems.

    Anyone? :)
  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
    I found a solution to my problem. See if it's the same for you.

    Open up your material.
    Find the Material drop down.
    Select Lighting Model > MLM_NonDirectional

    VT7Hq.jpg
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 7
    ^
    That's wrong? You're losing out on all the maps expect Diffuse and Emissive, which is not the solution unless somehow baking takes into consideration the Normal Map, Specular and etc bounce even in NonD, in which case you will be getting the old issue back.
  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
    Ace-Angel wrote: »
    ^
    That's wrong? You're losing out on all the maps expect Diffuse and Emissive, which is not the solution unless somehow baking takes into consideration the Normal Map, Specular and etc bounce even in NonD, in which case you will be getting the old issue back.
    Yeah I see that now. Though I still don't get it.

    How the fudge does modular modelling work then? If you cant rotate anything without getting lighting problems.
  • WarrenM
    Offline / Send Message
    WarrenM Polycount Sponsor
    Again, how did you generate the normal maps for this? I'm 99% sure that is your problem.
  • Oranghe
    NDO :) i will give it another test in a minute but i'm pretty sure i did a few tests without normal map and it still had the issue i will give it another go though. Thanks for the replies ! sorry for my slow response still working through this :)
  • Xendance
    Offline / Send Message
    Xendance polycounter lvl 7
    I'd try clearing the Unreal Swarm cache after you have put everything into place. It might be corrupted.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 7
    Can we see your normal map? I think there is slight overall 'bend' to your flat colors in the normal, so it's bending the normals in one direction, hence why the mesh looks borked when rotated.
  • Oranghe
    Thanks for all these suggestions guys!
    I will post any progress tomorrow :)

    Heres my normal,

    p_FLR_welcome_NM.jpg
  • Oranghe
    Small update,

    Cleaned the swarm cache and validated, also tested 4 of the unreal normal maps onto my model and still had the same issue, turning the normal map off also does not fix it.
    So not sure its that,
  • Xendance
    Offline / Send Message
    Xendance polycounter lvl 7
    Well hmm, could it be that your UV's are flipped in some weird way, which could confuse the engine when calculating the normals?
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    Linkitch had it right in the first post. It's not a model issue or UV one, it's simply that your inverting your own normals by rotating them. It's easy to see just flip your normal around in PS. This fix is just to mirror things and not rotate them, or make another tex and just invert the proper channel(green usally).



    Io6sN.jpg

    d75ce.jpg
  • Oranghe
    That makes sense thank you, but what if i want to use that asset more then once in the same scene and rotate them?

    Are you saying that i need a unique normal map per rotated model? isnt that a bit overkill having 4 rotated normal maps for one texture? or am i misunderstanding! :D

    Thank you for your help! i really really appreciate it! and i will try my best to fix it today :D

    thanks again!
  • sprunghunt
    Offline / Send Message
    sprunghunt greentooth
    if you make a procbuilding with these assets a lot of these problems get fixed...

    and, as people have said in other threads, it's better to just make a bigger piece of ground than do this. Or not put your seam across a smooth section of the texture - put it where there's a natural seam in the object.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    In this case you just need to flip the texture, which you can do in the texture alignment (Flip U/V).

    So you only need the one normal map in this instance. If you wanted to rotate it only 90 degrees you would need a new one since you would be swapping the green and red channels.
  • Oranghe
    Sorry i haven't been giving very good examples, it is not the seam i have an issue with as i know how to fix that :) (thank you though) my issue is when i rotate a model the specular highlight is in a completely different place.

    No rotation here, and it works fine
    rot01.jpg

    Here is after i rotated the top left model 90 degrees and as you can see the highlight has moved, if i mirror a model that works ok its just 90 degree rotations.
    rot2.jpg

    ROT03.jpg

    Sorry for any confusion! but thanks again and i hope this is a bit more clear.
  • Oranghe
    Sorry update! just tested again and mirroring does not work, it has the same issue.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    Like I said if you rotate 90 degrees you will need a new normal map. When you rotate 90 degrees you changing your normals on 2 axis. The red and green channel are both changing so you can't fix it by mirroring, you would have to swap them(red becomes green and green becomes red).

    When you rotate 180 degrees your only changing your norms on 1 axis so you fix it by mirroring.

    mDJo8.jpg
  • Sandro
    Nah, its not about normal maps. Does same stuff on models without them.

    I believe UDK's specular calculations is somehow tied to UVs. Haven't tried myself but you could actually try flipping UVs instead of flipping maps.

    Such scenarios are better avoided though
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 9
    yeah, there was the suggestion in another thread, to swap your lightmap uv channel to channel 0, and your diff/norm/whatev's to 1, since specularity apparently always reads the first channel.. doesn't work on more complex models though, as it'll screw with your baked normals. might work in this situation though.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 7
    Did you do the entire process of Reset XForm, etc before exporting the mesh?

    Also, does the problem present itself on other models FROM the stock models in the game?
  • Snight
    Offline / Send Message
    Snight polycounter lvl 12
    Just to clear this up, this has nothing to do with your normal map.

    I believe (if I can remember correctly) that this is intended by Epic. You have to remember that unless using fully dynamic lights you don't have real time specularity. From what I understand, UDK uses a light vector with 3 channels. If they had used 4 channels instead of 3 this problem wouldn't exist. I believe it was too costly. This is the same reason why you can't flip UVs on the vertical axis for meshes with mirrored geometry.

    So my suggestion for you, is to not rotate flat pieces. Build them differently, so you don't have to rotate them. You could build a larger mesh, or more variants that line up with each other. You could also try using a dominant light instead of a static light and the issue will most likely go away or at least lessen the issue.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    With all due respect but you guys are absolutely wrong. If your using indivduals tiles then you have to have your normals all pointing in the correct rotation in correlation to each other.

    Here's the same issue he's having, top and bottom fixed using proper normal orientation.

    mDRDo.jpg
  • Xendance
    Offline / Send Message
    Xendance polycounter lvl 7
    I think it's a problem in the specular lightmap generation. It doesn't seem to take mesh orientation into account.
  • Snight
    Offline / Send Message
    Snight polycounter lvl 12
    Did some digging on this, this should clear up everything -

    What happens is when you generate static lighting it picks 3 vectors from the surface (somewhat randomly) and computes the lighting intensity from each with what is generally the strongest light effecting the mesh. (it's more complex than this, but this is artist friendly). That generates the lightmap texture that DOESN'T include specular data. Specularity is calculated at runtime using all 3 vectors. Those vectors are based on the model's space, so if you rotate the model the vectors rotate. This means that rotated meshes compute specularity differently.

    This CAN be fixed by using a dominant directional light (which looks like that's what you're using Deadly). Dominant lights reduces it down to 1 vector and is not mesh orientation specific, I believe.

    Theoretically, you could try to make up for the vectors being different by shifting the vectors in the normal map. But, creating different normal maps for just 1 mesh is not ideal from a memory standpoint.

    You could also potentially have different models that are rotated in max/maya and imported into UDK. Again, not an ideal solution for performance reasons.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    It's not, that was static.

    Also if you don't want to use the lightmap specular then you can just turn it off in the material in the misc rollout > allow lightmap specular. You don't have to be stuck using dominant lights as a 'fix'.
  • WarrenM
    Offline / Send Message
    WarrenM Polycount Sponsor
    It's the normal map. We rotate, scale and abuse meshes with alarming frequency in Gears of War and so does every licensee. The engine handles it all perfectly fine. :)
  • ArchieVision
    I did a little digging into a Modular piece from Unreal, and learned a lot about how to get the realistic lighting and specs on modular pieces.

    Here, I will post some pics, and let you guys look over them, and see if you can discover what is wrong.

    I was trying to figure out the reason they are using a basic shader with a physical material, and not a exclusive mat for each model. But, I finally figured it out.

    Here is the mesh.
    StaticMesh.png

    Here is the Material Instance Constant.
    Mat_Inst_01.png

    And the Physical Material with the Textures there.
    PM_StoneProps.png

    And here is the simple material shader they use for most of the modular stone models.
    MatShader_Simple.png

    I am still trying to break all this down because it is new to me. I have always just worked with Exclusive mats, and shaders. But this seems to do the job better, and with less overhead.

    Also, if you notice, you can rotate the model anyway you want, and the shadows and Specular always act correctly.

    If anyone else uses this work flow or knows more about it, please enlighten us? I would love to know the benefits this has to the game, and the modular meshes.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    Also, if you notice, you can rotate the model anyway you want, and the shadows and Specular always act correctly.

    Sadly no, the lightmass specular is still wrong. It's just not in your face when you have a diffuse/spec map on it.
  • Oranghe
    Wow hey guy's thanks immensely for all this feedback and idea's i'm still having the issue and may find a different way around it then the current scheme i have going but i will give everyone's suggestions a shot! some of it is a little over my head though hah.

    Thanks again for all your time!
  • ArchieVision
    Sadly no, the lightmass specular is still wrong. It's just not in your face when you have a diffuse/spec map on it.
    I tested it again, and you are right.
  • kostyasazonov
    So what's up then? So many great environments on a forum and nobody could solve our problem? :D
    I'm stuck too - can't rotate modular stuff.
  • maxivz
    Offline / Send Message
    maxivz interpolator
    So what's up then? So many great environments on a forum and nobody could solve our problem? :D
    I'm stuck too - can't rotate modular stuff.
    Same thing happened to me with lightmap issues, i have tryied everything they suggested and still couldnt fix it :(
  • m1neh
    Same issue here - I don't understand why rotating an object would flip normal channels? Or have I understood it incorrectly? Keep digging!! :D
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 7
    Normal Map has nothing to do with this, unless you didn't reset XForm after rotating your UV's, etc in your modeling package of choice.

    Even if you rotated your Normal Map in the material, it will show up correctly.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    Ace-Angel wrote: »
    Normal Map has nothing to do with this, unless you didn't reset XForm after rotating your UV's, etc in your modeling package of choice.

    Even if you rotated your Normal Map in the material, it will show up correctly.


    Care to show an example then? I tested this extensively and what your saying is completely incorrect.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 7
    Upload a test model maybe? I don't have time to make one, but I can assure you, this is an issue I had extensively with Max's viewport when I was using ShaderFX, to which UDK is immune, UNLESS you did some/certain kind of normal editing like size, rotation, etc in your package of choice without collapsing resetting everything, UDK will read this 'dirty' data.

    Not sure if importation/exportation option play a role, since I export everything as an ASE with 1 smoothing group import.

    EDIT: I just realized that maybe my information could be wrong, since I have a custom material setup with a Blinn based Specular, not sure if this adds to anything.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    I used BSP brushes so I could exclude any errors from from exporting geo.

    Does your custom mat exclude the lightmap spec?
  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
    DeadlyFreeze, how did you fix the normal map you showed previously in post #26?

    I feel like I've tried every possible approach, but no matter what I do the specular still shows up wrong.
    I can make the normal show up just fine by switching the Red and Green channels. Though I noticed that if I used the normal as the diffuse, there are slight variations in the colors between the unedited normal map and the edited.
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    The fix was swapping red and green channel on the normal. That was the only difference between the piece being rotated 90 and the one rotated 180. You should only do the swap on a piece that is getting rotated 90 degrees, anything more and lightmap spec will get broken again.

    Could you throw up a screen shot so we can see what your doing?
  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
    Alright, I started a new scene with the Afternoon Lighting.

    Placed 4 bsp cubes next to each other. Applied Material 1:

    K8on5.jpg

    The result looks like this:

    6DN7Y.jpg

    Then I proceed to rotate 1 BSP face, make the 2nd material and apply it to the rotated face:

    CjGF6.jpg

    Now at this point it actually looks fine, but as soon as I bake the light information, it doesn't work anymore.
    Notice that the green color is slightly off compared to the other boxes.

    58wvU.jpg
  • DeadlyFreeze
    Offline / Send Message
    DeadlyFreeze polycounter lvl 11
    Ah I see what your doing. I tried this myself actually, trying to setup a material so I wouldn't have to render out other normal maps.

    I ended up at the same place you are which seems to be an issue with how UDK appends the channels. It looks fine in the mat editor but never worked for me either. The only way I've made it work was by using another normal map completely.
  • osman
    Have you tried posting this over at the UDK forums? It seems like something they should/could fix.
  • Linkitch
    Offline / Send Message
    Linkitch polycounter lvl 7
  • spicejustin@gmail.com
    Offline / Send Message
    [email protected] polycounter lvl 6
    having the same problems! gaaaa

    [IMG][/img]71jjvr.jpg
Sign In or Register to comment.