From 3D modeling software to Minecraft - ModularMods/MCglTF GitHub Wiki

This is for 3D Content Artist that use Windows 10 x86-64 platiform for content creation, I assume you have already read the overview of glTF.

Materials and Textures Preparation

Before you start creating or converting an existing model, you must know why MCglTF does not recommend to use existing material properties defined by glTF specification for current situation.

  1. Properties inside materials have a lots of difference between glTF V1 and V2 specification.
  2. Most shader pack only use color map, normals map, and specular map specially defined by OptiFine.

So whether it is glTF V1 or glTF V2, you must define material properties inside extras of materials.

"materials": [
	{
		"extras": {
			"baseColorTexture": {
				"index": 0
			},
			"normalTexture": {
				"index": 0
			},
			"specularTexture": {
				"index": 0
			},
			"baseColorFactor": [1.0, 1.0, 1.0, 1.0],
			"doubleSided": false
		}
	}
]
Property Description Default Value
baseColorTexture The index of the texture for color map If this property doesn't exist, #FFFFFFFF RGBA color will be supply
normalTexture The index of the texture for normal map If this property doesn't exist, #7F7FFFFF RGBA color will be supply
specularTexture The index of the texture for specular map If this property doesn't exist, #00000000 RGBA color will be supply
baseColorFactor Tinting of the model, will be overrided if vertex color attribute is specified [1.0, 1.0, 1.0, 1.0]
doubleSided Whether the back face should be render false

The usage for each RGBA channel in normal map and specular map are different depending on the shader pack in use.

glTF V2 material specification fallback

From MCglTF version 2.1.0.0 and above. If your model is in glTF V2 format and material properties inside extras of materials does not exist, it will try using corresponding properties of glTF V2 material before using Default Value.

Property Corresponding glTF V2 property
baseColorTexture pbrMetallicRoughness/baseColorTexture
normalTexture normalTexture
specularTexture metallicRoughnessTexture
baseColorFactor pbrMetallicRoughness/baseColorFactor
doubleSided doubleSided

There might have a chance that this fallback feature may drop and change the usage of glTF V2 material properties to different purpose in the future.

Since there is a mod called Canvas Renderer which will allow custom shader for Block, Entity, and Item. It might be used by MCglTF to fully implement original purpose of glTF V2 material.

And developers of Iris Shaders will introduce a new render system similar to Canvas Renderer currently known as Programmable Pipeline Interface. Which will give more control on GLSL shader beyond OptiFine shader specification.

Additional note

If your model will use normal maps, please read this topic to know more info about the format of the normal map and the tangents attribute for the model.

RGBA channel usage of BSL Shaders

SEUS/Old PBR

color map normal map specular map
R Albedo Red Normal X Glossiness
G Albedo Green Normal Y Metallic
B Albedo Blue UNUSE Emissive
A Opacity Height UNUSE

LabPBR

https://wiki.shaderlabs.org/wiki/LabPBR_Material_Standard

Normal map format

  • Orientation: Direct3D Y-
  • MikkTSpace Bitangent Calculation: per vertex

Texture conversion guide

  • Glossiness is invert of Roughness.
  • Normal texture in glTF specification is OpenGL Y+ orientation, so you need to invert green channel of normal textures from existing glTF model.
  • Converting from glTF V2 emissive texture to emissive strength in blue channel of specular map is a bit tricky.
    1. You need to knockout black area of original emissive texture, and cover it on color map.
    1. Make the original emissive texture into black and white and then combines with specular map, this may takes some adjustment to make sure emissive strength looks right in game.

Additional Note

If you are looking for a free image editor to handle these RGBA channel, I recommend you to use paint.NET with Modify Channels plugin. As for adjust black and white conversion for emissive texture, you can try Black and White+ from BoltBait's plugin.

Convert Your Model to glTF

Some 3D modeling software support exporting glTF model. But if not, you can export your model as FBX format and using FBX2glTF to convert to glTF.

By using FBX2glTF, you can use -keep-attribute to remove some unwanted attributes to reduce file size.

For example, if your model is just a simple cube-ish model like Vanilla, -keep-attribute position color uv0 would be enough.

After conversion is done, now it is time to preview your glTF file in VSCode with glTF tools extension.

There are 4 render engine in glTF tools extension. From my experience, if one of render engine render your model properly like what you see in your 3D modeling software, that means this model will work properly in MCglTF.

The VSCode can be also a tool for add those required extras properties for MCglTF or editing transform for nodes, since it will highlight any problem if you are doing something wrong.

Finally, if you are not going to export model as .glb, you can find any Json extension for VSCode to make your .glTF compact by remove any indent and convert text into one line.

ResourceLocation for External Images and Buffers Resource

Since you can not use any relative or absolute path for uri in MCglTF, you need to use ResourceLocation for those external resources as usual.

Simply adds resourceLocation property inside extras of the buffers and images.

"buffers": [
	{
		"uri": "buffer.bin",
		"extras": {
			"resourceLocation": "domain:your/resource/location/buffer.bin"
		}
	}
]
"images": [
	{
		"uri": "image.png",
		"extras": {
			"resourceLocation": "domain:your/resource/location/image.png"
		}
	}
]