mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-20 09:34:42 -05:00
Merge pull request #1817 from Santarh/addMatcapFactor
Add implementation of matcapFactor
This commit is contained in:
@@ -101,6 +101,7 @@ namespace UniVRM10
|
||||
}
|
||||
|
||||
// Rim Lighting
|
||||
mtoon.MatcapFactor = context.MatcapColorFactorSrgb.ToFloat3(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
var matcapTextureIndex = textureExporter.RegisterExportingAsSRgb(context.MatcapTexture, needsAlpha: false);
|
||||
if (matcapTextureIndex != -1)
|
||||
{
|
||||
|
||||
@@ -79,6 +79,13 @@ namespace UniVRM10
|
||||
yield return (MToon10Prop.EmissiveFactor.ToUnityShaderLabName(), emissionColor.Value);
|
||||
}
|
||||
|
||||
// Matcap
|
||||
var matcapColor = mToon?.MatcapFactor?.ToColor3(gltfColorSpace, ColorSpace.sRGB);
|
||||
if (matcapColor.HasValue)
|
||||
{
|
||||
yield return (MToon10Prop.MatcapColorFactor.ToUnityShaderLabName(), matcapColor.Value);
|
||||
}
|
||||
|
||||
// Rim Lighting
|
||||
var rimColor = mToon?.ParametricRimColorFactor?.ToColor3(gltfColorSpace, ColorSpace.sRGB);
|
||||
if (rimColor.HasValue)
|
||||
|
||||
@@ -147,37 +147,44 @@ namespace VRMShaders.VRM10.MToon10.Editor
|
||||
|
||||
using (new LabelScope("Rim Lighting"))
|
||||
{
|
||||
materialEditor.TexturePropertySingleLine(
|
||||
new GUIContent("Rim Color", "Rim Color (RGB)"),
|
||||
props[MToon10Prop.RimMultiplyTexture]
|
||||
);
|
||||
if (isAdvancedEditMode)
|
||||
{
|
||||
materialEditor.TexturePropertySingleLine(
|
||||
new GUIContent("Mask", "Rim Lighting Mask (RGB)"),
|
||||
props[MToon10Prop.RimMultiplyTexture]
|
||||
);
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.RimLightingMixFactor],
|
||||
new GUIContent("Rim LightingMix")
|
||||
new GUIContent("LightingMix")
|
||||
);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
using (new LabelScope("Matcap"))
|
||||
{
|
||||
materialEditor.TexturePropertySingleLine(
|
||||
new GUIContent("Matcap Rim", "Matcap Rim (RGB)"),
|
||||
props[MToon10Prop.MatcapTexture]
|
||||
new GUIContent("Matcap", "Matcap (RGB)"),
|
||||
props[MToon10Prop.MatcapTexture],
|
||||
props[MToon10Prop.MatcapColorFactor]
|
||||
);
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
using (new LabelScope("Parametric Rim"))
|
||||
{
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimColorFactor],
|
||||
new GUIContent("Color")
|
||||
);
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimFresnelPowerFactor],
|
||||
new GUIContent("Fresnel Power")
|
||||
);
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimLiftFactor],
|
||||
new GUIContent("Lift")
|
||||
);
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimColorFactor],
|
||||
new GUIContent("Parametric Rim Color")
|
||||
);
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimFresnelPowerFactor],
|
||||
new GUIContent("Parametric Rim Fresnel Power")
|
||||
);
|
||||
materialEditor.ShaderProperty(
|
||||
props[MToon10Prop.ParametricRimLiftFactor],
|
||||
new GUIContent("Parametric Rim Lift")
|
||||
);
|
||||
}
|
||||
|
||||
using (new LabelScope("Outline"))
|
||||
|
||||
@@ -29,6 +29,7 @@ Shader "VRM10/MToon10"
|
||||
_EmissionMap ("emissiveTexture", 2D) = "white" {} // Unity specified name
|
||||
|
||||
// Rim Lighting
|
||||
_MatcapColor ("mtoon.matcapFactor", Color) = (1, 1, 1, 1)
|
||||
_MatcapTex ("mtoon.matcapTexture", 2D) = "black" {}
|
||||
_RimColor ("mtoon.parametricRimColorFactor", Color) = (0, 0, 0, 1)
|
||||
_RimFresnelPower ("mtoon.parametricRimFresnelPowerFactor", Range(0, 100)) = 5.0
|
||||
|
||||
@@ -22,6 +22,7 @@ float4 _MainTex_ST;
|
||||
half4 _Color;
|
||||
half4 _ShadeColor;
|
||||
half4 _EmissionColor;
|
||||
half4 _MatcapColor;
|
||||
half4 _RimColor;
|
||||
half4 _OutlineColor;
|
||||
// Floats
|
||||
|
||||
@@ -124,11 +124,11 @@ inline half3 GetMToonLighting_Rim_Matcap(const MToonInput input)
|
||||
const half3 matcapRightAxisWS = normalize(cross(input.viewDirWS, worldUpWS));
|
||||
const half3 matcapUpAxisWS = normalize(cross(matcapRightAxisWS, input.viewDirWS));
|
||||
const half2 matcapUv = float2(dot(matcapRightAxisWS, input.normalWS), dot(matcapUpAxisWS, input.normalWS)) * 0.5 + 0.5;
|
||||
return UNITY_SAMPLE_TEX2D(_MatcapTex, matcapUv).rgb;
|
||||
return _MatcapColor.rgb * UNITY_SAMPLE_TEX2D(_MatcapTex, matcapUv).rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return _MatcapColor.rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -111,6 +111,10 @@ namespace VRMShaders.VRM10.MToon10.Runtime
|
||||
get => _material.GetTexture(MToon10Prop.EmissiveTexture);
|
||||
}
|
||||
// Rim Lighting
|
||||
public Color MatcapColorFactorSrgb
|
||||
{
|
||||
get => _material.GetColor(MToon10Prop.MatcapColorFactor);
|
||||
}
|
||||
public Texture MatcapTexture
|
||||
{
|
||||
get => _material.GetTexture(MToon10Prop.MatcapTexture);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
EmissiveTexture,
|
||||
|
||||
// Rim Lighting
|
||||
MatcapColorFactor,
|
||||
MatcapTexture,
|
||||
ParametricRimColorFactor,
|
||||
ParametricRimFresnelPowerFactor,
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace VRMShaders.VRM10.MToon10.Runtime
|
||||
[MToon10Prop.EmissiveFactor] = "_EmissionColor",
|
||||
[MToon10Prop.EmissiveTexture] = "_EmissionMap",
|
||||
|
||||
[MToon10Prop.MatcapColorFactor] = "_MatcapColor",
|
||||
[MToon10Prop.MatcapTexture] = "_MatcapTex",
|
||||
[MToon10Prop.ParametricRimColorFactor] = "_RimColor",
|
||||
[MToon10Prop.ParametricRimFresnelPowerFactor] = "_RimFresnelPower",
|
||||
|
||||
Reference in New Issue
Block a user