Streamingle_URP/Assets/NiloToonURP/Shaders/NiloToonCharacter_HLSL/NiloToonCharacter_GenericRimLight3D.hlsl

62 lines
2.5 KiB
HLSL

// SPDX-License-Identifier: (Not available for this version, you are only allowed to use this software if you have express permission from the copyright holder and agreed to the latest NiloToonURP EULA)
// Copyright (c) 2021 Kuroneko ShaderLab Limited
// For more information, visit -> https://github.com/ColinLeung-NiloCat/UnityURPToonLitShaderExample
// #pragma once is a safe guard best practice in almost every .hlsl,
// doing this can make sure your .hlsl's user can include this .hlsl anywhere anytime without producing any multi include conflict
#pragma once
#if _GENERIC_RIMLIGHT3D
void ApplyNiloToonCharacterGenericRimLight3D(
inout half3 result,
ToonSurfaceData surfaceData,
Varyings input,
ToonLightingData lightingData,
Light light,
half finalShadowArea,
half inShadow25PercentMul)
{
float2 genericRimLight3DColorUv = CalcUV(GetUV(input), _GenericRimLight3DColorTex_ST);
half4 genericRimLight3DColorTex = SAMPLE_TEXTURE2D(_GenericRimLight3DColorTex, sampler_BaseMap, genericRimLight3DColorUv);
#if _FACE_MASK_ON
half3 genericRimLight3DSmoothedNormalWS = normalize(input.smoothedNormalWS);
#else
half3 genericRimLight3DSmoothedNormalWS = input.smoothedNormalWS;
#endif
half3 genericRimLight3DNoNormalMapWS = lerp(lightingData.normalWS_NoNormalMap, genericRimLight3DSmoothedNormalWS, lightingData.isFaceArea);
half3 genericRimLight3DNormalWS = lerp(lightingData.normalWS, genericRimLight3DSmoothedNormalWS, lightingData.isFaceArea);
result = ApplyNiloGenericRimLight3D(
result,
surfaceData.albedo,
lightingData.facing,
genericRimLight3DNoNormalMapWS,
genericRimLight3DNormalWS,
lightingData.viewDirectionWS,
light.direction,
min(_GlobalMainDirectionalLightMaxContribution, light.color),
finalShadowArea,
inShadow25PercentMul,
genericRimLight3DColorTex,
_GenericRimLight3DColor,
_GenericRimLight3DIndirColor,
_GenericRimLight3DAlpha,
_GenericRimLight3DMainStrength,
_GenericRimLight3DEnableLighting,
_GenericRimLight3DShadowMask,
_GenericRimLight3DBackfaceMask,
_GenericRimLight3DBlendMode,
_GenericRimLight3DDirStrength,
_GenericRimLight3DDirRange,
_GenericRimLight3DBorder,
_GenericRimLight3DBlur,
_GenericRimLight3DIndirRange,
_GenericRimLight3DIndirBorder,
_GenericRimLight3DIndirBlur,
_GenericRimLight3DNormalStrength,
_GenericRimLight3DFresnelPower,
_GenericRimLight3DVRParallaxStrength);
}
#endif