Skip to content

3.) Editing the material values

Manashiku edited this page Apr 1, 2023 · 1 revision

This will go section by section according to how I have it laid out in material_default.fx
Almost all of these values can be copy pasted from the unity materials


Material General

#define BACKFACE_USE_UV2

Some models use a 2nd set of UVs to map a different part of a texture to its back-facing side. This should be toggled off if your model doesnt have a 2nd set of UVs. Either from not being exported properly with minmode's pmx script or simply because that part doesn't use it.

#define MATERIAL_ALPHA_USE


Genshin diffuse textures have, at first glance, weird transparency but it has multiple uses.
Setting this value to 0 will disable to alpha channel completely
Setting this value to 1 will enable the alpha channel and use it as a standard opacity texture except with the alpha values clipped below a certain threshold.
Setting this value to 2 will enable the alpha channel and use it as an emission mask. This will mask off certain parts of the model so they arent affected by either MMD or MMMs internal lighting colors. It will still be affected by the lighting changes from the model or controller morphs.
Setting this value to 3 will enable the alpha channel and use it as a blush expression mask. This will apply a blushed color to the cheeks of the model.

#define ALPHA_CUTOFF


This is to be used in conjunction with #define MATERIAL_ALPHA_USE 2 as it is the value that the alpha channel will be clipped.

#define BLUSH_COLOR


This is the color the cheeks will be painted when #define MATERIAL_ALPHA_USE is set to 3.

#define BLUSH_STRENGTH


This is the blush mask strength and shouldn't be set very high.

#define BLUSH_SLIDER_NAME


The jp name of the pmx morph linked to the blush. While it being the jp name, it doesn't necessarily need to be named in japanese. It just depends on what is animating your blush normally.


Normal Mapping

#define USE_NORMAL_TEXTURE


This line both functions as a toggle as well an input path for the normal map texture.
if your model doesn't use a normal map simply comment this line out and it will be skipped.

#define NORMAL_BUMP_SCALE


Normal map detail scale, the lower the less powerful the normal map is

#define DEBUG_VISUALIZE_NORMALS && #define DEBUG_VISUALIZE_NORMALS_B


These are two debug states you can use to check your normals no matter if the normal map is enabled or not.
The first of the two is just simply the normals in their range: -1 to 1.
The second is the same as the above but the normals have been encoded in a 0 to 1 range.


Detail Line

This only works if there is a normal map loaded and if the blue channel contains a SDF detail texture

#define USE_TEXTURE_LINE

This turns the detail lines on and off

#define LINE_MULTIPLIER

Lines colors. The darker the color the darker the lines.

#define LINE_SMOOTHNESS

Smoothness of the lines.

#define LINE_THICKNESS

Thickness of the lines.

#define DEBUG_VISUALIZE_LINES

Debug state to output just the detail lines. Useful for trying to get


Shadow

These are not all the values related to the shadows as some are per material region

#define USE_LIGHTMAP_AO


Turns on and off the use of the blue channel from the _Lightmap texture for the Ambient Occlusion shadow calculation.

#define USE_VERTEXCOLOR_AO


Turns on and off the use of the red channel from the vertex colors for the Ambient Occlusion shadow calculation.

#define USE_VERTEXCOLOR_RAMP_WIDTH


Turns on and off the use of the blue channel from the vertex colors for the shadow ramp width.

#define USE_RAMP_TEXTURE


Toggles the ramp textures on and off. If this is turned off the shader will use the SHADOW_WARM_COLOR && SHADOW_COOL_COLOR colors from the material regions instead. This is useful for the faces since genshin's face materials actually use 3 different colors for the skin, eyes, and inside the mouths.

#define SHADOW_RAMP_WIDTH


This is used in tandem with the vertex color blue channel if it is toggled to control the overall width of the ramps.

#define SHADOW_LIGHT_AREA


This is the overall shadow area.

#define FACE_SHADOW_SOFTNESS


Softness or "blur" level of the face shadow. At softer values, there will be some noticeable banding. Currently looking into ways I can reduce that.

#define FACE_LIGHTMAP


This is the input for the local path to the _FaceLightmap texture.

#define USE_FACE_SHADOW_MAP


This is necessary to turn on if you want to enable the use of the above lightmap. This value also sets the shader to use the face shading instead of the regular shading. This should generally mean automatically turning off the specular and metal mats but in some cases that doesn't happen(?).

`#define DEBUG_VISUALIZE_SHADOW


Debug state outputs just the shadows. Useful if you're not sure somethings shadow ramps are working correctly.


Material regions

Genshin Impact uses the alpha texture from the _Lightmap texture to test and get sub material regions. This is why the shadow ramps have multiple gradients instead of just one. There are 5 but other Hoyoverse games are known to use more than just those. Star rail for example uses 8 in total...

Material 1

This one is on at all times and cannot be toggled off.

#define COLOR_1

This is the object color for this material region

#define SHADOW_WARM_COLOR_1

This is the warm or default shadow color for this material region. It is the color used if the shadow ramps are turned off.

#define SHADOW_COOL_COLOR_1

This is the cool or nighttime shadow color for this material region. It is used if the shadow ramps are turned off. Controller.pmx controls the blend rate between the warm and cool shadows for both shadow ramps and these.

#define USE_SPECULAR_MAT

This controls the toggle for the whole model's specular, not just the current material region's.

#define SPECULAR_COLOR

This controls the color for the whole model's specular, not just the current material region's.

#define SPECULAR_MULTI_1

This is the current material region's specular intensity.

#define SPECULAR_SHINE_1

This is the current material region's specular power. Think of it like the size of the shine.

#define USE_OUTLINE

This controls the toggle for the whole model's outline, not just the current material region's.

#define OUTLINE_WIDTH

This controls the outline size for the whole model, not just the current material region's.

#define OUTLINE_COLOR_1

This is the current material region's outline color.

Material 2

#define USE_MATERIAL_2

Turn this off to skip the material at this range.

#define COLOR_2

This is the object color for this material region

#define SHADOW_WARM_COLOR_2

This is the warm or default shadow color for this material region. It is the color used if the shadow ramps are turned off.

#define SHADOW_COOL_COLOR_2

This is the cool or nighttime shadow color for this material region. It is used if the shadow ramps are turned off. Controller.pmx controls the blend rate between the warm and cool shadows for both shadow ramps and these.

#define SPECULAR_MULTI_2

This is the current material region's specular intensity.

#define SPECULAR_SHINE_2

This is the current material region's specular power. Think of it like the size of the shine.

#define OUTLINE_COLOR_2

This is the current material region's outline color.

Material 3

#define USE_MATERIAL_3

Turn this off to skip the material at this range.

#define COLOR_3

This is the object color for this material region

#define SHADOW_WARM_COLOR_3

This is the warm or default shadow color for this material region. It is the color used if the shadow ramps are turned off.

#define SHADOW_COOL_COLOR_3

This is the cool or nighttime shadow color for this material region. It is used if the shadow ramps are turned off. Controller.pmx controls the blend rate between the warm and cool shadows for both shadow ramps and these.

#define SPECULAR_MULTI_3

This is the current material region's specular intensity.

#define SPECULAR_SHINE_3

This is the current material region's specular power. Think of it like the size of the shine.

#define OUTLINE_COLOR_3

This is the current material region's outline color.

Material 4

#define USE_MATERIAL_4

Turn this off to skip the material at this range.

#define COLOR_4

This is the object color for this material region

#define SHADOW_WARM_COLOR_4

This is the warm or default shadow color for this material region. It is the color used if the shadow ramps are turned off.

#define SHADOW_COOL_COLOR_4

This is the cool or nighttime shadow color for this material region. It is used if the shadow ramps are turned off. Controller.pmx controls the blend rate between the warm and cool shadows for both shadow ramps and these.

#define SPECULAR_MULTI_4

This is the current material region's specular intensity.

#define SPECULAR_SHINE_4

This is the current material region's specular power. Think of it like the size of the shine.

#define OUTLINE_COLOR_4

This is the current material region's outline color.

Material 5

#define USE_MATERIAL_5

Turn this off to skip the material at this range.

#define COLOR_5

This is the object color for this material region

#define SHADOW_WARM_COLOR_5

This is the warm or default shadow color for this material region. It is the color used if the shadow ramps are turned off.

#define SHADOW_COOL_COLOR_5

This is the cool or nighttime shadow color for this material region. It is used if the shadow ramps are turned off. Controller.pmx controls the blend rate between the warm and cool shadows for both shadow ramps and these.

#define SPECULAR_MULTI_5

This is the current material region's specular intensity.

#define SPECULAR_SHINE_5

This is the current material region's specular power. Think of it like the size of the shine.

#define OUTLINE_COLOR_5

This is the current material region's outline color.


Metal

#define USE_METAL_MAT

This doubles as both a toggle for the metal shading on the whole model as well as the input path for the metal matcap texture.

#define USE_SPECULAR_RAMP

This doubles as both a toggle for using the specular ramp in the metal shading as well as the input path for the specular ramp texture.

#define METAL_BRIGHTNESS

The general brightness of the metal matcap

#define METAL_TILE

The tiling count for each axis of the sphere mapping.

#define METAL_SHARP_OFFSET

Metal highlight sharpness offset.

#define METAL_SHININESS

Metal specular power.

#define METAL_SPECULAR_IN_SHADOW

Metal specular intensity in shadowed areas.

#define METAL_SPECULAR_SCALE

Metal specular intensity in general areas.

#define METAL_LIGHT

Color to be blended into the light areas of the metal matcap texture.

#define METAL_DARK

Color to be blended into the dark areas of the metal matcap texture.

#define METAL_SHARP_COLOR

Color to be used in places where the highlight is sharp.

#define METAL_SPECULAR_COLOR

Color of the metal's specular highlight.

#define METAL_SHADOW_COLOR

Color of the metal in a shadowed area.

Clone this wiki locally