46 lines
1.6 KiB
HLSL
46 lines
1.6 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
|
|
|
|
#pragma once
|
|
|
|
#if NiloToonFurPrepassBufferPass
|
|
float4 FurNiloToonPrepassBufferColorOutput(Varyings input, FRONT_FACE_TYPE IsFrontFace : FRONT_FACE_SEMANTIC) : SV_TARGET
|
|
{
|
|
BaseColorAlphaClipTest(input, IsFrontFace);
|
|
|
|
#if _NILOTOON_FUR
|
|
float furNoise = ComputeNiloToonFurNoise(input.uv01.xy);
|
|
float furAlpha = ComputeNiloToonFurAlphaAndClip(input.uv01.xy, input.furLayer, furNoise);
|
|
|
|
if (_NiloFurShowOnSkinFace < 0.5)
|
|
{
|
|
half skinFaceArea = max(GetFaceArea(input.uv01.xy), GetSkinArea(input.uv01.xy));
|
|
clip(0.5 - skinFaceArea);
|
|
}
|
|
#else
|
|
discard;
|
|
float furAlpha = 0;
|
|
#endif
|
|
|
|
float sceneLinearDepth = Convert_SV_PositionZ_ToLinearViewSpaceDepth(LoadSceneDepth(input.positionCS.xy));
|
|
float selfLinearDepth = Convert_SV_PositionZ_ToLinearViewSpaceDepth(input.positionCS.z);
|
|
|
|
float depthBias = -0.0001;
|
|
float2 depthGradient = float2(ddx(selfLinearDepth), ddy(selfLinearDepth));
|
|
float gradientBias = length(depthGradient) * 0.5;
|
|
depthBias = depthBias - gradientBias;
|
|
|
|
if(sceneLinearDepth < selfLinearDepth + depthBias)
|
|
return 0;
|
|
|
|
float isFace = GetFaceArea(input.uv01.xy);
|
|
float4 prepassOutput = float4(isFace, _AllowNiloToonBloomCharacterAreaOverride * _AllowedNiloToonBloomOverrideStrength, 0, 1);
|
|
|
|
#if !NiloToonFurPrepassBufferDepthPass
|
|
prepassOutput.a = furAlpha;
|
|
#endif
|
|
|
|
return prepassOutput;
|
|
}
|
|
#endif
|