BramStoutProductions / MiEx

A modern Minecraft Exporter
BSD 3-Clause "New" or "Revised" License
61 stars 9 forks source link

PBR Material Template Resource Packs #75

Open BramStout opened 6 months ago

BramStout commented 6 months ago

The material templating system is very customisable and can support pretty much anything. Currently, the default material templates only support the normal diffuse textures and not any special PBR textures. It would be good to have PBR support in MiEx.

Adding in the PBR support directly to the default material templates can make them more complicated, especially since there are multiple PBR formats. Therefore, I propose that the PBR support is done via its own resource pack. Unfortunately, the different material templates (MaterialX, UsdPreviewSurface, Maya resource packs, Blender resource packs, etc.) are all different. This means that for each of those material template resource packs, we'd need to create a PBR resource pack to add in PBR support for that. And we'd need to create such a PBR pack for each PBR format.

These PBR material template resource packs would be located in extras/example_resource_packs/PBR/<PBR Format>/PBR_<base template pack>

I have written an overview of how the creation of such a pack would work: https://github.com/BramStoutProductions/MiEx/wiki/9.-Tutorials---Overviews#adding-support-for-pbr-resource-packs-overview

I currently do not have the time to create the PBR material template resource packs, so I'm opening it up as an issue in case other people are willing to take this task on.

Fyoncle commented 6 months ago

I was exactly about to ask for this few days ago, PBR resoruce packs support, its EZ as hell to do in my opinion, since its only 3 nodes to apply a PBR into blender, but not sure how complicated it will be in the codes of MiEx

BramStout commented 6 months ago

I was exactly about to ask for this few days ago, PBR resoruce packs support, its EZ as hell to do in my opinion, since its only 3 nodes to apply a PBR into blender, but not sure how complicated it will be in the codes of MiEx

MiEx itself wouldn't need to be changed. This can all be done with material templates in a custom resource pack. It's not that difficult, just a bit tedious. Unfortunately, I don't have the time for it right now.

This is what it would look like to add an emission texture to the UsdPreviewSurface material templates. So it would be this for the different PBR textures.

{
    "priority": 0,
    "selection": ["*"],
    "include": ["base"],
    "network": {
        "@texture@_emission": {  # If there is an emission texture
            "MAT": {  # Override the MAT material shading node, no need to specify a type because that's already specified.
                "attributes": {
                    "inputs:emissiveColor": {  # Specify a new value for inputs:emissiveColor
                        "type": "color3f",
                        "connection": "FILE_EMISSION.outputs:rgb"  # Connect it to the FILE_EMISSION node.
                    }
                }
            },
            "FILE_EMISSION": {  # Add in a new node to load in the emission texture.
                "type": "UsdUVTexture",
                "attributes": {
                    "outputs:rgb": {
                        "type": "float3"
                    },
                    "inputs:file": {
                        "type": "asset",
                        "value": "@texture@_emission"  # Specify the texture but with "_emission" at the end of it
                    },
                    "inputs:wrapS": {
                        "type": "string",
                        "value": "repeat"
                    },
                    "inputs:wrapT": {
                        "type": "string",
                        "value": "repeat"
                    },
                    "inputs:st": {
                        "type": "float2",
                        "connection": "UV.outputs:result"  # Hook the UVs up to the already existing UV node used by the normal FILE node.
                    }
                }
            }
        }
    }
}