コンパイルが通る状態にまで持っていった

This commit is contained in:
notargs 2023-04-26 13:57:12 +09:00
parent 0f0c8bba94
commit 613b2c7a62
2 changed files with 30 additions and 0 deletions

View File

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

View File

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