Jump to content
AmiPolizeiFunk

Let's talk about normal maps and reversing channels

8 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Common understanding is that you "reverse the red channel" on normalmaps for Cities:Skylines. I've been doing that (via heightmaps converted to normalmaps on normalmap-online) ever since I started modding buildings, over a year ago. I'm thinking it must be right, because I've checked my normal maps in game and they look correct. If the shadows were backwards or something, I think I would have noticed.

 

Until a week ago, I had never exported an .fbx in my life. I have only worked in blender and I have only exported .obj's with no ingame rotating or scaling on import. Are we learning now that your output method or import method could have different effects on normal maps?

 

In making my road, we discovered a very odd situation: the only way to get it to look correct and consistent in-game was to create a normal map like this:

1. For faces with unpainted vertices: reverse the GREEN channel in the normal map

2. For faces with magenta-painted vertices (to prevent texture scrolling), DO NOTHING.

This was a very odd discovery! Surely you should not have to make half of your normalmap one way and the other half another way! Are we sure about all of this? Should CO be informed?

 

Those of you that are pro modders that understand the tech of normalmaps and the unity engine, could you please enlighten us a bit?

 

@Ronyx69 has been researching this. What are your latest discoveries?

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

I will make a proper article and maybe a video but here's the tl;dr:

 

Problem 1: Do you reverse the orientation of the USB stick to put it in? That depends on which way it is currently facing.

Some normal map generators incorrectly report whether or not the red channel is inverted, most of them have an option called Invert X / Invert Red, but you can find two different normal map generators, use the same settings (let's say no inversion) yet they will have different red channels.

So before you invert the red channel, you need to make sure it's already inverted.

I am going by the standard defined here: https://en.wikipedia.org/wiki/Normal_mapping#How_it_works

The Ps plugin I use (xnormal) is correct, if you don't invert it, it's not inverted, but the one here http://cpetry.github.io/NormalMap-Online/ inverts it by default, so the red channel is the other way around, even though both don't have any inversion settings applied.

Here is a correct normal map, and also showing the red and green channels seperately (colored for easier understanding), on the red channel it should look like "light is coming" from the right, and on the green channel the "light is coming" from the top, this is because the "light is coming" from the positive x and y directions.

 RLIMzQX.png

So you have to make sure what your generator is doing, and make sure it's not inverted according to the standard linked above and shown in the picture.

 

Problem 2: Asset importer mesh rotation feature is broken and produces broken tangents, you must make sure the rotation is correct for the game before you import, or if you use the mesh rotation then run this script https://gist.github.com/ronyx69/29dfd41933b6735ac3a442455e1ef6ee , or use the mod made by Egi I will release soon.

 

Problem 3: For networks, faces vertex painted magenta (that is they are not using the automatic tiling and you have full control of the uv mapping) work the same way as for anything else described above. But for faces which are not vertex painted magenta (that is they are using the automatic tiling as any network usually does) the green channel usually needs to be flipped.

But if you enable the invert flag (which you would use to make an asymmetric network mesh be continuous - that means not flipped on every other segment) then the normal map will be flipped on every other segment as well. So if you are making an asymmetric network (like a castle wall or something) that requires a normal map and you want to always have it appear correctly, you would need two seperate segments, one of which would either have a flipped mesh or a flipped green channel, and then set up the invert flags for them in a way in which the segment with the correct looking normal map for that orientation is visible.

In some situations for nodes the green channel is inverted, no idea why or exactly what makes it happen, it seemed kinda rare.

 

 

I don't know what it is for map theme textures, but I assume it's the same as normal assets, I will check sometime.

  • Like 1

Ronyx rhymes with electronics...  

Steam  //  Twitch  //  YouTube  //  Twitter  //  CSLModding.INFO

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Oh ffs, so the only reason I've been reversing the red channel this entire time is because normalmap-online has been reversing them by default!? I did not know that.

     

    That also means when I talk about channels for roads, since I did not invert Red on normalmap-online, it is still inverting Red. 

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Thanks a lot guys!

    I've been trying to make a cobblestone lane and been experimenting with normal maps but they never looked quite right and now I know what's the problem thanks to pro modders like you guys.

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    Hard to tell anything that is going on with your normalmap from that screenshot where you have the lightsource almost directly behind the camera. Can you take a pic with a more extreme lighting angle? I also found that putting little normalmapped gaps on the curb-stones makes a huge difference.

     

    I'm eagerly anticipating this road @The Urbanist !!

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    2 hours ago, AmiPolizeiFunk said:

    Hard to tell anything that is going on with your normalmap from that screenshot where you have the lightsource almost directly behind the camera. Can you take a pic with a more extreme lighting angle? I also found that putting little normalmapped gaps on the curb-stones makes a huge difference.

     

    I'm eagerly anticipating this road @The Urbanist !!

    Will do soon! Maybe I haven't quite got the normal maps right yet. But after inverting the green channel, there was a huge improvement.

    But now I'm a bit confused: Is this image correct for faces vertex-painted magenta or for faces not vertex-painted?

    RLIMzQX.png

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections