From 0f3bdf3b2be01b0a7e47ba50e1343d5dd725975a Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 09:26:11 +0900 Subject: [PATCH 01/35] =?UTF-8?q?URP=E5=90=91=E3=81=91=E3=81=AE=E3=82=B7?= =?UTF-8?q?=E3=82=A7=E3=83=BC=E3=83=80=E3=83=BC=E3=82=92=E3=81=A8=E3=82=8A?= =?UTF-8?q?=E3=81=82=E3=81=88=E3=81=9A=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10_Samples/URPSample/Materials.meta | 8 + .../URPSample/Materials/URPMToon10.mat | 175 ++++++++++++++++++ .../URPSample/Materials/URPMToon10.mat.meta | 8 + .../VRM10/vrmc_materials_mtoon_urp.shader | 139 ++++++++++++++ .../vrmc_materials_mtoon_urp.shader.meta | 9 + 5 files changed, 339 insertions(+) create mode 100644 Assets/VRM10_Samples/URPSample/Materials.meta create mode 100644 Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat create mode 100644 Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta diff --git a/Assets/VRM10_Samples/URPSample/Materials.meta b/Assets/VRM10_Samples/URPSample/Materials.meta new file mode 100644 index 000000000..c535ae03a --- /dev/null +++ b/Assets/VRM10_Samples/URPSample/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 282c8c12552fd4c42840a5dda6ae2c9b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat new file mode 100644 index 000000000..58af27684 --- /dev/null +++ b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat @@ -0,0 +1,175 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-9194869756555787169 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 4 +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: URPMToon10 + m_Shader: {fileID: 4800000, guid: 0781c64b7f2a1604ea6aa7e252080372, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MatcapTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OutlineWidthTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _RimTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ShadeTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ShadingShiftTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _UvAnimMaskTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AlphaClip: 0 + - _AlphaMode: 0 + - _Blend: 0 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DoubleSided: 0 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GiEqualization: 0.9 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _M_AlphaToMask: 0 + - _M_CullMode: 2 + - _M_DebugMode: 0 + - _M_DstBlend: 0 + - _M_EditMode: 0 + - _M_SrcBlend: 1 + - _M_ZWrite: 1 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _OutlineLightingMix: 1 + - _OutlineWidth: 0 + - _OutlineWidthMode: 0 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _RenderQueueOffset: 0 + - _RimFresnelPower: 5 + - _RimLift: 0 + - _RimLightingMix: 1 + - _ShadingShiftFactor: -0.05 + - _ShadingShiftTexScale: 1 + - _ShadingToonyFactor: 0.95 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _TransparentWithZWrite: 0 + - _UvAnimRotationSpeed: 0 + - _UvAnimScrollXSpeed: 0 + - _UvAnimScrollYSpeed: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _MatcapColor: {r: 0, g: 0, b: 0, a: 1} + - _OutlineColor: {r: 0, g: 0, b: 0, a: 1} + - _RimColor: {r: 0, g: 0, b: 0, a: 1} + - _ShadeColor: {r: 1, g: 1, b: 1, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta new file mode 100644 index 000000000..552edcd93 --- /dev/null +++ b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3b3d2f142a7a89b42a3d483dacb0a2af +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader new file mode 100644 index 000000000..47e83e335 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -0,0 +1,139 @@ +Shader "VRM10/MToon10_URP" +{ + Properties + { + // Rendering + _AlphaMode ("alphaMode", Int) = 0 + _TransparentWithZWrite ("mtoon.transparentWithZWrite", Int) = 0 + _Cutoff ("alphaCutoff", Range(0, 1)) = 0.5 // Unity specified name + _RenderQueueOffset ("mtoon.renderQueueOffsetNumber", Int) = 0 + _DoubleSided ("doubleSided", Int) = 0 + + // Lighting + _Color ("pbrMetallicRoughness.baseColorFactor", Color) = (1, 1, 1, 1) // Unity specified name + _MainTex ("pbrMetallicRoughness.baseColorTexture", 2D) = "white" {} // Unity specified name + _ShadeColor ("mtoon.shadeColorFactor", Color) = (1, 1, 1, 1) + _ShadeTex ("mtoon.shadeMultiplyTexture", 2D) = "white" {} + [Normal] _BumpMap ("normalTexture", 2D) = "bump" {} // Unity specified name + _BumpScale ("normalTexture.scale", Float) = 1.0 // Unity specified name + _ShadingShiftFactor ("mtoon.shadingShiftFactor", Range(-1, 1)) = -0.05 + _ShadingShiftTex ("mtoon.shadingShiftTexture", 2D) = "black" {} // channel R + _ShadingShiftTexScale ("mtoon.shadingShiftTexture.scale", Float) = 1 + _ShadingToonyFactor ("mtoon.shadingToonyFactor", Range(0, 1)) = 0.95 + + // GI + _GiEqualization ("mtoon.giEqualizationFactor", Range(0, 1)) = 0.9 + + // Emission + [HDR] _EmissionColor ("emissiveFactor", Color) = (0, 0, 0, 1) // Unity specified name + _EmissionMap ("emissiveTexture", 2D) = "white" {} // Unity specified name + + // Rim Lighting + _MatcapColor ("mtoon.matcapFactor", Color) = (0, 0, 0, 1) + _MatcapTex ("mtoon.matcapTexture", 2D) = "black" {} + _RimColor ("mtoon.parametricRimColorFactor", Color) = (0, 0, 0, 1) + _RimFresnelPower ("mtoon.parametricRimFresnelPowerFactor", Range(0, 100)) = 5.0 + _RimLift ("mtoon.parametricRimLiftFactor", Range(0, 1)) = 0 + _RimTex ("mtoon.rimMultiplyTexture", 2D) = "white" {} + _RimLightingMix ("mtoon.rimLightingMixFactor", Range(0, 1)) = 1 + + // Outline + _OutlineWidthMode ("mtoon.outlineWidthMode", Int) = 0 + [PowerSlider(2.2)] _OutlineWidth ("mtoon.outlineWidthFactor", Range(0, 0.05)) = 0 + _OutlineWidthTex ("mtoon.outlineWidthMultiplyTexture", 2D) = "white" {} // channel G + _OutlineColor ("mtoon.outlineColorFactor", Color) = (0, 0, 0, 1) + _OutlineLightingMix ("mtoon.outlineLightingMixFactor", Range(0, 1)) = 1 + + // UV Animation + _UvAnimMaskTex ("mtoon.uvAnimationMaskTexture", 2D) = "white" {} // channel B + _UvAnimScrollXSpeed ("mtoon.uvAnimationScrollXSpeedFactor", Float) = 0 + _UvAnimScrollYSpeed ("mtoon.uvAnimationScrollYSpeedFactor", Float) = 0 + _UvAnimRotationSpeed ("mtoon.uvAnimationRotationSpeedFactor", Float) = 0 + + // Unity ShaderPass Mode + _M_CullMode ("_CullMode", Float) = 2.0 + _M_SrcBlend ("_SrcBlend", Float) = 1.0 + _M_DstBlend ("_DstBlend", Float) = 0.0 + _M_ZWrite ("_ZWrite", Float) = 1.0 + _M_AlphaToMask ("_AlphaToMask", Float) = 0.0 + + // etc + _M_DebugMode ("_DebugMode", Float) = 0.0 + + // for Editor + _M_EditMode ("_EditMode", Float) = 0.0 + } + + // Shader Model 3.0 + SubShader + { + Tags { "RenderType" = "Opaque" "Queue" = "Geometry" } + + // Built-in Forward Base Pass + Pass + { + Name "FORWARD_BASE" + Tags { "LightMode" = "ForwardBase" } + + Cull [_M_CullMode] + Blend [_M_SrcBlend] [_M_DstBlend] + ZWrite [_M_ZWrite] + ZTest LEqual + BlendOp Add, Max + AlphaToMask [_M_AlphaToMask] + + HLSLPROGRAM + #pragma target 3.0 + + // Unity defined keywords + #pragma multi_compile_fwdbase nolightmap nodynlightmap nodirlightmap novertexlight + #pragma multi_compile_fog + #pragma multi_compile_instancing + + #pragma multi_compile __ _ALPHATEST_ON _ALPHABLEND_ON + #pragma multi_compile __ _NORMALMAP + #pragma multi_compile __ _MTOON_EMISSIVEMAP + #pragma multi_compile __ _MTOON_RIMMAP + #pragma multi_compile __ _MTOON_PARAMETERMAP + + #pragma vertex MToonVertex + #pragma fragment MToonFragment + + #include "./vrmc_materials_mtoon_forward_vertex.hlsl" + #include "./vrmc_materials_mtoon_forward_fragment.hlsl" + ENDHLSL + } + + // Shadow rendering pass + Pass + { + Name "ShadowCaster" + Tags { "LightMode" = "ShadowCaster" } + + Cull [_M_CullMode] + ZWrite On + ZTest LEqual + + CGPROGRAM + #pragma target 3.0 + + // Unity defined keywords + #pragma multi_compile_shadowcaster nolightmap nodynlightmap nodirlightmap novertexlight + #pragma multi_compile_instancing + + #pragma multi_compile __ _ALPHATEST_ON _ALPHABLEND_ON + + // Use unity standard shadow implementation. + // internal usage: + // keywords: _ALPHATEST_ON _ALPHABLEND_ON + // variables: _MainTex.a _Color.a _Cutoff + #pragma vertex vertShadowCaster + #pragma fragment fragShadowCaster + + #include "UnityStandardShadow.cginc" + ENDCG + } + } + Fallback "Unlit/Texture" + CustomEditor "VRMShaders.VRM10.MToon10.Editor.MToonInspector" +} diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta new file mode 100644 index 000000000..9d51e8d1a --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0781c64b7f2a1604ea6aa7e252080372 +timeCreated: 1514111466 +licenseType: Free +ShaderImporter: + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: From 9514e7abe1e03b7706cfeb981b816ff37c4e738d Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 09:32:56 +0900 Subject: [PATCH 02/35] =?UTF-8?q?=E3=83=9E=E3=83=86=E3=83=AA=E3=82=A2?= =?UTF-8?q?=E3=83=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 47e83e335..639d3e4bf 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -72,8 +72,8 @@ Shader "VRM10/MToon10_URP" // Built-in Forward Base Pass Pass { - Name "FORWARD_BASE" - Tags { "LightMode" = "ForwardBase" } + Name "UniversalForward" + Tags { "LightMode" = "UniversalForward" } Cull [_M_CullMode] Blend [_M_SrcBlend] [_M_DstBlend] @@ -99,6 +99,8 @@ Shader "VRM10/MToon10_URP" #pragma vertex MToonVertex #pragma fragment MToonFragment + #define MTOON_URP + #include "./vrmc_materials_mtoon_forward_vertex.hlsl" #include "./vrmc_materials_mtoon_forward_fragment.hlsl" ENDHLSL From 86207b7cbd414626e67e8ed46f9534a22d523f23 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 11:05:11 +0900 Subject: [PATCH 03/35] =?UTF-8?q?MTOON=E5=AF=BE=E5=BF=9C=E6=99=82=E3=81=AF?= =?UTF-8?q?UnityCG=E3=82=92=E7=94=A8=E3=81=84=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl | 2 ++ .../MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl | 2 ++ .../Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl | 2 ++ .../MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl | 2 ++ 10 files changed, 20 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl index e406a2491..7c3f85b60 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl @@ -1,8 +1,10 @@ #ifndef VRMC_MATERIALS_MTOON_ATTRIBUTE_INCLUDED #define VRMC_MATERIALS_MTOON_ATTRIBUTE_INCLUDED +#ifndef MTOON_URP #include #include +#endif struct Attributes { diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 84ca54245..ac5ebfd20 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_FORWARD_FRAGMENT_INCLUDED #define VRMC_MATERIALS_MTOON_FORWARD_FRAGMENT_INCLUDED +#ifndef MTOON_URP #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index e536543f3..dc01e79ba 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -1,8 +1,10 @@ #ifndef VRMC_MATERIALS_MTOON_FORWARD_VERTEX_INCLUDED #define VRMC_MATERIALS_MTOON_FORWARD_VERTEX_INCLUDED +#ifndef MTOON_URP #include #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl index 1eda41448..7c23aaf30 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_NORMAL_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_NORMAL_INCLUDED +#ifndef MTOON_URP #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl index 5a9e9ac46..30f6ae553 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_UV_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_UV_INCLUDED +#ifndef MTOON_URP #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl index 6ee24dbde..4a2ce56c0 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_VERTEX_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_VERTEX_INCLUDED +#ifndef MTOON_URP #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl index 274f51d51..7825dd777 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_INPUT_INCLUDED #define VRMC_MATERIALS_MTOON_INPUT_INCLUDED +#ifndef MTOON_URP #include +#endif // Textures UNITY_DECLARE_TEX2D(_MainTex); diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index 39a3c5eb4..44aa72782 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_LIGHTING_MTOON_INCLUDED #define VRMC_MATERIALS_MTOON_LIGHTING_MTOON_INCLUDED +#ifndef MTOON_URP #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index 5940d9bba..c7ee39be5 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -1,9 +1,11 @@ #ifndef VRMC_MATERIALS_MTOON_LIGHTING_UNITY_INCLUDED #define VRMC_MATERIALS_MTOON_LIGHTING_UNITY_INCLUDED +#ifndef MTOON_URP #include #include #include +#endif #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" #include "./vrmc_materials_mtoon_attribute.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl index bd1d91262..e59f7ff79 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_UTILITY_INCLUDED #define VRMC_MATERIALS_MTOON_UTILITY_INCLUDED +#ifndef MTOON_URP #include +#endif // define static const float PI_2 = 6.28318530718; From f48f0e27be2258387273448682ac6585fcfa823c Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 11:13:17 +0900 Subject: [PATCH 04/35] Invert ifdef --- .../Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl | 4 +++- .../VRM10/vrmc_materials_mtoon_forward_fragment.hlsl | 5 ++++- .../Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 5 ++++- .../VRM10/vrmc_materials_mtoon_geometry_normal.hlsl | 5 ++++- .../Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl | 5 ++++- .../VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl | 5 ++++- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl | 4 +++- .../Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl | 5 ++++- .../Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl | 5 ++++- .../Resources/VRM10/vrmc_materials_mtoon_utility.hlsl | 4 +++- 10 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl index 7c3f85b60..7d9a926a3 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_ATTRIBUTE_INCLUDED #define VRMC_MATERIALS_MTOON_ATTRIBUTE_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #include #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index ac5ebfd20..3198ba4b7 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -1,9 +1,12 @@ #ifndef VRMC_MATERIALS_MTOON_FORWARD_FRAGMENT_INCLUDED #define VRMC_MATERIALS_MTOON_FORWARD_FRAGMENT_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index dc01e79ba..316e9b562 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -1,10 +1,13 @@ #ifndef VRMC_MATERIALS_MTOON_FORWARD_VERTEX_INCLUDED #define VRMC_MATERIALS_MTOON_FORWARD_VERTEX_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl index 7c23aaf30..075c13b8a 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl @@ -1,9 +1,12 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_NORMAL_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_NORMAL_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl index 30f6ae553..7864a5c1f 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl @@ -1,9 +1,12 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_UV_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_UV_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl index 4a2ce56c0..032ba2d42 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl @@ -1,9 +1,12 @@ #ifndef VRMC_MATERIALS_MTOON_GEOMETRY_VERTEX_INCLUDED #define VRMC_MATERIALS_MTOON_GEOMETRY_VERTEX_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl index 7825dd777..32a3801fa 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_INPUT_INCLUDED #define VRMC_MATERIALS_MTOON_INPUT_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index 44aa72782..6b6559236 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -1,9 +1,12 @@ #ifndef VRMC_MATERIALS_MTOON_LIGHTING_MTOON_INCLUDED #define VRMC_MATERIALS_MTOON_LIGHTING_MTOON_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_utility.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index c7ee39be5..9d3e8c9eb 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -1,11 +1,14 @@ #ifndef VRMC_MATERIALS_MTOON_LIGHTING_UNITY_INCLUDED #define VRMC_MATERIALS_MTOON_LIGHTING_UNITY_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #include #include #endif + #include "./vrmc_materials_mtoon_define.hlsl" #include "./vrmc_materials_mtoon_input.hlsl" #include "./vrmc_materials_mtoon_attribute.hlsl" diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl index e59f7ff79..fec4d535d 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_utility.hlsl @@ -1,7 +1,9 @@ #ifndef VRMC_MATERIALS_MTOON_UTILITY_INCLUDED #define VRMC_MATERIALS_MTOON_UTILITY_INCLUDED -#ifndef MTOON_URP +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#else #include #endif From da6e4bfda2ed52ee5183522e32e7dfe2efd9e376 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 11:24:26 +0900 Subject: [PATCH 05/35] =?UTF-8?q?UNITY=5FDECLARE=5FTEX2D=E3=82=92=E5=9B=9E?= =?UTF-8?q?=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_input.hlsl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl index 32a3801fa..f2bed97f5 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl @@ -8,16 +8,16 @@ #endif // Textures -UNITY_DECLARE_TEX2D(_MainTex); -UNITY_DECLARE_TEX2D(_ShadeTex); -UNITY_DECLARE_TEX2D(_BumpMap); -UNITY_DECLARE_TEX2D(_ShadingShiftTex); -UNITY_DECLARE_TEX2D(_EmissionMap); -UNITY_DECLARE_TEX2D(_MatcapTex); -UNITY_DECLARE_TEX2D(_RimTex); -UNITY_DECLARE_TEX2D(_OutlineWidthTex); +TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex); +TEXTURE2D(_ShadeTex); SAMPLER(sampler_ShadeTex); +TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap); +TEXTURE2D(_ShadingShiftTex); SAMPLER(sampler_ShadingShiftTex); +TEXTURE2D(_EmissionMap); SAMPLER(sampler_EmissionMap); +TEXTURE2D(_MatcapTex); SAMPLER(sampler_MatcapTex); +TEXTURE2D(_RimTex); SAMPLER(sampler_RimTex); +TEXTURE2D(_OutlineWidthTex); SAMPLER(sampler_OutlineWidthTex); // NOTE: "tex2d() * _Time.y" returns mediump value if sampler is half precision in Android VR platform -UNITY_DECLARE_TEX2D_FLOAT(_UvAnimMaskTex); +TEXTURE2D_FLOAT(_UvAnimMaskTex); SAMPLER(sampler_UvAnimMaskTex); CBUFFER_START(UnityPerMaterial) // Vector From 31e57de03bf055c5379192eca1e14167d33979c6 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 11:32:11 +0900 Subject: [PATCH 06/35] =?UTF-8?q?=E6=95=B0=E3=82=AB=E6=89=80=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=83=91=E3=82=A4=E3=83=AB=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_attribute.hlsl | 6 ++++++ .../VRM10/vrmc_materials_mtoon_define.hlsl | 6 +++++- .../Resources/VRM10/vrmc_materials_mtoon_input.hlsl | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl index 7d9a926a3..ca16186de 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl @@ -29,8 +29,14 @@ struct Varyings half4 tangentWS : TEXCOORD3; #endif float3 viewDirWS : TEXCOORD4; + + #ifdef MTOON_URP + half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light + #else UNITY_FOG_COORDS(5) UNITY_LIGHTING_COORDS(6,7) + #endif + float4 pos : SV_POSITION; // UnityCG macro specified name. Accurately "positionCS" UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl index 909079822..6eeefca25 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl @@ -12,7 +12,11 @@ #endif #ifndef MTOON_FRONT_FACE_TYPE // from https://docs.unity3d.com/Manual/SL-ShaderSemantics.html - #define MTOON_FRONT_FACE_TYPE fixed + #ifdef MTOON_URP + #define MTOON_FRONT_FACE_TYPE float + #else + #define MTOON_FRONT_FACE_TYPE fixed + #endif #endif #ifndef MTOON_IS_FRONT_VFACE #define MTOON_IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL > 0.0) ? (FRONT) : (BACK)) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl index f2bed97f5..1dcaa64d4 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_input.hlsl @@ -8,6 +8,7 @@ #endif // Textures +#ifdef MTOON_URP TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex); TEXTURE2D(_ShadeTex); SAMPLER(sampler_ShadeTex); TEXTURE2D(_BumpMap); SAMPLER(sampler_BumpMap); @@ -18,6 +19,18 @@ TEXTURE2D(_RimTex); SAMPLER(sampler_RimTex); TEXTURE2D(_OutlineWidthTex); SAMPLER(sampler_OutlineWidthTex); // NOTE: "tex2d() * _Time.y" returns mediump value if sampler is half precision in Android VR platform TEXTURE2D_FLOAT(_UvAnimMaskTex); SAMPLER(sampler_UvAnimMaskTex); +#else +UNITY_DECLARE_TEX2D(_MainTex); +UNITY_DECLARE_TEX2D(_ShadeTex); +UNITY_DECLARE_TEX2D(_BumpMap); +UNITY_DECLARE_TEX2D(_ShadingShiftTex); +UNITY_DECLARE_TEX2D(_EmissionMap); +UNITY_DECLARE_TEX2D(_MatcapTex); +UNITY_DECLARE_TEX2D(_RimTex); +UNITY_DECLARE_TEX2D(_OutlineWidthTex); +// NOTE: "tex2d() * _Time.y" returns mediump value if sampler is half precision in Android VR platform +UNITY_DECLARE_TEX2D_FLOAT(_UvAnimMaskTex); +#endif CBUFFER_START(UnityPerMaterial) // Vector From cc691f24bcd2db7f828699f5bed13d643559be13 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 13:10:53 +0900 Subject: [PATCH 07/35] =?UTF-8?q?Transform=E3=82=92URP=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vrmc_materials_mtoon_forward_vertex.hlsl | 10 +++++ .../vrmc_materials_mtoon_geometry_vertex.hlsl | 38 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index 316e9b562..17c2984ad 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -29,14 +29,24 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. const VertexPositionInfo position = MToon_GetOutlineVertex(v.vertex.xyz, normalize(v.normalOS), output.uv); output.pos = position.positionCS; output.positionWS = position.positionWS; + + #ifdef MTOON_URP + output.normalWS = TransformObjectToWorldNormal(-v.normalOS); + #else output.normalWS = UnityObjectToWorldNormal(-v.normalOS); + #endif } else { const VertexPositionInfo position = MToon_GetVertex(v.vertex.xyz); output.pos = position.positionCS; output.positionWS = position.positionWS; + + #ifdef MTOON_URP + output.normalWS = TransformObjectToWorldNormal(v.normalOS); + #else output.normalWS = UnityObjectToWorldNormal(v.normalOS); + #endif } output.viewDirWS = MToon_GetWorldSpaceNormalizedViewDir(output.positionWS); diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl index 032ba2d42..0e8210fed 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl @@ -2,6 +2,7 @@ #define VRMC_MATERIALS_MTOON_GEOMETRY_VERTEX_INCLUDED #ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Input.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #else #include @@ -54,12 +55,25 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const if (MToon_IsOutlineModeWorldCoordinates()) { const float3 positionWS = mul(unity_ObjectToWorld, float4(positionOS, 1)).xyz; + + #ifdef MTOON_URP + const half3 normalWS = TransformObjectToWorldNormal(normalOS); + #else const half3 normalWS = UnityObjectToWorldNormal(normalOS); + #endif + const half outlineWidth = MToon_GetOutlineVertex_OutlineWidth(uv); VertexPositionInfo output; output.positionWS = float4(positionWS + normalWS * outlineWidth, 1); + + #ifdef MTOON_URP + output.positionCS = TransformWorldToHClip(output.positionWS); + #else output.positionCS = UnityWorldToClipPos(output.positionWS); + #endif + + return output; } else if (MToon_IsOutlineModeScreenCoordinates()) @@ -70,9 +84,20 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const const float4 nearUpperRight = mul(unity_CameraInvProjection, float4(1, 1, UNITY_NEAR_CLIP_VALUE, _ProjectionParams.y)); const half aspect = abs(nearUpperRight.y / nearUpperRight.x); + #ifdef MTOON_URP + const float4 positionCS = TransformObjectToHClip(positionOS); + #else const float4 positionCS = UnityObjectToClipPos(positionOS); + #endif + const half3 normalVS = MToon_GetObjectToViewNormal(normalOS); + + #ifdef MTOON_URP + const half3 normalWS = TransformObjectToWorldNormal(normalOS.xyz); + const half3 normalCS = TransformWorldToHClipDir(normalWS.xyz); + #else const half3 normalCS = TransformViewToProjection(normalVS.xyz); + #endif half2 normalProjectedCS = normalize(normalCS.xy); const float clipSpaceHeight = 2.0f; @@ -90,7 +115,13 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const { VertexPositionInfo output; output.positionWS = mul(unity_ObjectToWorld, float4(positionOS * 0.001, 1)); + + #ifdef MTOON_URP + output.positionCS = TransformWorldToHClip(output.positionWS); + #else output.positionCS = UnityWorldToClipPos(output.positionWS); + #endif + return output; } } @@ -99,7 +130,14 @@ inline VertexPositionInfo MToon_GetVertex(const float3 positionOS) { VertexPositionInfo output; output.positionWS = mul(unity_ObjectToWorld, float4(positionOS, 1)); + + #ifdef MTOON_URP + output.positionCS = TransformWorldToHClip(output.positionWS); + #else output.positionCS = UnityWorldToClipPos(output.positionWS); + #endif + + return output; } From 9c7e357f50fda9d7bec2ce9bc3772d1c77530748 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 14:26:31 +0900 Subject: [PATCH 08/35] =?UTF-8?q?fogFactorAndVertexLight=E3=81=AE=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index 17c2984ad..2420d9971 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -3,6 +3,7 @@ #ifdef MTOON_URP #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #else #include #include @@ -56,8 +57,14 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. output.tangentWS = half4(UnityObjectToWorldDir(v.tangentOS), tangentSign); #endif + #ifdef MTOON_URP + half3 vertexLight = VertexLighting(output.positionWS, output.normalWS); + half fogFactor = ComputeFogFactor(output.pos.z); + output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); + #else UNITY_TRANSFER_FOG(output, output.pos); UNITY_TRANSFER_LIGHTING(output, v.texcoord1.xy); + #endif return output; } From 89431f6451ac06456c7339262c04ec2490adabf9 Mon Sep 17 00:00:00 2001 From: notargs Date: Tue, 25 Apr 2023 15:29:42 +0900 Subject: [PATCH 09/35] =?UTF-8?q?Texture=20access=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl index 7864a5c1f..df1c43e30 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl @@ -15,7 +15,11 @@ inline float GetMToonGeometry_Uv_Time(const float2 uvRaw) { if (MToon_IsParameterMapOn()) { + #ifdef MTOON_URP + SAMPLE_TEXTURE2D(_UvAnimMaskTex, sampler_UvAnimMaskTex, uvRaw); + #else return UNITY_SAMPLE_TEX2D(_UvAnimMaskTex, uvRaw).b * _Time.y; + #endif } else { From 0f0c8bba9439e6bab832f5dcd756f2d2f97be4b4 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 11:07:27 +0900 Subject: [PATCH 10/35] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=88=E3=81=AE?= =?UTF-8?q?=E5=8F=96=E5=BE=97=E3=82=92URP=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_attribute.hlsl | 13 +++++++--- .../vrmc_materials_mtoon_forward_vertex.hlsl | 16 +++++++++--- .../vrmc_materials_mtoon_lighting_unity.hlsl | 26 +++++++++++++++++++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl index ca16186de..564cafca8 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_attribute.hlsl @@ -30,12 +30,19 @@ struct Varyings #endif float3 viewDirWS : TEXCOORD4; - #ifdef MTOON_URP +#ifdef MTOON_URP half4 fogFactorAndVertexLight : TEXCOORD5; // x: fogFactor, yzw: vertex light - #else + + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + float4 shadowCoord : TEXCOORD6; + #endif + + DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 7); + +#else UNITY_FOG_COORDS(5) UNITY_LIGHTING_COORDS(6,7) - #endif +#endif float4 pos : SV_POSITION; // UnityCG macro specified name. Accurately "positionCS" UNITY_VERTEX_INPUT_INSTANCE_ID diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index 2420d9971..3419a1113 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -57,14 +57,24 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. output.tangentWS = half4(UnityObjectToWorldDir(v.tangentOS), tangentSign); #endif - #ifdef MTOON_URP +#ifdef MTOON_URP + VertexPositionInputs vertexInput = GetVertexPositionInputs(v.vertex.xyz); + + OUTPUT_LIGHTMAP_UV(input.texcoord1, unity_LightmapST, output.lightmapUV); + OUTPUT_SH(output.normalWS.xyz, output.vertexSH); + half3 vertexLight = VertexLighting(output.positionWS, output.normalWS); half fogFactor = ComputeFogFactor(output.pos.z); output.fogFactorAndVertexLight = half4(fogFactor, vertexLight); - #else + + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + output.shadowCoord = GetShadowCoord(vertexInput); + #endif + +#else UNITY_TRANSFER_FOG(output, output.pos); UNITY_TRANSFER_LIGHTING(output, v.texcoord1.xy); - #endif +#endif return output; } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index 9d3e8c9eb..b2cae2c93 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -3,6 +3,7 @@ #ifdef MTOON_URP #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #else #include #include @@ -24,16 +25,41 @@ struct UnityLighting UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS) { +#ifdef MTOON_URP + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + float4 shadowCoord = input.shadowCoord; + #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) + float4 shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); + #else + float4 shadowCoord = float4(0, 0, 0, 0); + #endif + + float shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); + Light mainLight = GetMainLight(shadowCoord, input.positionWS, shadowMask); + + const half3 lightDir = mainLight.direction; + const half3 lightColor = mainLight.color.rgb; + + float atten = mainLight.shadowAttenuation; + +#else UNITY_LIGHT_ATTENUATION(atten, input, input.positionWS); const half3 lightDir = normalize(UnityWorldSpaceLightDir(input.positionWS)); const half3 lightColor = _LightColor0.rgb; +#endif + if (MToon_IsForwardBasePass()) { UnityLighting output; +#ifdef MTOON_URP + output.indirectLight = SampleSH(normalWS); + output.indirectLightEqualized = (SampleSH(half3(0, 1, 0)) + SampleSH(half3(0, -1, 0))) * 0.5; +#else output.indirectLight = ShadeSH9(half4(normalWS, 1)); output.indirectLightEqualized = (ShadeSH9(half4(0, 1, 0, 1)) + ShadeSH9(half4(0, -1, 0, 1))) * 0.5; +#endif output.directLightColor = lightColor; output.directLightDirection = lightDir; output.directLightAttenuation = atten; From 613b2c7a62ba4b3291ea32bbcca5cd6a5c6b4c24 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 13:57:12 +0900 Subject: [PATCH 11/35] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=91=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E9=80=9A=E3=82=8B=E7=8A=B6=E6=85=8B=E3=81=AB?= =?UTF-8?q?=E3=81=BE=E3=81=A7=E6=8C=81=E3=81=A3=E3=81=A6=E3=81=84=E3=81=A3?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...vrmc_materials_mtoon_forward_fragment.hlsl | 9 ++++++++ .../vrmc_materials_mtoon_lighting_mtoon.hlsl | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 3198ba4b7..639874e0d 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -31,7 +31,11 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target const float2 uv = GetMToonGeometry_Uv(input.uv); // Get LitColor with Alpha + #ifdef MTOON_URP + const half4 litColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv) * _Color; + #else const half4 litColor = UNITY_SAMPLE_TEX2D(_MainTex, uv) * _Color; + #endif // Alpha Test const half alpha = GetMToonGeometry_Alpha(litColor); @@ -52,7 +56,12 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target half4 col = GetMToonLighting(unityLighting, mtoonInput); // Apply Fog + #ifdef MTOON_URP + float fogCoord = input.fogFactorAndVertexLight.x; + col.rgb = MixFog(col.rgb, fogCoord); + #else UNITY_APPLY_FOG(fragmentInput.varyings.fogCoord, col); + #endif return col; } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index 6b6559236..11a5053a8 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -25,7 +25,11 @@ inline half GetMToonLighting_Reflectance_ShadingShift(const MToonInput input) { if (MToon_IsParameterMapOn()) { + #ifdef MTOON_URP + return SAMPLE_TEXTURE2D(_ShadingShiftTex, sampler_ShadingShiftTex, input.uv).r * _ShadingShiftTexScale + _ShadingShiftFactor; + #else return UNITY_SAMPLE_TEX2D(_ShadingShiftTex, input.uv).r * _ShadingShiftTexScale + _ShadingShiftFactor; + #endif } else { @@ -83,7 +87,11 @@ inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dot inline half3 GetMToonLighting_DirectLighting(const UnityLighting unityLight, const MToonInput input, const half shade, const half shadow) { + #ifdef MTOON_URP + const half3 shadeColor = SAMPLE_TEXTURE2D(_ShadeTex, sampler_ShadeTex, input.uv).rgb * _ShadeColor.rgb; + #else const half3 shadeColor = UNITY_SAMPLE_TEX2D(_ShadeTex, input.uv).rgb * _ShadeColor.rgb; + #endif const half3 albedo = lerp(shadeColor, input.litColor, shade); return albedo * unityLight.directLightColor * shadow; @@ -107,7 +115,11 @@ inline half3 GetMToonLighting_Emissive(const MToonInput input) { if (MToon_IsEmissiveMapOn()) { + #ifdef MTOON_URP + return SAMPLE_TEXTURE2D(_EmissionMap, sampler_EmissionMap, input.uv).rgb * _EmissionColor.rgb; + #else return UNITY_SAMPLE_TEX2D(_EmissionMap, input.uv).rgb * _EmissionColor.rgb; + #endif } else { @@ -129,7 +141,12 @@ 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; + + #ifdef MTOON_URP + return _MatcapColor.rgb * SAMPLE_TEXTURE2D(_MatcapTex, sampler_MatcapTex, matcapUv).rgb; + #else return _MatcapColor.rgb * UNITY_SAMPLE_TEX2D(_MatcapTex, matcapUv).rgb; + #endif } else { @@ -157,7 +174,11 @@ inline half3 GetMToonLighting_Rim(const UnityLighting unityLight, const MToonInp if (MToon_IsRimMapOn()) { + #ifdef MTOON_URP + return (matcapFactor + parametricRimFactor) * rimLightingFactor * SAMPLE_TEXTURE2D(_RimTex, sampler_RimTex, input.uv).rgb; + #else return (matcapFactor + parametricRimFactor) * rimLightingFactor * UNITY_SAMPLE_TEX2D(_RimTex, input.uv).rgb; + #endif } else { From d7e9d92d0501a84de103fdfd0c938f53e11c3e6e Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 14:57:22 +0900 Subject: [PATCH 12/35] =?UTF-8?q?=E8=AD=A6=E5=91=8A=E3=82=92=E6=BD=B0?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 4 ++-- .../VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl | 8 ++++---- .../VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl | 6 +++--- .../VRM10/vrmc_materials_mtoon_lighting_unity.hlsl | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index 3419a1113..5cb9fa706 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -29,7 +29,7 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. { const VertexPositionInfo position = MToon_GetOutlineVertex(v.vertex.xyz, normalize(v.normalOS), output.uv); output.pos = position.positionCS; - output.positionWS = position.positionWS; + output.positionWS = position.positionWS.xyz; #ifdef MTOON_URP output.normalWS = TransformObjectToWorldNormal(-v.normalOS); @@ -41,7 +41,7 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. { const VertexPositionInfo position = MToon_GetVertex(v.vertex.xyz); output.pos = position.positionCS; - output.positionWS = position.positionWS; + output.positionWS = position.positionWS.xyz; #ifdef MTOON_URP output.normalWS = TransformObjectToWorldNormal(v.normalOS); diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl index 0e8210fed..b6853a52a 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_vertex.hlsl @@ -22,7 +22,7 @@ inline half MToon_GetOutlineVertex_OutlineWidth(const float2 uv) { if (MToon_IsParameterMapOn()) { - return _OutlineWidth * UNITY_SAMPLE_TEX2D_LOD(_OutlineWidthTex, uv, 0); + return _OutlineWidth * UNITY_SAMPLE_TEX2D_LOD(_OutlineWidthTex, uv, 0).x; } else { @@ -68,7 +68,7 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const output.positionWS = float4(positionWS + normalWS * outlineWidth, 1); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif @@ -117,7 +117,7 @@ inline VertexPositionInfo MToon_GetOutlineVertex(const float3 positionOS, const output.positionWS = mul(unity_ObjectToWorld, float4(positionOS * 0.001, 1)); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif @@ -132,7 +132,7 @@ inline VertexPositionInfo MToon_GetVertex(const float3 positionOS) output.positionWS = mul(unity_ObjectToWorld, float4(positionOS, 1)); #ifdef MTOON_URP - output.positionCS = TransformWorldToHClip(output.positionWS); + output.positionCS = TransformWorldToHClip(output.positionWS.xyz); #else output.positionCS = UnityWorldToClipPos(output.positionWS); #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index 11a5053a8..d60367a02 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -56,7 +56,7 @@ inline half GetMToonLighting_Shade(const UnityLighting lighting, const MToonInpu if (MToon_IsForwardBasePass()) { const half shadeInput = lerp(-1, 1, mtoon_linearstep(-1, 1, dotNL)); - return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift) * lighting.directLightAttenuation; + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift) * lighting.directLightAttenuation.x; } else { @@ -69,7 +69,7 @@ inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dot { if (MToon_IsPbrCorrectOn()) { - return lighting.directLightAttenuation * step(0, dotNL); + return lighting.directLightAttenuation.x * step(0, dotNL); } if (MToon_IsForwardBasePass()) @@ -81,7 +81,7 @@ inline half GetMToonLighting_Shadow(const UnityLighting lighting, const half dot // heuristic term for weak lights. // 0.5: heuristic. // min(0, dotNL) + 1: darken if (dotNL < 0) by using half lambert. - return lighting.directLightAttenuation * 0.5 * (min(0, dotNL) + 1); + return lighting.directLightAttenuation.x * 0.5 * (min(0, dotNL) + 1); } } diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index b2cae2c93..e1607b3d7 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -34,7 +34,7 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS) float4 shadowCoord = float4(0, 0, 0, 0); #endif - float shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); + half4 shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); Light mainLight = GetMainLight(shadowCoord, input.positionWS, shadowMask); const half3 lightDir = mainLight.direction; From bb414ec8980cf7eca439aee41f033a8cd0ac8f91 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 15:18:03 +0900 Subject: [PATCH 13/35] =?UTF-8?q?=E9=96=93=E6=8E=A5=E5=85=89=E3=81=8C?= =?UTF-8?q?=E4=B9=97=E3=82=89=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl index 6eeefca25..50d915bb0 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_define.hlsl @@ -32,7 +32,9 @@ inline bool MToon_IsPbrCorrectOn() // Compile-time constant inline bool MToon_IsForwardBasePass() { -#if defined(UNITY_PASS_FORWARDBASE) +#if defined(MTOON_URP) + return true; +#elif defined(UNITY_PASS_FORWARDBASE) return true; #elif defined(UNITY_PASS_FORWARDADD) return false; From 428eed2c923acef6b540a419c8915b34c99be8f6 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 15:54:56 +0900 Subject: [PATCH 14/35] =?UTF-8?q?Shadow=E3=81=8C=E8=90=BD=E3=81=A1?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_lighting_unity.hlsl | 2 +- .../Resources/VRM10/vrmc_materials_mtoon_urp.shader | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index e1607b3d7..8e30886cd 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -29,7 +29,7 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS) #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) float4 shadowCoord = input.shadowCoord; #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) - float4 shadowCoord = TransformWorldToShadowCoord(inputData.positionWS); + float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); #else float4 shadowCoord = float4(0, 0, 0, 0); #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 639d3e4bf..9d3f9b81e 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -96,6 +96,17 @@ Shader "VRM10/MToon10_URP" #pragma multi_compile __ _MTOON_RIMMAP #pragma multi_compile __ _MTOON_PARAMETERMAP + // ------------------------------------- + // Universal Pipeline keywords + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS + #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE + #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS + #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS + #pragma multi_compile_fragment _ _SHADOWS_SOFT + #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING + #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION + #pragma vertex MToonVertex #pragma fragment MToonFragment From 69ee1f88541032f747b5c90cb916ea667bde87ab Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:13:54 +0900 Subject: [PATCH 15/35] =?UTF-8?q?ShadowCaster=E3=81=AE=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_urp.shader | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 9d3f9b81e..151628595 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -121,30 +121,30 @@ Shader "VRM10/MToon10_URP" Pass { Name "ShadowCaster" - Tags { "LightMode" = "ShadowCaster" } + Tags{"LightMode" = "ShadowCaster"} Cull [_M_CullMode] ZWrite On ZTest LEqual - CGPROGRAM + HLSLPROGRAM #pragma target 3.0 - // Unity defined keywords - #pragma multi_compile_shadowcaster nolightmap nodynlightmap nodirlightmap novertexlight + //-------------------------------------- + // GPU Instancing #pragma multi_compile_instancing - #pragma multi_compile __ _ALPHATEST_ON _ALPHABLEND_ON + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A - // Use unity standard shadow implementation. - // internal usage: - // keywords: _ALPHATEST_ON _ALPHABLEND_ON - // variables: _MainTex.a _Color.a _Cutoff - #pragma vertex vertShadowCaster - #pragma fragment fragShadowCaster + #pragma vertex ShadowPassVertex + #pragma fragment ShadowPassFragment - #include "UnityStandardShadow.cginc" - ENDCG + #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + ENDHLSL } } Fallback "Unlit/Texture" From 963775dfc1dd597f5e6e30cf5878ba41e93744d6 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:15:02 +0900 Subject: [PATCH 16/35] =?UTF-8?q?material=20keyword=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 151628595..9e96b68d1 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -137,7 +137,6 @@ Shader "VRM10/MToon10_URP" // ------------------------------------- // Material Keywords #pragma shader_feature_local_fragment _ALPHATEST_ON - #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A #pragma vertex ShadowPassVertex #pragma fragment ShadowPassFragment From d756e3487d17c20ecb84e5a2dcb5c31f10794438 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:24:23 +0900 Subject: [PATCH 17/35] =?UTF-8?q?MToon=20URP=E3=81=AE=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IO/Material/URP/Import/Materials.meta | 8 +++ .../UrpVrm10MToonMaterialImporter.cs | 49 +++++++++++++++++++ .../UrpVrm10MToonMaterialImporter.cs.meta | 3 ++ 3 files changed, 60 insertions(+) create mode 100644 Assets/VRM10/Runtime/IO/Material/URP/Import/Materials.meta create mode 100644 Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs create mode 100644 Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs.meta diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials.meta b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials.meta new file mode 100644 index 000000000..2c542f476 --- /dev/null +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1987bdfe8c2df174abb9cf04caaaba15 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs new file mode 100644 index 000000000..fae01b5b5 --- /dev/null +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs @@ -0,0 +1,49 @@ +using System; +using System.Linq; +using UniGLTF; +using UnityEngine; +using VRMShaders; +using VRMShaders.VRM10.MToon10.Runtime; + +namespace UniVRM10 +{ + /// + /// Convert MToon parameters from glTF specification to Unity implementation. + /// + public static class UrpVrm10MToonMaterialImporter + { + /// + /// VMRC_materials_mtoon の場合にマテリアル生成情報を作成する + /// + public static bool TryCreateParam(GltfData data, int i, out MaterialDescriptor matDesc) + { + var m = data.GLTF.materials[i]; + if (!UniGLTF.Extensions.VRMC_materials_mtoon.GltfDeserializer.TryGet(m.extensions, out var mtoon)) + { + // Fallback to glTF, when MToon extension does not exist. + matDesc = default; + return false; + } + + // use material.name, because material name may renamed in GltfParser. + matDesc = new MaterialDescriptor( + m.name, + Shader.Find(MToon10Meta.URPUnityShaderName), + null, + Vrm10MToonTextureImporter.EnumerateAllTextures(data, m, mtoon).ToDictionary(tuple => tuple.key, tuple => tuple.Item2.Item2), + BuiltInVrm10MToonMaterialImporter.TryGetAllFloats(m, mtoon).ToDictionary(tuple => tuple.key, tuple => tuple.value), + BuiltInVrm10MToonMaterialImporter.TryGetAllColors(m, mtoon).ToDictionary(tuple => tuple.key, tuple => tuple.value), + BuiltInVrm10MToonMaterialImporter.TryGetAllFloatArrays(m, mtoon).ToDictionary(tuple => tuple.key, tuple => tuple.value), + new Action[] + { + material => + { + // Set hidden properties, keywords from float properties. + new MToonValidator(material).Validate(); + } + }); + + return true; + } + } +} diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs.meta b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs.meta new file mode 100644 index 000000000..0714adc64 --- /dev/null +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 57d820ccc1ff7e2469f7fb5cc435bd5b +timeCreated: 1620630516 \ No newline at end of file From 18f7d8dedb1f03526e602cf50562e9e7c1c527e9 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:38:11 +0900 Subject: [PATCH 18/35] =?UTF-8?q?=E3=82=B7=E3=83=BC=E3=83=89=E3=81=95?= =?UTF-8?q?=E3=82=93=E3=81=8C=E6=AD=A3=E5=B8=B8=E3=81=AB=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E8=BE=BC=E3=82=81=E3=81=AA=E3=81=84=E3=83=90=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM10/vrmc_materials_mtoon_forward_vertex.hlsl | 6 ++++++ .../VRM10/vrmc_materials_mtoon_geometry_normal.hlsl | 6 ++++++ .../Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl | 2 +- .../Runtime/UnityShaderLab/Properties/MToon10Meta.cs | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl index 5cb9fa706..62a60f3c0 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_vertex.hlsl @@ -54,7 +54,13 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name. #if defined(_NORMALMAP) const half tangentSign = v.tangentOS.w * unity_WorldTransformParams.w; + + #ifdef MTOON_URP + output.tangentWS = half4(TransformObjectToWorldDir(v.tangentOS), tangentSign); + #else output.tangentWS = half4(UnityObjectToWorldDir(v.tangentOS), tangentSign); + #endif + #endif #ifdef MTOON_URP diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl index 075c13b8a..160c45206 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_normal.hlsl @@ -21,8 +21,14 @@ inline float3 GetMToonGeometry_Normal(const Varyings input, const MTOON_FRONT_FA const half3 normalWS = MTOON_IS_FRONT_VFACE(facing, input.normalWS, -input.normalWS); #if defined(_NORMALMAP) + // Get Normal in WorldSpace from Normalmap if available + #ifdef MTOON_URP + const half3 normalTS = normalize(UnpackNormalScale(SAMPLE_TEXTURE2D(_BumpMap, sampler_MainTex, mtoonUv), _BumpScale)); + #else const half3 normalTS = normalize(UnpackNormalWithScale(UNITY_SAMPLE_TEX2D(_BumpMap, mtoonUv), _BumpScale)); + #endif + return normalize(mul(normalTS, MToon_GetTangentToWorld(normalWS, input.tangentWS))); #else return GetMToonGeometry_NormalWithoutNormalMap(normalWS); diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl index df1c43e30..21d79d3fc 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_geometry_uv.hlsl @@ -16,7 +16,7 @@ inline float GetMToonGeometry_Uv_Time(const float2 uvRaw) if (MToon_IsParameterMapOn()) { #ifdef MTOON_URP - SAMPLE_TEXTURE2D(_UvAnimMaskTex, sampler_UvAnimMaskTex, uvRaw); + return SAMPLE_TEXTURE2D(_UvAnimMaskTex, sampler_UvAnimMaskTex, uvRaw); #else return UNITY_SAMPLE_TEX2D(_UvAnimMaskTex, uvRaw).b * _Time.y; #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs index 8141abb90..de76587b8 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs @@ -3,5 +3,6 @@ public static class MToon10Meta { public static readonly string UnityShaderName = "VRM10/MToon10"; + public static readonly string URPUnityShaderName = "VRM10/MToon10_URP"; } } \ No newline at end of file From 6cdfc7fe86dc6c6f640f17772d3b6d0010b793ad Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:38:24 +0900 Subject: [PATCH 19/35] =?UTF-8?q?UrpVrm10MaterialDescriptorGenerator?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../URP/Import/UrpVrm10MaterialDescriptorGenerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/UrpVrm10MaterialDescriptorGenerator.cs b/Assets/VRM10/Runtime/IO/Material/URP/Import/UrpVrm10MaterialDescriptorGenerator.cs index 8cba77b28..d389d3117 100644 --- a/Assets/VRM10/Runtime/IO/Material/URP/Import/UrpVrm10MaterialDescriptorGenerator.cs +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/UrpVrm10MaterialDescriptorGenerator.cs @@ -10,8 +10,10 @@ namespace UniVRM10 { public MaterialDescriptor Get(GltfData data, int i) { + // mtoon + if (UrpVrm10MToonMaterialImporter.TryCreateParam(data, i, out var matDesc)) return matDesc; // unlit - if (BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out MaterialDescriptor matDesc)) return matDesc; + if (BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out matDesc)) return matDesc; // pbr if (UrpGltfPbrMaterialImporter.TryCreateParam(data, i, out matDesc)) return matDesc; From 449cdf29df76041215e7165e5f7161953858464b Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:41:04 +0900 Subject: [PATCH 20/35] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs index fae01b5b5..1a690e060 100644 --- a/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/URP/Import/Materials/UrpVrm10MToonMaterialImporter.cs @@ -8,7 +8,7 @@ using VRMShaders.VRM10.MToon10.Runtime; namespace UniVRM10 { /// - /// Convert MToon parameters from glTF specification to Unity implementation. + /// Convert MToon parameters from glTF specification to Unity implementation.(for URP) /// public static class UrpVrm10MToonMaterialImporter { From 2fde31bc6f87552236b517f110237e3e2ae11dfe Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:42:12 +0900 Subject: [PATCH 21/35] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10_Samples/URPSample/Materials.meta | 8 - .../URPSample/Materials/URPMToon10.mat | 175 ------------------ .../URPSample/Materials/URPMToon10.mat.meta | 8 - 3 files changed, 191 deletions(-) delete mode 100644 Assets/VRM10_Samples/URPSample/Materials.meta delete mode 100644 Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat delete mode 100644 Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta diff --git a/Assets/VRM10_Samples/URPSample/Materials.meta b/Assets/VRM10_Samples/URPSample/Materials.meta deleted file mode 100644 index c535ae03a..000000000 --- a/Assets/VRM10_Samples/URPSample/Materials.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 282c8c12552fd4c42840a5dda6ae2c9b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat deleted file mode 100644 index 58af27684..000000000 --- a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat +++ /dev/null @@ -1,175 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!114 &-9194869756555787169 -MonoBehaviour: - m_ObjectHideFlags: 11 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} - m_Name: - m_EditorClassIdentifier: - version: 4 ---- !u!21 &2100000 -Material: - serializedVersion: 6 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: URPMToon10 - m_Shader: {fileID: 4800000, guid: 0781c64b7f2a1604ea6aa7e252080372, type: 3} - m_ShaderKeywords: - m_LightmapFlags: 4 - m_EnableInstancingVariants: 0 - m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} - disabledShaderPasses: [] - m_SavedProperties: - serializedVersion: 3 - m_TexEnvs: - - _BaseMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _BumpMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailAlbedoMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailMask: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _DetailNormalMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _EmissionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MainTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MatcapTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _MetallicGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OcclusionMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _OutlineWidthTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ParallaxMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _RimTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ShadeTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _ShadingShiftTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _SpecGlossMap: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - _UvAnimMaskTex: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - unity_Lightmaps: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - unity_LightmapsInd: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - - unity_ShadowMasks: - m_Texture: {fileID: 0} - m_Scale: {x: 1, y: 1} - m_Offset: {x: 0, y: 0} - m_Floats: - - _AlphaClip: 0 - - _AlphaMode: 0 - - _Blend: 0 - - _BumpScale: 1 - - _ClearCoatMask: 0 - - _ClearCoatSmoothness: 0 - - _Cull: 2 - - _Cutoff: 0.5 - - _DetailAlbedoMapScale: 1 - - _DetailNormalMapScale: 1 - - _DoubleSided: 0 - - _DstBlend: 0 - - _EnvironmentReflections: 1 - - _GiEqualization: 0.9 - - _GlossMapScale: 0 - - _Glossiness: 0 - - _GlossyReflections: 0 - - _M_AlphaToMask: 0 - - _M_CullMode: 2 - - _M_DebugMode: 0 - - _M_DstBlend: 0 - - _M_EditMode: 0 - - _M_SrcBlend: 1 - - _M_ZWrite: 1 - - _Metallic: 0 - - _OcclusionStrength: 1 - - _OutlineLightingMix: 1 - - _OutlineWidth: 0 - - _OutlineWidthMode: 0 - - _Parallax: 0.005 - - _QueueOffset: 0 - - _ReceiveShadows: 1 - - _RenderQueueOffset: 0 - - _RimFresnelPower: 5 - - _RimLift: 0 - - _RimLightingMix: 1 - - _ShadingShiftFactor: -0.05 - - _ShadingShiftTexScale: 1 - - _ShadingToonyFactor: 0.95 - - _Smoothness: 0.5 - - _SmoothnessTextureChannel: 0 - - _SpecularHighlights: 1 - - _SrcBlend: 1 - - _Surface: 0 - - _TransparentWithZWrite: 0 - - _UvAnimRotationSpeed: 0 - - _UvAnimScrollXSpeed: 0 - - _UvAnimScrollYSpeed: 0 - - _WorkflowMode: 1 - - _ZWrite: 1 - m_Colors: - - _BaseColor: {r: 1, g: 1, b: 1, a: 1} - - _Color: {r: 1, g: 1, b: 1, a: 1} - - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - - _MatcapColor: {r: 0, g: 0, b: 0, a: 1} - - _OutlineColor: {r: 0, g: 0, b: 0, a: 1} - - _RimColor: {r: 0, g: 0, b: 0, a: 1} - - _ShadeColor: {r: 1, g: 1, b: 1, a: 1} - - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} - m_BuildTextureStacks: [] diff --git a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta b/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta deleted file mode 100644 index 552edcd93..000000000 --- a/Assets/VRM10_Samples/URPSample/Materials/URPMToon10.mat.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3b3d2f142a7a89b42a3d483dacb0a2af -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 2100000 - userData: - assetBundleName: - assetBundleVariant: From 1e01559220c953c5cd00b6c69ed5ec3d0b55c1c3 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 16:50:21 +0900 Subject: [PATCH 22/35] =?UTF-8?q?pragma=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 9e96b68d1..151628595 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -137,6 +137,7 @@ Shader "VRM10/MToon10_URP" // ------------------------------------- // Material Keywords #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A #pragma vertex ShadowPassVertex #pragma fragment ShadowPassFragment From f970da6f3a60c88875bfcb68d765de00dbb2ada3 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 17:47:44 +0900 Subject: [PATCH 23/35] =?UTF-8?q?AdditionalLight=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...vrmc_materials_mtoon_forward_fragment.hlsl | 9 +++++++ .../vrmc_materials_mtoon_lighting_unity.hlsl | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 639874e0d..7685dff24 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -55,6 +55,15 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target mtoonInput.alpha = alpha; half4 col = GetMToonLighting(unityLighting, mtoonInput); + #ifdef _ADDITIONAL_LIGHTS + uint pixelLightCount = GetAdditionalLightsCount(); + for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex) + { + UnityLighting additionalUnityLighting = GetAdditionalUnityLighting(input, normalWS, lightIndex); + col.rgb += GetMToonLighting(additionalUnityLighting, mtoonInput).rgb; + } + #endif + // Apply Fog #ifdef MTOON_URP float fogCoord = input.fogFactorAndVertexLight.x; diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl index 8e30886cd..0151a8166 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_unity.hlsl @@ -77,4 +77,29 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS) } } +#ifdef MTOON_URP +UnityLighting GetAdditionalUnityLighting(const Varyings input, const half3 normalWS, int lightIndex) +{ + // TODO: Duplicate in GetUnityLighting + #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) + float4 shadowCoord = input.shadowCoord; + #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS) + float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS); + #else + float4 shadowCoord = float4(0, 0, 0, 0); + #endif + + half4 shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); + Light light = GetAdditionalLight(lightIndex, input.positionWS, shadowMask); + + UnityLighting output; + output.indirectLight = 0; + output.indirectLightEqualized = 0; + output.directLightColor = light.color; + output.directLightDirection = light.direction; + output.directLightAttenuation = light.shadowAttenuation * light.distanceAttenuation; + return output; +} +#endif + #endif From c5d3b4d613eb081b69972d035cb079a8c58e02a4 Mon Sep 17 00:00:00 2001 From: notargs Date: Wed, 26 Apr 2023 17:49:45 +0900 Subject: [PATCH 24/35] =?UTF-8?q?=E5=BF=B5=E3=81=AE=E3=81=9F=E3=82=81?= =?UTF-8?q?=E3=80=81MTOON=20URP=E3=81=A7=E5=9B=B2=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 7685dff24..8711d82f2 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -55,6 +55,7 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target mtoonInput.alpha = alpha; half4 col = GetMToonLighting(unityLighting, mtoonInput); + #ifdef MTOON_URP #ifdef _ADDITIONAL_LIGHTS uint pixelLightCount = GetAdditionalLightsCount(); for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex) @@ -63,6 +64,7 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target col.rgb += GetMToonLighting(additionalUnityLighting, mtoonInput).rgb; } #endif + #endif // Apply Fog #ifdef MTOON_URP From c9e62eb7adba25e5403b5b16b905f2f54b49c5b6 Mon Sep 17 00:00:00 2001 From: notargs Date: Thu, 27 Apr 2023 14:15:06 +0900 Subject: [PATCH 25/35] =?UTF-8?q?ShadowCaster=E3=82=92=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E5=8C=96=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...materials_mtoon_shadowcaster_fragment.hlsl | 34 ++++++++++++ ...ials_mtoon_shadowcaster_fragment.hlsl.meta | 9 ++++ ...c_materials_mtoon_shadowcaster_vertex.hlsl | 54 +++++++++++++++++++ ...erials_mtoon_shadowcaster_vertex.hlsl.meta | 9 ++++ .../VRM10/vrmc_materials_mtoon_urp.shader | 21 ++++---- 5 files changed, 116 insertions(+), 11 deletions(-) create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl create mode 100644 Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl new file mode 100644 index 000000000..e020417a3 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl @@ -0,0 +1,34 @@ +#ifndef VRMC_MATERIALS_MTOON_SHADOWCASTER_FRAGMENT_INCLUDED +#define VRMC_MATERIALS_MTOON_SHADOWCASTER_FRAGMENT_INCLUDED + +#ifdef MTOON_URP +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + +#include "./vrmc_materials_mtoon_define.hlsl" +#include "./vrmc_materials_mtoon_utility.hlsl" +#include "./vrmc_materials_mtoon_input.hlsl" +#include "./vrmc_materials_mtoon_attribute.hlsl" +#include "./vrmc_materials_mtoon_geometry_uv.hlsl" +#include "./vrmc_materials_mtoon_geometry_alpha.hlsl" +#include "./vrmc_materials_mtoon_geometry_normal.hlsl" +#include "./vrmc_materials_mtoon_lighting_unity.hlsl" +#include "./vrmc_materials_mtoon_lighting_mtoon.hlsl" + +half4 MToonShadowCasterFragment(const FragmentInput fragmentInput) : SV_Target +{ + const Varyings input = fragmentInput.varyings; + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + // Get MToon UV (with UVAnimation) + const float2 uv = GetMToonGeometry_Uv(input.uv); + + // Get LitColor with Alpha + const half4 litColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv) * _Color; + GetMToonGeometry_Alpha(litColor); + + return 0; +} + +#endif + +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta new file mode 100644 index 000000000..9b6e1469d --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_fragment.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: de3bc67bd63189846842d2a03b2b13a9 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl new file mode 100644 index 000000000..94ad32a5f --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl @@ -0,0 +1,54 @@ +#ifndef VRMC_MATERIALS_MTOON_SHADOWCASTER_VERTEX_INCLUDED +#define VRMC_MATERIALS_MTOON_SHADOWCASTER_VERTEX_INCLUDED + +#ifdef MTOON_URP + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + +#include "./vrmc_materials_mtoon_define.hlsl" +#include "./vrmc_materials_mtoon_utility.hlsl" +#include "./vrmc_materials_mtoon_input.hlsl" +#include "./vrmc_materials_mtoon_attribute.hlsl" +#include "./vrmc_materials_mtoon_geometry_vertex.hlsl" + +float3 _LightDirection; + +VertexPositionInfo MToon_GetShadowCasterVertex(const float3 positionOS, const float3 normalWS) +{ + VertexPositionInfo output; + output.positionWS = mul(unity_ObjectToWorld, float4(positionOS, 1)); + float4 positionCS = TransformWorldToHClip(ApplyShadowBias(output.positionWS, normalWS, _LightDirection)); + + #if UNITY_REVERSED_Z + positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); + #else + positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE); + #endif + + output.positionCS = positionCS; + + return output; +} + +Varyings MToonShadowCasterVertex(const Attributes v) +{ + Varyings output = (Varyings)0; + + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, output); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + float3 normalWS = TransformObjectToWorldNormal(v.normalOS); + const VertexPositionInfo position = MToon_GetShadowCasterVertex(v.vertex.xyz, normalWS); + output.pos = position.positionCS; + output.positionWS = position.positionWS.xyz; + output.normalWS = TransformObjectToWorldNormal(normalWS); + output.viewDirWS = MToon_GetWorldSpaceNormalizedViewDir(output.positionWS); + + return output; +} + +#endif + +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta new file mode 100644 index 000000000..fd4fe6a34 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_shadowcaster_vertex.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 06e9bdc3bc909534399f25d6769c8396 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 151628595..473c2456e 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -121,7 +121,7 @@ Shader "VRM10/MToon10_URP" Pass { Name "ShadowCaster" - Tags{"LightMode" = "ShadowCaster"} + Tags { "LightMode" = "ShadowCaster" } Cull [_M_CullMode] ZWrite On @@ -130,20 +130,19 @@ Shader "VRM10/MToon10_URP" HLSLPROGRAM #pragma target 3.0 - //-------------------------------------- - // GPU Instancing + // Unity defined keywords + #pragma multi_compile_shadowcaster nolightmap nodynlightmap nodirlightmap novertexlight #pragma multi_compile_instancing - // ------------------------------------- - // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON - #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma multi_compile __ _ALPHATEST_ON _ALPHABLEND_ON - #pragma vertex ShadowPassVertex - #pragma fragment ShadowPassFragment + #pragma vertex MToonShadowCasterVertex + #pragma fragment MToonShadowCasterFragment - #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" - #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl" + #define MTOON_URP + + #include "./vrmc_materials_mtoon_shadowcaster_vertex.hlsl" + #include "./vrmc_materials_mtoon_shadowcaster_fragment.hlsl" ENDHLSL } } From 35b39df95d8650fee92f778c79687d57bd489510 Mon Sep 17 00:00:00 2001 From: notargs Date: Thu, 27 Apr 2023 14:31:14 +0900 Subject: [PATCH 26/35] =?UTF-8?q?AdditionalLight=E3=81=8C=E7=A0=B4?= =?UTF-8?q?=E7=B6=BB=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...vrmc_materials_mtoon_forward_fragment.hlsl | 2 +- .../vrmc_materials_mtoon_lighting_mtoon.hlsl | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 8711d82f2..220c1ab42 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -61,7 +61,7 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex) { UnityLighting additionalUnityLighting = GetAdditionalUnityLighting(input, normalWS, lightIndex); - col.rgb += GetMToonLighting(additionalUnityLighting, mtoonInput).rgb; + col.rgb += GetMToonURPAdditionalLighting(additionalUnityLighting, mtoonInput).rgb; } #endif #endif diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl index d60367a02..24e32dbfb 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_lighting_mtoon.hlsl @@ -211,4 +211,48 @@ half4 GetMToonLighting(const UnityLighting unityLight, const MToonInput input) } } +#ifdef MTOON_URP + +inline half GetMToonURPAdditionalLighting_Shadow(const UnityLighting lighting, const half dotNL) +{ + if (MToon_IsPbrCorrectOn()) + { + return lighting.directLightAttenuation.x * step(0, dotNL); + } + + return lighting.directLightAttenuation.x * 0.5 * (min(0, dotNL) + 1); +} + +inline half GetMToonURPAdditionalLighting_Shade(const UnityLighting lighting, const MToonInput input, const half dotNL) +{ + const half shadeShift = GetMToonLighting_Reflectance_ShadingShift(input); + const half shadeToony = _ShadingToonyFactor; + + if (MToon_IsPbrCorrectOn()) + { + const half shadeInput = dotNL; + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift); + } + + const half shadeInput = dotNL; + return mtoon_linearstep(-1.0 + shadeToony, +1.0 - shadeToony, shadeInput + shadeShift); +} + +half4 GetMToonURPAdditionalLighting(const UnityLighting unityLight, const MToonInput input) +{ + const half dotNL = GetMToonLighting_DotNL(unityLight, input); + const half shade = GetMToonURPAdditionalLighting_Shade(unityLight, input, dotNL); + const half shadow = GetMToonURPAdditionalLighting_Shadow(unityLight, dotNL); + + const half3 direct = GetMToonLighting_DirectLighting(unityLight, input, shade, shadow); + const half3 lighting = direct; + + const half3 baseCol = lighting; + + return half4(baseCol, input.alpha); +} + +#endif + + #endif From ee88a56c35e6d46e8fc046ec59adab3354c51681 Mon Sep 17 00:00:00 2001 From: notargs Date: Thu, 27 Apr 2023 15:06:01 +0900 Subject: [PATCH 27/35] =?UTF-8?q?AdditionalLightShadowsSupported=E3=82=92?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../URPSample/Settings/UniversalRenderPipelineAsset.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset.asset b/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset.asset index 7d9e94149..a9311a774 100644 --- a/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset.asset +++ b/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset.asset @@ -32,7 +32,7 @@ MonoBehaviour: m_MainLightShadowmapResolution: 2048 m_AdditionalLightsRenderingMode: 1 m_AdditionalLightsPerObjectLimit: 4 - m_AdditionalLightShadowsSupported: 0 + m_AdditionalLightShadowsSupported: 1 m_AdditionalLightsShadowmapResolution: 512 m_ShadowDistance: 50 m_ShadowCascadeCount: 4 From 2dc6cd07588a8c6708754c028f10d445a25b0ef9 Mon Sep 17 00:00:00 2001 From: notargs Date: Fri, 28 Apr 2023 17:32:06 +0900 Subject: [PATCH 28/35] =?UTF-8?q?=E3=82=A2=E3=82=A6=E3=83=88=E3=83=A9?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=92=E6=8F=8F=E7=94=BB=E3=81=99=E3=82=8B?= =?UTF-8?q?=E4=BB=95=E7=B5=84=E3=81=BF=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...niversalRenderPipelineAsset_Renderer.asset | 18 +++++++- ...vrmc_materials_mtoon_forward_fragment.hlsl | 4 +- .../VRM10/vrmc_materials_mtoon_urp.shader | 40 ++++++++++++++++++ .../Runtime/MToonOutlineRenderFeature.cs | 24 +++++++++++ .../Runtime/MToonOutlineRenderFeature.cs.meta | 3 ++ .../MToon10/Runtime/MToonOutlineRenderPass.cs | 41 +++++++++++++++++++ .../Runtime/MToonOutlineRenderPass.cs.meta | 3 ++ .../VRMShaders.VRM10.MToon10.Runtime.asmdef | 14 ++++++- 8 files changed, 140 insertions(+), 7 deletions(-) create mode 100644 Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs create mode 100644 Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs.meta create mode 100644 Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs create mode 100644 Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs.meta diff --git a/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset_Renderer.asset b/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset_Renderer.asset index cd7074b5f..9c8da0435 100644 --- a/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset_Renderer.asset +++ b/Assets/VRM10_Samples/URPSample/Settings/UniversalRenderPipelineAsset_Renderer.asset @@ -12,8 +12,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3} m_Name: UniversalRenderPipelineAsset_Renderer m_EditorClassIdentifier: - m_RendererFeatures: [] - m_RendererFeatureMap: + m_RendererFeatures: + - {fileID: 6807519784255233043} + m_RendererFeatureMap: 131cfa0d2d2b795e postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} shaders: @@ -43,3 +44,16 @@ MonoBehaviour: m_ShadowTransparentReceive: 1 m_RenderingMode: 0 m_AccurateGbufferNormals: 0 +--- !u!114 &6807519784255233043 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b6d00cd3f0249a2b4ee7dc86f9a8d63, type: 3} + m_Name: MToonOutlineRenderFeature + m_EditorClassIdentifier: + m_Active: 1 diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl index 220c1ab42..74d03532d 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_forward_fragment.hlsl @@ -55,8 +55,7 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target mtoonInput.alpha = alpha; half4 col = GetMToonLighting(unityLighting, mtoonInput); - #ifdef MTOON_URP - #ifdef _ADDITIONAL_LIGHTS + #if defined(MTOON_URP) && defined(_ADDITIONAL_LIGHTS) && !defined(MTOON_PASS_OUTLINE) uint pixelLightCount = GetAdditionalLightsCount(); for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex) { @@ -64,7 +63,6 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target col.rgb += GetMToonURPAdditionalLighting(additionalUnityLighting, mtoonInput).rgb; } #endif - #endif // Apply Fog #ifdef MTOON_URP diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 473c2456e..26cf9e71a 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -117,6 +117,46 @@ Shader "VRM10/MToon10_URP" ENDHLSL } + // Built-in Forward Base Pass + Pass + { + Name "MToonOutline" + Tags { "LightMode" = "MToonOutline" } + + Cull Front + Blend [_M_SrcBlend] [_M_DstBlend] + ZWrite [_M_ZWrite] + ZTest LEqual + Offset 1, 1 + BlendOp Add, Max + AlphaToMask [_M_AlphaToMask] + + HLSLPROGRAM + #pragma target 3.0 + + // Unity defined keywords + #pragma multi_compile_fwdbase nolightmap nodynlightmap nodirlightmap novertexlight + #pragma multi_compile_fog + #pragma multi_compile_instancing + + #pragma multi_compile __ _ALPHATEST_ON _ALPHABLEND_ON + #pragma multi_compile __ _NORMALMAP + #pragma multi_compile __ _MTOON_EMISSIVEMAP + #pragma multi_compile __ _MTOON_RIMMAP + #pragma multi_compile __ _MTOON_PARAMETERMAP + #pragma multi_compile __ _MTOON_OUTLINE_WORLD _MTOON_OUTLINE_SCREEN + + #pragma vertex MToonVertex + #pragma fragment MToonFragment + + #define MTOON_URP + #define MTOON_PASS_OUTLINE + + #include "./vrmc_materials_mtoon_forward_vertex.hlsl" + #include "./vrmc_materials_mtoon_forward_fragment.hlsl" + ENDHLSL + } + // Shadow rendering pass Pass { diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs new file mode 100644 index 000000000..5320b2fd6 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs @@ -0,0 +1,24 @@ +#if MTOON_URP +using UnityEngine.Rendering.Universal; + +namespace VRMShaders.VRM10.MToon10.Runtime +{ + public sealed class MToonOutlineRenderFeature : ScriptableRendererFeature + { + private MToonOutlineRenderPass _pass; + + public override void Create() + { + _pass = new MToonOutlineRenderPass + { + renderPassEvent = RenderPassEvent.AfterRenderingOpaques + }; + } + + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + renderer.EnqueuePass(_pass); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs.meta b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs.meta new file mode 100644 index 000000000..e0a69838c --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderFeature.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5b6d00cd3f0249a2b4ee7dc86f9a8d63 +timeCreated: 1682661280 \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs new file mode 100644 index 000000000..5fedcc594 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs @@ -0,0 +1,41 @@ +#if MTOON_URP +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +namespace VRMShaders.VRM10.MToon10.Runtime +{ + public sealed class MToonOutlineRenderPass : ScriptableRenderPass + { + private const string ProfilerTag = nameof(MToonOutlineRenderPass); + private readonly ProfilingSampler _profilingSampler = new ProfilingSampler(ProfilerTag); + + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + var cmd = CommandBufferPool.Get(); + using (new ProfilingScope(cmd, _profilingSampler)) + { + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + + var camera = renderingData.cameraData.camera; + var shaderTagId = new ShaderTagId("MToonOutline"); + var sortingSettings = new SortingSettings(camera); + var drawingSettings = new DrawingSettings(shaderTagId, sortingSettings) + { + perObjectData = PerObjectData.ReflectionProbes | PerObjectData.Lightmaps | + PerObjectData.LightProbe | PerObjectData.LightData | PerObjectData.OcclusionProbe | + PerObjectData.ShadowMask + }; + var filteringSettings = FilteringSettings.defaultValue; + var renderStateBlock = new RenderStateBlock(RenderStateMask.Nothing); + context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, + ref renderStateBlock); + } + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs.meta b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs.meta new file mode 100644 index 000000000..e26639ad2 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/MToonOutlineRenderPass.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: df162971c1034acdbe28ff1ec94d8601 +timeCreated: 1682665616 \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/VRMShaders.VRM10.MToon10.Runtime.asmdef b/Assets/VRMShaders/VRM10/MToon10/Runtime/VRMShaders.VRM10.MToon10.Runtime.asmdef index 25f494397..7b4b785b5 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/VRMShaders.VRM10.MToon10.Runtime.asmdef +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/VRMShaders.VRM10.MToon10.Runtime.asmdef @@ -1,6 +1,10 @@ { "name": "VRMShaders.VRM10.MToon10.Runtime", - "references": [], + "rootNamespace": "", + "references": [ + "GUID:15fc0a57446b3144c949da3e2b9737a9", + "GUID:df380645f10b7bc4b97d4f5eb6303d95" + ], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, @@ -8,6 +12,12 @@ "precompiledReferences": [], "autoReferenced": false, "defineConstraints": [], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.render-pipelines.core", + "expression": "", + "define": "MTOON_URP" + } + ], "noEngineReferences": false } \ No newline at end of file From 93333ce6f86ea279262546031854a6cb423922d5 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 15:34:06 +0900 Subject: [PATCH 29/35] =?UTF-8?q?SubShader=E3=81=AETags=E3=81=AE=E8=A1=A8?= =?UTF-8?q?=E8=A8=98=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/VRM10/vrmc_materials_mtoon_urp.shader | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 26cf9e71a..b33c4ded0 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -67,7 +67,12 @@ Shader "VRM10/MToon10_URP" // Shader Model 3.0 SubShader { - Tags { "RenderType" = "Opaque" "Queue" = "Geometry" } + Tags { + "RenderType" = "Opaque" + "RenderPipeline" = "UniversalPipeline" + "UniversalMaterialType" = "Lit" + "IgnoreProjector" = "True" + } // Built-in Forward Base Pass Pass From ae08e8b5ef2fb3d7c637398535a48f9a596f3097 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 15:34:20 +0900 Subject: [PATCH 30/35] =?UTF-8?q?=E6=94=B9=E8=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index b33c4ded0..a3d24a761 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -67,7 +67,8 @@ Shader "VRM10/MToon10_URP" // Shader Model 3.0 SubShader { - Tags { + Tags + { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "UniversalMaterialType" = "Lit" From edf58171062caa3ec7ef171a475dd3815e309971 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 16:13:40 +0900 Subject: [PATCH 31/35] =?UTF-8?q?Fallback=E3=82=92FallbackError=E3=81=AB?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index a3d24a761..026dffd5c 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -192,6 +192,7 @@ Shader "VRM10/MToon10_URP" ENDHLSL } } - Fallback "Unlit/Texture" + + FallBack "Hidden/Universal Render Pipeline/FallbackError" CustomEditor "VRMShaders.VRM10.MToon10.Editor.MToonInspector" } From 503bd64d7d3824169a119de17887e41acca4f1de Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 16:35:39 +0900 Subject: [PATCH 32/35] Rename shader to "VRM10/URP MToon10" --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 026dffd5c..79521a51b 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -1,4 +1,4 @@ -Shader "VRM10/MToon10_URP" +Shader "VRM10/URP MToon10" { Properties { From 95cad4b5feaf7410b519030a1bcbc374c9ca0d27 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 16:39:29 +0900 Subject: [PATCH 33/35] Rename -> VRM10/URP/MToon10 --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 79521a51b..7c942089e 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -1,4 +1,4 @@ -Shader "VRM10/URP MToon10" +Shader "VRM10/URP/MToon10" { Properties { From efd11e7a77220ef0406e90fd06a276b0f1d1e9f5 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 16:41:40 +0900 Subject: [PATCH 34/35] rename -> Universal Render Pipeline/ --- .../MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader index 7c942089e..d10d28134 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader @@ -1,4 +1,4 @@ -Shader "VRM10/URP/MToon10" +Shader "VRM10/Universal Render Pipeline/MToon10" { Properties { From 9f6927716351757cbd1fa71945b158d257419e52 Mon Sep 17 00:00:00 2001 From: notargs Date: Mon, 8 May 2023 17:12:37 +0900 Subject: [PATCH 35/35] =?UTF-8?q?C#=E5=81=B4=E3=82=92Shader=E5=90=8D?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=81=AB=E8=BF=BD=E5=BE=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs index de76587b8..33e485a96 100644 --- a/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs +++ b/Assets/VRMShaders/VRM10/MToon10/Runtime/UnityShaderLab/Properties/MToon10Meta.cs @@ -3,6 +3,6 @@ public static class MToon10Meta { public static readonly string UnityShaderName = "VRM10/MToon10"; - public static readonly string URPUnityShaderName = "VRM10/MToon10_URP"; + public static readonly string URPUnityShaderName = "VRM10/Universal Render Pipeline/MToon10"; } } \ No newline at end of file