Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing MiEx Imports #563

Open
1 task done
StandingPadAnimations opened this issue Apr 27, 2024 · 7 comments
Open
1 task done

Fixing MiEx Imports #563

StandingPadAnimations opened this issue Apr 27, 2024 · 7 comments
Labels
enhancement Feature requests or new functionality suggestions
Milestone

Comments

@StandingPadAnimations
Copy link
Collaborator

StandingPadAnimations commented Apr 27, 2024

Check against existing requests

  • I have checked existing feature requests, and my idea is different

Describe the context

MiEx (https://github.com/BramStoutProductions/MiEx) is a new exporter that has been used for Minecraft Live's trailers, and was recently open sourced under the BSD 3-Clause license. Unlike previous exporters, it doesn't export OBJ, but instead USD (Mineways does too, but the default is OBJ), and takes advantage of MaterialX. Due to Blender's lack of support at the moment with MaterialX, UsdPreviewSurface has to be used instead, resulting in a lot of manual work needed to get MiEx exports to look good. Of course, this will likely be solved at some point by the Blender Foundation, but USD and MaterialX doesn't seem to be a priority for them.

How do you imagine your feature works?

MCprep has Prep Materials which fixes OBJ imports, so why not a version of Prep Materials that fixes up MiEx exports? This would certainly fill in the gap that currently exists. As @zNightlord has mentioned on the MiEx repo (BramStoutProductions/MiEx#6 (reply in thread)), Blender does have hooks for USD to extend imports.

The only downside is trying to determine what USD imports are MiEx USDs. We don't want this hook to start going haywire on non-related USDs after all.

What existing workaround (or closest thing to a workaround) do you have today (within Blender, MCprep, or any software)? If there is no workaround, explain why you feel this way.

Beyond manual work, no existing workaround exists, due to limitations in Blender's existing feature set.

@StandingPadAnimations StandingPadAnimations added the enhancement Feature requests or new functionality suggestions label Apr 27, 2024
@zNightlord
Copy link
Contributor

The USDHook import is limited to 4.1 unfortunately, it acts as a post import action script.
As for MCprep integration should be more in the material mapping data json file like Mineways and JMC have their own material naming difference, round it back to what MCprep material names to work with.

@StandingPadAnimations
Copy link
Collaborator Author

I think we could also look into extending Prep materials

@StandingPadAnimations
Copy link
Collaborator Author

StandingPadAnimations commented Apr 29, 2024

Testing MCprep 3.5.3 locally on my machine, it seems Prep Materials can already work with MiEx exports (unintentional obviously, probably related to the graceful fallbacks we have in MCprep), which is a good start

EDIT: vegetation doesn't get proper color multiplication in the generated materials

@StandingPadAnimations
Copy link
Collaborator Author

Tagging @TheDuckCow

@BramStout
Copy link

Keep in mind that MiEx has material template, so you don't have to use MaterialX materials or UsdPreviewSurface materials. You could for example create some material templates where you essentially encode native Blender material networks as USD data 1-to-1. Then in the USDHook, you would have access to the USD data from which you can decode the Blender material networks. The main part would be figuring out a mapping from the material in USD to the material in Blender, so that you actually fix the right material.

You could then also say that all node types have a prefix like blender_ so that you can check for that and only decode the material if it contains shading nodes with that prefix in their types. This way the addon isn't going to mess with any other USD file.

@zNightlord
Copy link
Contributor

Using either MaterialX or UsdPreviewSurface is fine since what MCprep works with is the material names.
So keeping the default template settings would be more convenient (having both would need to agree with the names)

Beside USDHook stucked in 4.1 in Blender 3.5 the exposed USD Python binding is good enough if you need to access the USD stage file and go for any shader attributes reference easily. For wanting support old versions of Blender early than that, might have to use external usd python package.

@BramStout
Copy link

In trying to get Unreal Engine to fully load in MiEx exports with materials, I've ended up extending the material templating system to also be able to write out the materials to alternative material definition files. When specifying the types of nodes, you can put in a namespace to tell MiEx what file type it should write that node out into. It can also do this while still writing out all of the other shading nodes just like normal.

So, if it would make it easier for MCprep, I could add in to MiEx that it can write out the material information to some custom file format, maybe like a json file. It could specify the name of the material, the texture, whether it has biome colours on it, keyframes for animated textures, a list of utility textures, whether it has transparency, etc.

It could also just write out full material networks out into a json file which could then be read in by MCprep in any version of Blender and used to create the material network from that. We could then just specify the native Blender shading nodes in the material templates 1-to-1. While MCprep has its own material templating system, users of MiEx might assume that MiEx's material templating system gets used. Just something to keep in mind.

In any case, there are quite a few possibilities, and if I can add anything to MiEx to help with this, then please don't hesitate to submit an issue post on the MiEx repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or new functionality suggestions
Projects
Status: Todo
Development

No branches or pull requests

3 participants