DepthNormalsPassを追加

This commit is contained in:
yoship1639
2023-07-21 18:18:54 +09:00
parent c334886e08
commit 0b48e59f51
4 changed files with 99 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 93f88dc204e783a4aaabfc17a087bce8
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b69080781a3778e499a6ae99adb82053
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: