diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl new file mode 100644 index 000000000..278bfca0f --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl @@ -0,0 +1,38 @@ +#ifndef VRMC_MATERIALS_MTOON_DEPTHNORMALS_FRAGMENT_INCLUDED +#define VRMC_MATERIALS_MTOON_DEPTHNORMALS_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 MToonDepthNormalsFragment(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); + + // Get Normal + float3 normalWS = GetMToonGeometry_Normal(input, fragmentInput.facing, uv); + normalWS = NormalizeNormalPerPixel(normalWS); + + return half4(normalWS, 0.0); +} + +#endif + +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta new file mode 100644 index 000000000..6087a7c7f --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_fragment.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 93f88dc204e783a4aaabfc17a087bce8 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl new file mode 100644 index 000000000..9349252e0 --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl @@ -0,0 +1,43 @@ +#ifndef VRMC_MATERIALS_MTOON_DEPTHNORMALS_VERTEX_INCLUDED +#define VRMC_MATERIALS_MTOON_DEPTHNORMALS_VERTEX_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_vertex.hlsl" + +Varyings MToonDepthNormalsVertex(const Attributes v) +{ + Varyings output = (Varyings)0; + + UNITY_SETUP_INSTANCE_ID(v); + UNITY_TRANSFER_INSTANCE_ID(v, output); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + +#if defined(_NORMALMAP) + VertexNormalInputs normalInput = GetVertexNormalInputs(v.normalOS, v.tangentOS); + float3 normalWS = normalInput.normalWS; + float sign = v.tangentOS.w * float(GetOddNegativeScale()); + half4 tangentWS = half4(normalInput.tangentWS.xyz, sign); +#else + float3 normalWS = TransformObjectToWorldNormal(v.normalOS); +#endif + + output.pos = TransformObjectToHClip(v.vertex.xyz); + output.normalWS = normalWS; +#if defined(_NORMALMAP) + output.tangentWS = tangentWS; +#endif + output.uv = v.texcoord0; + + return output; +} + +#endif + +#endif \ No newline at end of file diff --git a/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta new file mode 100644 index 000000000..8b3aaab6a --- /dev/null +++ b/Assets/VRMShaders/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_depthnormals_vertex.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b69080781a3778e499a6ae99adb82053 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: