Git Product home page Git Product logo

Comments (9)

mmikk avatar mmikk commented on July 24, 2024

Thanks for reaching out. Before I dig in just a quick thing to confirm. If you triangulate the mesh in blender first (you can use the modifier stack so it’s not destructive), then do the bake, then export this version of the mesh so you bring the same triangulation of the mesh into your engine. Does the problem go away? Similar to Gouraud shading how you tringulate your polygons has an impact on your interpolated vertex attributes.

Morten

from mikktspace.

mmikk avatar mmikk commented on July 24, 2024

The two copies of mikktspace should definitely generate identical results. Ill take a look at that

from mikktspace.

CaffeineViking avatar CaffeineViking commented on July 24, 2024

Thanks for the lighting fast reply! I'm pretty sure that they were triangulated before baking/export (I'll double-check with our artist).

from mikktspace.

CaffeineViking avatar CaffeineViking commented on July 24, 2024

Actually, the warping is a bit hard to see in my earlier screenshots, here's a short video we did at some point to compare the results:

mikkt_tests_f_game_tangent_export_2021_03_24.mp4

The face without any kind of warping corresponds to the case where tangents between Blender and our converter were matching:

 

  • No Tangents Exported: tangent vertex attributes were generated through our converter (which was using this implementation).
  • Tangents Exported: we use the tangent data directly from the FBX we get from Blender (i.e. using Tangent Space export option).

from mikktspace.

CaffeineViking avatar CaffeineViking commented on July 24, 2024

Yeah, they should've been per-triangulated in Blender according to our artist. I opened them in Blender and they do indeed seem to be proper. The normal map was baked in Substance. Contained within mikkt_tests.zip are our test assets. Here's a short description:

  • mikkt_tests_01_blender_high.fbx: high-polygon ground truth made in Blender (pretty much a cube with some rounded edges).
  • mikkt_tests_01_blender_n.tga: baked per-pixel MikkTSpace normal map for a single UV shell (i.e. for the two FBX files below).
  • mikkt_tests_01_blender_tangents_exported.fbx: low-poly single UV shell version of the asset, tangents exported from Blender.
  • mikkt_tests_01_blender_no_tangents_exported.fbx: low-poly single UV shell, tangents need to be generated through our code.
  • mikkt_tests_01_blender_separate_shells_n.tga: baked per-pixel MikkTSpace normal map with multiple UV islands (see below).
  • mikkt_tests_01_blender_tangents_exported_separate_shells.fbx: low-poly multiple UV islands, tangents exported from Blender.
  • mikkt_tests_01_blender_no_tangents_exported_separate_shells.fbx: low-poly multi-UV islands, tangents need to be generated.

Artists have been trying to follow this guide: Generating Perfect Normal Maps for Unity, but maybe we're still missing something. I'll also try to do a bit more digging later this week and see if I can pin down what's wrong, since I still have both versions of the code.

from mikktspace.

mmikk avatar mmikk commented on July 24, 2024

bakes.zip

Could you try these two? It's a bake from xnormal and one from knald. Neither one uses Blender's version of the .c file but both are working as intended. What happens when you use these in your engine?

Btw this was baked to mikkt_tests_01_blender_no_tangents_exported.fbx

from mikktspace.

CaffeineViking avatar CaffeineViking commented on July 24, 2024

Hey Morten, thanks for checking that out for us! I downloaded those bakes and proceeded to try them in our engine with that asset:

 

I think the left one was the one from Knald and the one on the right is the one from xNormal, notice the warping in that closest one.

Since it sounded like it worked on your side that got me thinking what could be different between our implementation and the one in this repository (and why it worked when we pulled the one from Blender). Well, it turns out that it was something embarrassing... Our compiler is setup to treat warnings as errors, even in middleware code (which is kind of stupid to begin with), so when I ported over mikktspace.c we got quite a few warnings that I needed to fix. I quickly hacked that together and didn't think too much of it.

Well, it turns out when doing vimdiff between those changes and the code here reveals a pretty stupid change I didn't notice I did:

I didn't actually notice that was a union before double checking now, so that explains the weird edge connections I was getting πŸ˜…. Instead of fixing those compilation warnings, I just pulled this repository again and disabled warnings with a few pragma directives. And yeah, after that, the results are completely perfect xD (not so surprisingly). So there is absolutely nothing wrong with the code here, it was just me being too carefree when patching out the warnings and not thinking too much about it afterwards... **sigh**

Thank you very much for your patience and help Morten! I think the mystery has been solved on our side at least πŸ˜…. Closing issue!

from mikktspace.

mmikk avatar mmikk commented on July 24, 2024

No problem. I'm glad it was an easy fix for you :)

from mikktspace.

perkele1989 avatar perkele1989 commented on July 24, 2024

After reading the tech deep dive of Northlight / Alan Wake 2 today, I've been feeling that impostor syndrome. You've really done an amazing job on that engine, twisting the GPU to do your bidding for you in ways I couldn't have imagined. Very impressive.

Then I found this issue while integrating mikktspace in my engine, and realize it's one of you guys. Instantly felt much better lol. What are the odds? Great work on Northlight, you are an inspiration.

And sorry for off-topic.

from mikktspace.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.