focustense / easymod

Modding for the modern age.
44 stars 2 forks source link

Dynamic previews #38

Open evertiro opened 3 years ago

evertiro commented 3 years ago

I know it's a big ask and not going to happen any time soon, and my C# is rusty at best so I probably won't be much help short-term, but I thought it worthwhile to at least open an issue to discuss what it would take to make this happen. For modding guides on the scale of Lexy's and mine, a true visual NPC picker that can do what EasyNPC does would be a game-changer, so I'm willing to put in as much legwork as I can to make it happen.

focustense commented 3 years ago

It is, indeed, big and long-term. To summarize what's required, there are two major problems to solve, one that I believe has recently been "mostly solved" to my satisfaction, and one additional minor problem.

The major problems are:

  1. The facegen NIFs themselves are not entirely suitable for rendering. You can see this if you open some of them directly in NifSkope, even if you have all the right resources configured:

    NifSkope uggs

    This is one of the better examples, from a mod author who tends to be somewhat conscientious with facegens. Other ones may have wrong texture paths, especially facetints, or various other issues that make them look not-awesome.

    I've recently put together a small tool called MugPrep that, for now, is just intended to make my life easier when creating the static preview images. However, the same code can be used to automate some of the more complex fixes, either in real time or maybe on a background thread while EasyNPC is running. The most important thing it does is dive into the NPC's skeleton, compute all the worldspace transforms for the different bones, and apply them back to the NIF. The code here fixes most of the common issues, but not all; it would not need to be improved, and ported into a reusable library.

  2. Actually rendering the NIF on screen.

    The truth is, I wouldn't even know where to start. I don't need C# help on this, I would need to consult with someone who has experience - probably a few years of experience - with 3D graphics, such as the BodySlide or NifSkope devs. I haven't approached anyone specifically, as I think there are a lot of important features and bug fixes in front of this one in the queue.

    The NIF format alone is pretty complicated, even with a parser like Nifly, and that's to say nothing of the DirectX/OpenGL code involved. Even if I get help from someone who knows this stuff well in C++, I'd then have to translate it into the .NET framework. Any of these steps could possibly be very simple, if there's already a library to do it or if there's an expert or two to lean on, or could be incredibly complicated if it ends up being an exploration of unknown territory.

Those are the major, blocking bugs. There is one other, minor issue, that I think could be resolved without much difficulty given the aforementioned two, but would still require extra work, and that is texture overrides. Facegen files have their own texture references, but these can be overridden at many different levels in the Bethesda record structure. These different sources of data have to all be joined together to display a face in the same way that the game would.

Performance may turn out to be a fourth issue, but I'm not sure about that. Rendering a half-dozen raster (PNG) images is actually already a bit slow, so rendering that many 3D meshes without any pre-caching could be very slow indeed. This might require changes to the UI, or a more aggressive caching strategy, requiring a lot more memory usage by the app, etc. These are more distant concerns, I'm just bringing them up because they could drag out the release even after everybody's pitched in to build the basic feature. It might have to start off as more of a "static image but click for a live preview" sort of thing, to avoid overwhelming the average user's PC.

That's the story in a very large nutshell. The main thing that's missing right now is an expert - or at least someone highly proficient - in 3D graphics, i.e. OpenGL or DirectX programming, and a second expert on NIFs if it's not the same person. As much as I'd love to trumpet my own skills, I don't think I could become proficient in those things myself in a matter of weeks, or months - not without a lot of help.