Home Technical Talk

Baking normals in Blender to Cryengine

polycounter lvl 4
Offline / Send Message
code7 polycounter lvl 4
Hello,
I have baked some normal maps in blender. Do I need to invert them before exporting to cryengine. I have imported them without modifying and looks like the bump is inverted. Thanks

Replies

  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    You should only bake normals for Cryengine using Xnormal, using the tangent space plugin they provide for it (CryTB) and a swizzle of X+Y-Z+. Otherwise, you'll get shading errors.
  • code7
    Options
    Offline / Send Message
    code7 polycounter lvl 4
    You should only bake normals for Cryengine using Xnormal, using the tangent space plugin they provide for it (CryTB) and a swizzle of X+Y-Z+. Otherwise, you'll get shading errors.
    Thanks. It worked. Should I use harden edges for low poly when baking.
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    It depends on the shape of your low-poly and high-poly meshes. Generally, you want the low-poly's normals to match the high-poly's normals as closely as possible. If a hard edge is conducive to that, then you should put a hard edge there, but you shouldn't put a hard edge anywhere that there's no UV seam.

    You definitely shouldn't harden every edge in Xnormal, or with flat shading in Blender. That would also cause problems for your bake.
  • code7
    Options
    Offline / Send Message
    code7 polycounter lvl 4
    It depends on the shape of your low-poly and high-poly meshes. Generally, you want the low-poly's normals to match the high-poly's normals as closely as possible. If a hard edge is conducive to that, then you should put a hard edge there, but you shouldn't put a hard edge anywhere that there's no UV seam.

    You definitely shouldn't harden every edge in Xnormal, or with flat shading in Blender. That would also cause problems for your bake.
    Thank you for the advice.
  • grimsonfart
    Options
    Offline / Send Message
    grimsonfart polycounter lvl 4
    You should only bake normals for Cryengine using Xnormal, using the tangent space plugin they provide for it (CryTB) and a swizzle of X+Y-Z+. Otherwise, you'll get shading errors.
    Is there a CE plugin for xNormal? How do i use it?
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Actually, I'm having some serious trouble finding the CryTB.dll plugin anywhere on the internet. I can only really find documentation that says that it was publically available in the past, and it's marked "Obsolete." Here: http://docs.cryengine.com/display/SDKDOC3/Normal+map+baking+with+xNormal

    It looks like they have some new documentation up, which I mostly agree with. Here: http://docs.cryengine.com/display/SDKDOC3/Ambient+Occlusion+and+Normal+map+bake+using+Xnormal Still, that page doesn't mention anything about tangent space and whether you should export the tangent basis or use Xnormal's native Mikktspace tangent basis.

    I'm guessing that it's impossible to get a correct tspace sync right now with Xnormal, unless you have the old CryTB.dll file around, which is probably part of why in the new documentation they recommend adding more geometry and more bevels to fix problems with normal maps. In fact, I'm not really sure if Crytek even knows how their tangent basis is calculated. I suppose they want to keep the 3ds Max tradition of really bad and obscure tangent spaces.

    I did some pipeline testing baking with Xnormal (in mikktspace, as I don't have the CryTB plugin) and taking the results into Cryengine and the results are not very good:

    e3PVvYL.jpg

    This is a cube with one smoothing group, baked in Xnormal in tangent space, with X+Y-Z+ swizzle. I baked the map out again with the tangents exported, and got a different but equally bad result, indicating that the Cryengine Max exporter didn't take the tangent space over.

    gcMWRzv.jpg

    So, until the Handplane guys come out with a TSpace plugin for Cryengine, or someone finds the CryTB.dll plugin, you have to use special tactics to minimize the impact of the tangent space mismatch. This means that you should use lots of bevels and custom normals to minimize the gradients in your normal map. Or, you could just use Unreal and have a synced TSpace with Xnormal out of the box (well, after you go into the Mikktspace options and check the box to calculate binormals in the pixel shader) and not have to worry too much if you have gradients in your normal map. You might also be able to get good bakes out of Max, but I don't know the program well enough to say for sure.

    Tl;dr: Cryengine sucks if you want a real tangent space sync. If you don't care much because you can throw a lot of geometry at the problem, then Cry is great!

    I'm going to look a little harder for CryTB.dll and see if I can find it and get it working tomorrow. I honestly hate working with Cryengine for things like this.
  • Cap
    Options
    Offline / Send Message
    Cap triangle
    As far as I know the cryTB plugin hasnt been supported by crytek or xnormal for a good while, polybump might be what you're looking for.

    http://docs.cryengine.com/display/SDKDOC3/Polybump+Standalone+Tutorial + http://docs.cryengine.com/display/SDKDOC3/Polybump

    Here is a cube baked in Polybump in CE with an excessively shiny mat applied, one smooth group:

    PolyBumpCube01.jpg

    and here is the LP geo in max:

    PolyBumpCube02.jpg

    Ive done this in about 10 mins so its not perfect, but anyone should be able to get a better cube than this if they put there mind to it.

    In addition, here is an older pic with a bunch of cubes baked in 3ds max with different ways you could potentially unwrap and/or build the cubes. This doesnt apply so much to a perfectly synced workflow but it does show you how your results could vary depending on how the mesh was built/smoothed/unwrapped specifically for MAX->CE.

    CEMaxCubes.jpg

    Of course, if you're looking to get a 6 sided cube with one uv island/ one smooth group to shade correctly, I dont think anything is going to help you. If you want to work in CE you'll have to deal with it not being a synced workflow and build your assets with that in mind.

    Edit: also heres the cryTB plugin, but good luck finding the older version of xnormal that supports it http://s000.tinyupload.com/index.php?file_id=34972448539338292113
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    I have here the same 1-smoothing-group cube that I've baked in Xnormal 3.17.1, which is the fist one I could get working with the CryTB plugin that Cap so kindly posted. <3 Here are the results:

    5PXeo8v.png

    If you want to try for yourself, you can grab Xnormal 3.17.1 here: http://eat3d.com/forum/official-releases/xnormal-3171

    As you can see, the TB sync is far from perfect, but it's quite a bit better than the Mikktspace bake. You also have to set your FBX export version to FBX 2011 so that Xnormal can read it, but that's hardly a deal-breaker.

    Here's the same cube, but baked in Max.

    Q1mildB.png

    The TSpace synce is a little worse if you bake it in 3ds Max compared to baking it in Xnormal 3.17.1 with CryTB, so I still stand by my initial recommendation. However, with CryTB the sync is still not perfect, so you'll definitely want to bake with relatively high polycount geometry, possibly with custom normals, to get a correct result.
  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    One problem I've found with baking with CryTB.dll is that it doesn't seem to allow you to take custom normals into account. You also can't change the lowpoly normals to "averaged" or "hardened". In any of these cases, you'll find that you get an error saying that Xnormal tried to read from or write to protected memory. So, if you want to bake something with custom normals, you'll have to do it either in Xnormal with a .fbx exported mont29's Blender test builds to export custom normals, or in 3ds Max, with Max having the better tangent basis sync between the two.

    Here's the result I get by baking in Max with a 44-triangle cube with custom normals. There's still an unsightly line across the top caused by triangulation, which I'm not sure is possible to solve. Anyway, here's the beef:

    k12oCep.png

    I've had triangulation issues in UE4 as well on some of my tangent basis testers, so I'm pretty sure there's no easy solution for this. However, it's pretty plain that if you take a similar approach of drastically increasing the polycount of everything in your scene, you'll still be able to get some pretty accurate results.
  • AlecMoody
    Options
    Offline / Send Message
    AlecMoody ngon master
    I doubt there will ever be a crytek output for handplane. A studio using cryengine already did their best to get us documentation and crytek was not interested. If one of their licensees can't convince them to provide support I don't think anything will.
Sign In or Register to comment.