Update custom pass to global custom pass
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#define unity_ColorSpaceDielectricSpec half4(0.04, 0.04, 0.04, 1 - 0.04)
|
||||
|
||||
// _preIntegratedFGD and _CubemapLD are unique for each BRDF
|
||||
IndirectLighting EvaluateBSDF_Env(LightLoopContext lightLoopContext,
|
||||
float3 V, PositionInputs posInput,
|
||||
@@ -171,7 +169,7 @@ float3 ComputeIndirectDiffuse(PositionInputs posInput, BSDFData bsdfData, float3
|
||||
}
|
||||
|
||||
//Compelete the indirect lighting
|
||||
indirectDiffuse = indirectDiffuse * bsdfData.diffuseColor * _BaseColor;
|
||||
indirectDiffuse = indirectDiffuse * bsdfData.diffuseColor.rgb * _BaseColor.rgb;
|
||||
|
||||
//SSAO
|
||||
if(_ReceivesSSAO == 1)
|
||||
@@ -204,8 +202,8 @@ float3 ComputeIndirectSpecular(LightLoopContext lightLoopContext, PositionInputs
|
||||
float NdotV = saturate(dot(bsdfData.normalWS, V));
|
||||
|
||||
indirectSpecular = SampleSkyTexture(reflect(-V, bsdfData.normalWS), mip, 0).rgb;
|
||||
float3 specColor = lerp(unity_ColorSpaceDielectricSpec, albedo, surfaceData.metallic);;
|
||||
float oneMinusReflectivity = unity_ColorSpaceDielectricSpec.a * (1 - surfaceData.metallic);
|
||||
float3 specColor = lerp(ColorSpaceDielectricSpec.rgb, albedo, surfaceData.metallic);
|
||||
float oneMinusReflectivity = ColorSpaceDielectricSpec.a * (1 - surfaceData.metallic);
|
||||
float grazingTerm = saturate((1 - bsdfData.perceptualRoughness) + (1 - oneMinusReflectivity));
|
||||
|
||||
//Reflection Probe
|
||||
|
||||
@@ -316,8 +316,8 @@ Shader "HDRP/Toon"
|
||||
_SDFNoseHighlightCoef("SDFNoseHighlightCoef", Range(0.0, 5.0)) = 1.25
|
||||
_SDFNoseHighlightSmoothRange("SDFNoseHighlightSmoothRange", Range(0.0, 0.1)) = 0.02
|
||||
|
||||
// Hair Shadow
|
||||
[Toggle(_)] _Is_ReceiveHairShadow("_Is_ReceiveHairShadow", Float) = 0
|
||||
// Hair Shadow
|
||||
[Toggle(_)] _Is_ReceiveHairShadow("Is_ReceiveHairShadow", Float) = 0
|
||||
|
||||
_ShadowBias("ShadowBias", Range(0.0, 5.0)) = 0.0
|
||||
|
||||
@@ -326,11 +326,11 @@ Shader "HDRP/Toon"
|
||||
|
||||
// Eye Parallax
|
||||
[Toggle(_)] _Is_EyeParallax("_Is_EyeParallax", Float) = 0
|
||||
_EyeParallaxAmount("_EyeParallaxAmount", Float) = 0.1
|
||||
_EyeParallaxAmount("EyeParallaxAmount", Float) = 0.1
|
||||
|
||||
// Eyebrow Seethrough
|
||||
[Togle(_)] _Is_EyebrowSeethrough("_Is_EyebrowSeethrough", Float) = 0
|
||||
_EyeBrowBlendingFactor("_EyeBrowBlendingFactor", Float) = 0.5
|
||||
_EyeBrowBlendingFactor("EyeBrowBlendingFactor", Float) = 0.5
|
||||
|
||||
//v.2.0.6
|
||||
_BaseColor_Step("BaseColor_Step", Range(0, 1)) = 0.5
|
||||
|
||||
@@ -33,6 +33,7 @@ struct UTSData
|
||||
fixed signMirror;
|
||||
};
|
||||
|
||||
//#define UTSDATA_ZERO_INITIALIZE (UTSData)
|
||||
|
||||
struct UTSLightData
|
||||
{
|
||||
@@ -42,6 +43,7 @@ struct UTSLightData
|
||||
float specularDimmer;
|
||||
float3 shadowTint;
|
||||
float penumbraTint;
|
||||
float shadowValue;
|
||||
};
|
||||
|
||||
struct UTSAggregateLighting
|
||||
@@ -325,5 +327,26 @@ float3 SampleBakedGI_UTS(float3 positionRWS, float3 normalWS, float2 uvStaticLig
|
||||
return bakeDiffuseLighting;
|
||||
}
|
||||
|
||||
float3 SampleBakedGI_UTS_OutLine(float3 positionRWS, float3 normalWS, float2 uvStaticLightmap, float2 uvDynamicLightmap)
|
||||
{
|
||||
float3 bakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backBakeDiffuseLighting = float3(0, 0, 0);
|
||||
float3 backNormalWS = float3(0, 0, 0);
|
||||
|
||||
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||
EvaluateLightmap(positionRWS, normalWS, backNormalWS, uvStaticLightmap, uvDynamicLightmap, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#elif (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
|
||||
EvaluateAdaptiveProbeVolume(GetAbsolutePositionWS(positionRWS), normalWS, backNormalWS, GetWorldSpaceNormalizeViewDir(positionRWS), 0.0, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#else
|
||||
EvaluateLightProbeBuiltin(positionRWS, normalWS, backNormalWS, bakeDiffuseLighting, backBakeDiffuseLighting);
|
||||
#if defined(SHADER_STAGE_RAY_TRACING)
|
||||
bakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
backBakeDiffuseLighting *= _RayTracingAmbientProbeDimmer;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return bakeDiffuseLighting;
|
||||
}
|
||||
|
||||
|
||||
#endif //#ifndef UCTS_HDRP_INCLUDED
|
||||
@@ -152,10 +152,10 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
||||
//v.2.0.9
|
||||
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
||||
float3 envLightSource_GradientEquator = ShadeSH9(float4(0, 1, 0, 0)) * 10.0;
|
||||
float3 envLightSource_GradientEquator = ShadeSH9(float4(0, 1, 0, 0));
|
||||
float3 envLightSource_SkyboxIntensity = max(
|
||||
SampleBakedGI_UTS(objPos, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true),
|
||||
SampleBakedGI_UTS(objPos, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy, true)
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, 0.0, 0.0), input.texCoord1.xy, input.texCoord2.xy),
|
||||
SampleBakedGI_UTS_OutLine(objPos.xyz, float3(0.0, -1.0, 0.0), input.texCoord1.xy, input.texCoord2.xy)
|
||||
).rgb;
|
||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||
ambientSkyColor *= GetCurrentExposureMultiplier() * 5.0f;
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
float3 FinalNormal;
|
||||
if(_UseSmoothedNormal == 1)
|
||||
{
|
||||
float3 normal = float3(inputMesh.uv1, 0);
|
||||
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
|
||||
FinalNormal = mul(normal, tangentTransform);
|
||||
float3 normal = float3(inputMesh.uv1, 0);
|
||||
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
|
||||
FinalNormal = mul(normal, tangentTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
FinalNormal = lerp(inputMesh.normalOS, _BakedNormalDir, _Is_BakedNormal);
|
||||
FinalNormal = lerp(inputMesh.normalOS, _BakedNormalDir, _Is_BakedNormal);
|
||||
}
|
||||
|
||||
//v2.0.4
|
||||
@@ -50,7 +50,7 @@
|
||||
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), signVar * normalize(inputMesh.positionOS));
|
||||
#endif
|
||||
// screen space width
|
||||
float2 extendDir = normalize(TransformWViewToHClip(normal));
|
||||
float2 extendDir = normalize(TransformWViewToHClip(normal).xy);
|
||||
float4 clipPos = UnityObjectToClipPos(inputMesh.positionOS);
|
||||
clipPos.xy += extendDir * min(_Outline_MaxWidth, (clipPos.w * Set_Outline_Width));
|
||||
clipPos.z = clipPos.z + _Offset_Z * _ClipCameraPos.z;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define unity_ColorSpaceDielectricSpec half4(0.22, 0.22, 0.22, 0.779)
|
||||
#define ColorSpaceDielectricSpec half4(0.22, 0.22, 0.22, 0.779)
|
||||
|
||||
float3 schlick(float f0, float hl) {
|
||||
real x = 1.0 - hl;
|
||||
@@ -9,7 +9,7 @@ float3 schlick(float f0, float hl) {
|
||||
|
||||
float3 SpecularColor(float3 albedo, float metalic)
|
||||
{
|
||||
float3 specColor = lerp(unity_ColorSpaceDielectricSpec, albedo, metalic);
|
||||
float3 specColor = lerp(ColorSpaceDielectricSpec.rgb, albedo, metalic);
|
||||
return specColor;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ float3 ComputeSpecularTerm(float3 V, float3 L, BSDFData bsdfData)
|
||||
float NdotH = saturate(dot(N, H));
|
||||
float HdotL = saturate(dot(H, L));
|
||||
|
||||
float3 F = schlick(bsdfData.fresnel0, HdotL);
|
||||
float3 F = schlick(bsdfData.fresnel0.x, HdotL);
|
||||
|
||||
float partLambdaV;
|
||||
float3 DV = 0;
|
||||
@@ -80,7 +80,7 @@ float3 ComputeSpecularTerm(float3 V, float3 L, BSDFData bsdfData)
|
||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||
specTerm = pow(NdotH, 5.0 * specularExponent);
|
||||
specTerm = StepFeatherToon(specTerm, _ToonSpecularStep, _ToonSpecularFeather);
|
||||
return specTerm * unity_ColorSpaceDielectricSpec * clampedNdotL;
|
||||
return specTerm * ColorSpaceDielectricSpec.rgb * clampedNdotL;
|
||||
#endif
|
||||
|
||||
specTerm = DV * F;
|
||||
@@ -132,8 +132,8 @@ half3 FitWithCurveApprox(half NdotL, half Curvature)
|
||||
float2 right_uv = float2(1 - UV.x, UV.y);
|
||||
rSDF_Tex = SAMPLE_TEXTURE2D(_SDFShadowTex, sampler_SDFShadowTex, right_uv);
|
||||
|
||||
leftVector = normalize(mul(UNITY_MATRIX_M, float3(1, 0, 0)).xz);
|
||||
forwardVector = normalize(mul(UNITY_MATRIX_M, float3(0, 0, 1)).xz);
|
||||
leftVector = normalize(mul(UNITY_MATRIX_M, float4(1, 0, 0, 0)).xz);
|
||||
forwardVector = normalize(mul(UNITY_MATRIX_M, float4(0, 0, 1, 0)).xz);
|
||||
}
|
||||
|
||||
// Return 1 -> right side
|
||||
@@ -165,26 +165,11 @@ half3 FitWithCurveApprox(half NdotL, half Curvature)
|
||||
|
||||
float SDFMask(float angle, float tex_direct)
|
||||
{
|
||||
float SDFMask = 0;
|
||||
float smoothGamma = _SDFSmoothGamma / 10.0f;
|
||||
float shadowLevel = _SDFShadowLevel / 10.0f;
|
||||
|
||||
float isShadow = smoothstep(tex_direct - smoothGamma, tex_direct + smoothGamma, angle - shadowLevel);
|
||||
//float bias = saturate(smoothstep(0, _SDFShadowLevel , (angle - tex_direct)));
|
||||
|
||||
//if(angle > 0.99)
|
||||
//{
|
||||
// SDFMask = lerp(0, 1, bias) * saturate(angle);
|
||||
//}
|
||||
|
||||
//if(isShadow > 0.95)
|
||||
//{
|
||||
// SDFMask = lerp(0, 1, bias) * saturate(isShadow);
|
||||
//}
|
||||
|
||||
////float v = SDFMask - 0.5;
|
||||
////SDFMask = saturate(v / (fwidth(v) + HALF_MIN));
|
||||
return isShadow;
|
||||
float SDFMask = smoothstep(tex_direct - smoothGamma, tex_direct + smoothGamma, angle - shadowLevel);
|
||||
return SDFMask;
|
||||
}
|
||||
|
||||
float SDFNoseHighlight(float angle,float tex_value, bool rightside, float2 UV)
|
||||
@@ -196,7 +181,7 @@ half3 FitWithCurveApprox(half NdotL, half Curvature)
|
||||
float cutU = UV.x;
|
||||
|
||||
float uvMask=lerp(cutU, 1 - cutU, rightside);//discard half of the sdf we sampled (Only one side of highlight wanted)
|
||||
float lightAtten = pow(angle - (_SDFShadowLevel / 10.0f), 0.8);
|
||||
float lightAtten = pow(max(0, angle - (_SDFShadowLevel / 10.0f)), 0.8);
|
||||
|
||||
return smoothstep(lightAtten-_SDFNoseHighlightSmoothRange,lightAtten+_SDFNoseHighlightSmoothRange , uvMask * tex_value) * tex_value; // Safeguard, return 0 when tex_value = 0
|
||||
}
|
||||
|
||||
@@ -304,8 +304,9 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
ZERO_INITIALIZE(UTSAggregateLighting, utsAggregateLighting);
|
||||
|
||||
UTSLightData customMainLight;
|
||||
UTSLightData mainPunctualLight;
|
||||
mainPunctualLight.lightColor = float3(0, 0, 0);
|
||||
customMainLight.shadowValue = 1.0f;
|
||||
//UTSLightData mainPunctualLight;
|
||||
//mainPunctualLight.lightColor = float3(0, 0, 0);
|
||||
|
||||
#define UNITY_PROJ_COORD(a) a
|
||||
#define UNITY_SAMPLE_SCREEN_SHADOW(tex, uv) tex2Dproj( tex, UNITY_PROJ_COORD(uv) ).r
|
||||
@@ -350,13 +351,13 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float3 lightColor = ApplyCurrentExposureMultiplier(lightData.color);
|
||||
float3 lightDirection = -lightData.forward;
|
||||
|
||||
#ifndef LIGHT_EVALUATION_NO_COOKIE
|
||||
#ifndef LIGHT_EVALUATION_NO_COOKIE
|
||||
if (lightData.cookieMode != COOKIEMODE_NONE)
|
||||
{
|
||||
float3 lightToSample = input.positionRWS - lightData.positionRWS;
|
||||
lightColor *= EvaluateCookie_Directional(context, lightData, lightToSample);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UTSLightData utsLightData;
|
||||
utsLightData.lightDirection = lightDirection;
|
||||
@@ -366,18 +367,20 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
utsLightData.shadowTint = lightData.shadowTint;
|
||||
utsLightData.penumbraTint = lightData.penumbraTint;
|
||||
|
||||
customMainLight = utsLightData;
|
||||
|
||||
// Evaluate sun shadows.
|
||||
if (_DirectionalShadowIndex >= 0)
|
||||
{
|
||||
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(UTS_USE_RAYTRACING_SHADOW)
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(UTS_USE_RAYTRACING_SHADOW)
|
||||
if (UtsUseScreenSpaceShadow(light, bsdfData.normalWS))
|
||||
{
|
||||
// HDRP Contact Shadow
|
||||
context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
// TODO: this will cause us to load from the normal buffer first. Does this cause a performance problem?
|
||||
float3 L = -light.forward;
|
||||
@@ -388,7 +391,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
!ShouldEvaluateThickObjectTransmission(V, L, preLightData, bsdfData, light.shadowIndex))
|
||||
{
|
||||
|
||||
#if defined(UTS_USE_RAYTRACING_SHADOW)
|
||||
#if defined(UTS_USE_RAYTRACING_SHADOW)
|
||||
{
|
||||
/*
|
||||
struct PositionInputs
|
||||
@@ -406,37 +409,37 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, lightDirection * _ShadowBias, 1));
|
||||
context.shadowValue = r;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
{
|
||||
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
||||
posInput.positionSS, posInput.positionWS + lightDirection * _ShadowBias, GetNormalForShadowBias(bsdfData),
|
||||
light.shadowIndex, L);
|
||||
|
||||
}
|
||||
#endif // UTS_USE_RAYTRACING_SHADOW
|
||||
#endif // UTS_USE_RAYTRACING_SHADOW
|
||||
|
||||
|
||||
}
|
||||
#if defined (UTS_USE_RAYTRACING_SHADOW)
|
||||
#if defined (UTS_USE_RAYTRACING_SHADOW)
|
||||
else
|
||||
{
|
||||
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, lightDirection * _ShadowBias, 1));
|
||||
context.shadowValue = r;
|
||||
}
|
||||
#endif // UTS_USE_RAYTRACING_SHADOW
|
||||
#endif // UTS_USE_RAYTRACING_SHADOW
|
||||
}
|
||||
|
||||
context.shadowValue = lerp(1, context.shadowValue, lightData.shadowDimmer);
|
||||
|
||||
customMainLight.shadowValue = context.shadowValue;
|
||||
}
|
||||
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
if (_DirectionalShadowIndex >= 0)
|
||||
finalColor = UTS_SelfShdowMainLight(context, input, _DirectionalShadowIndex);
|
||||
#else
|
||||
#else
|
||||
UTS_MainLight(context, input, utsLightData, surfaceData, bsdfData, inverseClipping, channelAlpha, utsData, utsAggregateLighting);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int i = 0; // Declare once to avoid the D3D11 compiler warning.
|
||||
@@ -455,11 +458,11 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
utsLightData.shadowTint = _DirectionalLightDatas[i].shadowTint;
|
||||
utsLightData.penumbraTint = _DirectionalLightDatas[i].penumbraTint;
|
||||
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#else
|
||||
#else
|
||||
UTS_OtherLights(context, input, utsLightData, surfaceData, bsdfData, 0, i_normalDir, notDirectional, channelAlpha, utsAggregateLighting);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,14 +477,14 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
{
|
||||
uint lightCount, lightStart;
|
||||
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
GetCountAndStart(posInput, LIGHTCATEGORY_PUNCTUAL, lightStart, lightCount);
|
||||
#else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
#else // LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
lightCount = _PunctualLightCount;
|
||||
lightStart = 0;
|
||||
#endif
|
||||
#endif
|
||||
bool fastPath = false;
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
uint lightStartLane0;
|
||||
fastPath = IsFastPath(lightStart, lightStartLane0);
|
||||
|
||||
@@ -489,7 +492,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
{
|
||||
lightStart = lightStartLane0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -506,11 +509,11 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
while (v_lightListOffset < lightCount)
|
||||
{
|
||||
v_lightIdx = FetchIndex(lightStart, v_lightListOffset);
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
#if SCALARIZE_LIGHT_LOOP
|
||||
uint s_lightIdx = ScalarizeElementIndex(v_lightIdx, fastPath);
|
||||
#else
|
||||
#else
|
||||
uint s_lightIdx = v_lightIdx;
|
||||
#endif
|
||||
#endif
|
||||
if (s_lightIdx == -1)
|
||||
break;
|
||||
|
||||
@@ -531,13 +534,6 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
float3 additionalLightColor = ApplyCurrentExposureMultiplier(lightColor.rgb) * lightColor.a;
|
||||
const float notDirectional = 1.0f;
|
||||
|
||||
float3 lightDirectionToObject;
|
||||
float4 distancesToObject; // {d, d^2, 1/d, d_proj}
|
||||
float3 objectCenter = (TransformObjectToWorld(float3(0, 0, 0)));
|
||||
GetPunctualLightVectors(objectCenter, s_lightData, lightDirectionToObject, distancesToObject);
|
||||
float4 lightColorToObject = EvaluateLight_Punctual(context, posInput, s_lightData, lightDirectionToObject, distancesToObject);
|
||||
float3 additionalLightColorToObject = ApplyCurrentExposureMultiplier(lightColorToObject.rgb) * lightColorToObject.a;
|
||||
|
||||
UTSLightData utsLightData;
|
||||
utsLightData.lightColor = additionalLightColor;
|
||||
utsLightData.lightDirection = lightDirection;
|
||||
@@ -546,23 +542,31 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
utsLightData.shadowTint = s_lightData.shadowTint;
|
||||
utsLightData.penumbraTint = s_lightData.penumbraTint;
|
||||
|
||||
if (length(utsLightData.lightColor) >= length(mainPunctualLight.lightColor))
|
||||
{
|
||||
//mainPunctualLight = utsLightData;
|
||||
mainPunctualLight.lightColor = additionalLightColorToObject;
|
||||
mainPunctualLight.lightDirection = lightDirectionToObject;
|
||||
}
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#else
|
||||
#else
|
||||
posInput.positionWS = posInput.positionWS + lightDirection * _ShadowBias;
|
||||
float shadow = EvaluateShadow_Punctual(context, posInput, s_lightData, builtinData, GetNormalForShadowBias(bsdfData), lightDirection, distances);
|
||||
context.shadowValue = shadow;
|
||||
posInput.positionWS = posInput.positionWS - lightDirection * _ShadowBias;
|
||||
|
||||
if (length(utsLightData.lightColor) >= length(customMainLight.lightColor))
|
||||
{
|
||||
float3 lightDirectionToObject;
|
||||
float4 distancesToObject; // {d, d^2, 1/d, d_proj}
|
||||
float3 objectCenter = (TransformObjectToWorld(float3(0, 0, 0)));
|
||||
GetPunctualLightVectors(objectCenter, s_lightData, lightDirectionToObject, distancesToObject);
|
||||
float4 lightColorToObject = EvaluateLight_Punctual(context, posInput, s_lightData, lightDirectionToObject, distancesToObject);
|
||||
float3 additionalLightColorToObject = ApplyCurrentExposureMultiplier(lightColorToObject.rgb) * lightColorToObject.a;
|
||||
|
||||
customMainLight = utsLightData;
|
||||
customMainLight.lightColor = additionalLightColorToObject;
|
||||
customMainLight.lightDirection = lightDirectionToObject;
|
||||
customMainLight.shadowValue = context.shadowValue;
|
||||
}
|
||||
|
||||
UTS_OtherLights(context, input, utsLightData, surfaceData, bsdfData, s_lightData.lightType, i_normalDir, notDirectional, channelAlpha, utsAggregateLighting);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -575,12 +579,12 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
{
|
||||
uint lightCount, lightStart;
|
||||
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
#ifndef LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||
GetCountAndStart(posInput, LIGHTCATEGORY_AREA, lightStart, lightCount);
|
||||
#else
|
||||
#else
|
||||
lightCount = _AreaLightCount;
|
||||
lightStart = _PunctualLightCount;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// COMPILER BEHAVIOR WARNING!
|
||||
// If rectangle lights are before line lights, the compiler will duplicate light matrices in VGPR because they are used differently between the two types of lights.
|
||||
@@ -645,13 +649,13 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
//Evaluate the shadow part
|
||||
float shadow;
|
||||
posInput.positionWS = posInput.positionWS + utsLightData.lightDirection * _ShadowBias;
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
||||
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT)
|
||||
if ((s_lightData.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW)
|
||||
{
|
||||
shadow = GetScreenSpaceShadow(posInput, s_lightData.screenSpaceShadowIndex);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
shadow = EvaluateShadow_RectArea(context, posInput, s_lightData, builtinData, GetNormalForShadowBias(bsdfData), normalize(s_lightData.positionRWS), length(s_lightData.positionRWS));
|
||||
}
|
||||
@@ -659,13 +663,13 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
posInput.positionWS = posInput.positionWS - lightDirection * _ShadowBias;
|
||||
}
|
||||
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
#if defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#else
|
||||
#else
|
||||
UTS_OtherLights(context, input, utsLightData, surfaceData, bsdfData, s_lightData.lightType, i_normalDir, notDirectional, channelAlpha, utsAggregateLighting);
|
||||
//utsAggregateLighting.directDiffuse += ltcValue.rgb * ltcValue.a * intensity * s_lightData.diffuseDimmer;
|
||||
//utsAggregateLighting.directDiffuse += intensity;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
if(s_lightData.lightType == GPULIGHTTYPE_RECTANGLE)
|
||||
@@ -829,7 +833,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // SHADEROPTIONS_AREA_LIGHTS
|
||||
|
||||
#ifdef _EMISSIVE_SIMPLE
|
||||
float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(Set_UV0, _Emissive_Tex));
|
||||
@@ -872,7 +876,8 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
//v.2.0.6: GI_Intensity with Intensity Multiplier Filter
|
||||
#endif
|
||||
|
||||
customMainLight = GetCustomMainLightData(builtinData, mainPunctualLight);
|
||||
// We directly calculate custome main light during the light loop in upper code to avoid extra calculation
|
||||
//customMainLight = GetCustomMainLightData(builtinData, mainPunctualLight);
|
||||
|
||||
#if _SDFShadow || _RECEIVE_HAIR_SHADOW
|
||||
float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz);
|
||||
@@ -888,6 +893,8 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _1st_ShadeMap)), _MainTex_var, _Use_BaseAs1st);
|
||||
float3 _1st_Shade_var = lerp((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb) * lightColor), _Is_LightColor_1st_Shade);
|
||||
|
||||
float systemShadowValue = lerp(1.0f, saturate(customMainLight.shadowValue * 2.0f), _Set_SystemShadowsToBase);
|
||||
#endif
|
||||
|
||||
#ifdef _SDFShadow
|
||||
@@ -897,12 +904,11 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
bool rightside;
|
||||
float2 SDF_UV = TRANSFORM_TEX(Set_UV0, _BaseColorMap);
|
||||
float4 sdfRes = SDFResult(rightside, angle, customMainLight.lightDirection, SDF_UV);
|
||||
float sdfMask = SDFMask(angle, sdfRes.r);
|
||||
|
||||
utsAggregateLighting.directDiffuse = lerp(bsdfData.diffuseColor * _BaseColor * lightColor, _1st_Shade_var, sdfMask);
|
||||
utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, sdfMask);
|
||||
utsAggregateLighting.directDiffuse += _SDFNoseHighlightCoef * SDFNoseHighlight(angle, sdfRes.g, rightside, SDF_UV) * lightColor;
|
||||
//utsAggregateLighting.directDiffuse = lightColor;
|
||||
float sdfShadowValue = 1.0f - SDFMask(angle, sdfRes.r);
|
||||
|
||||
utsAggregateLighting.directDiffuse = lerp(_1st_Shade_var, bsdfData.diffuseColor * _BaseColor.rgb * lightColor, sdfShadowValue * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular = lerp(0, utsAggregateLighting.directSpecular, sdfShadowValue * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular += _SDFNoseHighlightCoef * SDFNoseHighlight(angle, sdfRes.g, rightside, SDF_UV) * lightColor;
|
||||
#endif
|
||||
|
||||
#if defined(_RECEIVE_HAIR_SHADOW) && defined(_HAIR_SHADOWS)
|
||||
@@ -911,19 +917,18 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
|
||||
if(hairShadowOpacity > 0)
|
||||
{
|
||||
float2 scrPos = input.positionSS.xy;
|
||||
float3 viewLightDir = TransformWorldToViewDir(customMainLight.lightDirection) / posInput.linearDepth; // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face.
|
||||
float shadowLength = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor);
|
||||
float2 samplingPoint = (scrPos + shadowLength * viewLightDir.xy ) * _ScreenSize.zw;
|
||||
float3 viewLightDir = TransformWorldToViewDir(customMainLight.lightDirection); // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face.
|
||||
float shadowLength = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth;
|
||||
float2 samplingPoint = (input.positionSS.xy + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2 (1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
|
||||
// Then sample the hair buffer, to see if the fragment lands in shadow.
|
||||
float3 hairBuffer = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, samplingPoint);
|
||||
float4 hairBuffer = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, samplingPoint);
|
||||
float hairDepth = hairBuffer.r;
|
||||
float depthCorrect = posInput.deviceDepth <= hairDepth + _HairShadowDepthBias ? 1 : 0; // Hair < Face means Hair are closer to camera
|
||||
// Note that we have LinearEyeDepth in the buffer. A comparison of depth is needed so that we don't project the shadow of hair behind the face.
|
||||
float hairShadow = lerp(0,hairShadowOpacity,depthCorrect);
|
||||
|
||||
utsAggregateLighting.directDiffuse = lerp(utsAggregateLighting.directDiffuse, _1st_Shade_var, hairShadow);
|
||||
utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, hairShadow);
|
||||
utsAggregateLighting.directDiffuse = lerp(utsAggregateLighting.directDiffuse, _1st_Shade_var, hairShadow * systemShadowValue);
|
||||
utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, hairShadow * systemShadowValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -950,25 +955,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
outColor = float4(outColor.rgb, Set_Opacity * ApplyChannelAlpha(channelAlpha));
|
||||
#endif
|
||||
|
||||
#if defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||
outColor.rgb = 1;
|
||||
#ifdef UTS_DEBUG_SELFSHADOW
|
||||
outColor.rgb = min(finalColor, outColor.rgb);
|
||||
#endif
|
||||
|
||||
#ifdef UTS_DEBUG_SHADOWMAP
|
||||
#ifdef UTS_DEBUG_SHADOWMAP_BINALIZATION
|
||||
outColor.rgb = min(context.shadowValue < 0.9f ? clamp(context.shadowValue - 0.2, 0.0, 0.9) : 1.0f, outColor.rgb);
|
||||
#else
|
||||
outColor.rgb = min(context.shadowValue, outColor.rgb);
|
||||
#endif
|
||||
#endif // ifdef UTS_DEBUG_SHADOWMAP
|
||||
#endif // defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#ifdef _EYEBROW_SEETHROUGH
|
||||
|
||||
|
||||
|
||||
// By Suomi, 20230915
|
||||
// The eyebrow should use transparent pass and utilize the hair depth texture we have from HairShadowPass
|
||||
float2 samplingPoint = posInput.positionNDC;
|
||||
@@ -989,9 +976,22 @@ void Frag(PackedVaryingsToPS packedInput,
|
||||
|
||||
|
||||
//outColor.rgb = float3(hDepth.rg * 5,0);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||
outColor.rgb = 1;
|
||||
#ifdef UTS_DEBUG_SELFSHADOW
|
||||
outColor.rgb = min(finalColor, outColor.rgb);
|
||||
#endif
|
||||
|
||||
#ifdef UTS_DEBUG_SHADOWMAP
|
||||
#ifdef UTS_DEBUG_SHADOWMAP_BINALIZATION
|
||||
outColor.rgb = min(context.shadowValue < 0.9f ? clamp(context.shadowValue - 0.2, 0.0, 0.9) : 1.0f, outColor.rgb);
|
||||
#else
|
||||
outColor.rgb = min(context.shadowValue, outColor.rgb);
|
||||
#endif
|
||||
#endif // ifdef UTS_DEBUG_SHADOWMAP
|
||||
#endif // defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||
|
||||
#ifdef _DEPTHOFFSET_ON
|
||||
outputDepth = posInput.deviceDepth;
|
||||
|
||||
@@ -12,21 +12,25 @@
|
||||
|
||||
void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLightData utsLightData, SurfaceData surfaceData, BSDFData bsdfData, out float inverseClipping, out float channelOutAlpha, out UTSData utsData, inout UTSAggregateLighting utsAggregateLighting)
|
||||
{
|
||||
inverseClipping = 0;
|
||||
channelOutAlpha = 1.0f;
|
||||
ZERO_INITIALIZE(UTSData, utsData);
|
||||
|
||||
// We dont have to calculate lighting here if we are using sdf shadow
|
||||
#ifndef _SDFShadow
|
||||
|
||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||
inverseClipping = 0;
|
||||
// input.positionSS is SV_Position
|
||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
||||
float2 screenUV = posInput.positionNDC;
|
||||
|
||||
|
||||
#ifdef VARYINGS_NEED_POSITION_WS
|
||||
#ifdef VARYINGS_NEED_POSITION_WS
|
||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||
#else
|
||||
#else
|
||||
// Unused
|
||||
float3 V = float3(1.0, 1.0, 1.0); // Avoid the division by 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
|
||||
/* todo. these should be put int a struct */
|
||||
@@ -40,9 +44,9 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
|
||||
/* to here todo. these should be put int a struct */
|
||||
//v.2.0.4
|
||||
#ifdef _IS_TRANSCLIPPING_OFF
|
||||
//
|
||||
#elif _IS_TRANSCLIPPING_ON
|
||||
#ifdef _IS_TRANSCLIPPING_OFF
|
||||
//
|
||||
#elif _IS_TRANSCLIPPING_ON
|
||||
float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _ClippingMask));
|
||||
float Set_MainTexAlpha = _MainTex_var.a;
|
||||
float _IsBaseMapAlphaAsClippingMask_var = lerp(_ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask);
|
||||
@@ -50,16 +54,16 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float Set_Clipping = saturate((_Inverse_Clipping_var + _Clipping_Level));
|
||||
clip(Set_Clipping - 0.5);
|
||||
inverseClipping = _Inverse_Clipping_var;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
SHADOW_TYPE shadowAttenuation = lightLoopContext.shadowValue;
|
||||
//v.2.0.6
|
||||
//Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
|
||||
#if !defined (UTS_USE_RAYTRACING_SHADOW)
|
||||
#if !defined (UTS_USE_RAYTRACING_SHADOW)
|
||||
shadowAttenuation *= 2.0f;
|
||||
shadowAttenuation = saturate(shadowAttenuation);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float3 mainLightDirection = utsLightData.lightDirection;
|
||||
float3 mainLightColor = utsLightData.lightColor;
|
||||
@@ -90,22 +94,22 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base);
|
||||
float Set_BaseColorAlpha = _BaseColorVisible;
|
||||
float3 clippingColor = float3(1.0f, 1.0f, 1.0f);
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 1)
|
||||
{
|
||||
clippingColor = Set_BaseColor;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
|
||||
float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode);
|
||||
Set_BaseColor = lerp(Set_BaseColor, overridingColor, maskEnabled);
|
||||
Set_BaseColor = lerp(Set_BaseColor, overridingColor.rgb, maskEnabled);
|
||||
Set_BaseColor *= _BaseColorVisible;
|
||||
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
//v.2.0.5
|
||||
float4 _1st_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _1st_ShadeMap)), _MainTex_var, _Use_BaseAs1st);
|
||||
float3 _Is_LightColor_1st_Shade_var = lerp((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb), ((_1st_ShadeMap_var.rgb * _1st_ShadeColor.rgb) * Set_LightColor), _Is_LightColor_1st_Shade);
|
||||
@@ -114,7 +118,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
//v.2.0.6
|
||||
float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM));
|
||||
|
||||
float _SystemShadowsLevel_var = (shadowAttenuation *0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001;
|
||||
float _SystemShadowsLevel_var = (shadowAttenuation * 0.5f) + 0.5f + _Tweak_SystemShadowsLevel > 0.001f ? (shadowAttenuation * 0.5f)+0.5f+_Tweak_SystemShadowsLevel : 0.0001f;
|
||||
|
||||
float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r + _Tweak_ShadingGradeMapLevel : 1;
|
||||
|
||||
@@ -162,23 +166,23 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
|
||||
|
||||
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 2)
|
||||
{
|
||||
clippingColor = _Is_LightColor_1st_Shade_var;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_FirstShadeMaskColor, float4(_FirstShadeMaskColor.w, _FirstShadeMaskColor.w, _FirstShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_FirstShadeOverridden, _ComposerMaskMode);
|
||||
_Is_LightColor_1st_Shade_var = lerp(_Is_LightColor_1st_Shade_var, overridingColor, maskEnabled);
|
||||
_Is_LightColor_1st_Shade_var = lerp(_Is_LightColor_1st_Shade_var, overridingColor.rgb, maskEnabled);
|
||||
_Is_LightColor_1st_Shade_var = lerp(_Is_LightColor_1st_Shade_var, Set_BaseColor, 1.0f - _FirstShadeVisible);
|
||||
}
|
||||
float Set_1st_ShadeAlpha = _FirstShadeVisible;
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 _BaseColor_var = lerp(Set_BaseColor, _Is_LightColor_1st_Shade_var, Set_FinalShadowMask);
|
||||
//v.2.0.5
|
||||
float4 _2nd_ShadeMap_var = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_BaseColorMap,TRANSFORM_TEX(Set_UV0, _2nd_ShadeMap)), _1st_ShadeMap_var, _Use_1stAs2nd);
|
||||
@@ -186,14 +190,14 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float Set_ShadeShadowMask = saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - 1).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask)))); // 1st and 2nd Shades Mask
|
||||
//Composition: 3 Basic Colors as Set_FinalBaseColor
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 Set_FinalBaseColor;
|
||||
{
|
||||
float4 overridingColor = lerp(_SecondShadeMaskColor, float4(_SecondShadeMaskColor.w, _SecondShadeMaskColor.w, _SecondShadeMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_SecondShadeOverridden, _ComposerMaskMode);
|
||||
|
||||
float3 _Is_LightColor_2nd_Shade_var = lerp((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade);
|
||||
_Is_LightColor_2nd_Shade_var = lerp(_Is_LightColor_2nd_Shade_var, overridingColor, maskEnabled);
|
||||
_Is_LightColor_2nd_Shade_var = lerp(_Is_LightColor_2nd_Shade_var, overridingColor.rgb, maskEnabled);
|
||||
_Is_LightColor_2nd_Shade_var = lerp(_Is_LightColor_2nd_Shade_var, Set_BaseColor, 1.0f - _SecondShadeVisible);
|
||||
float Set_2nd_ShadeAlpha = _SecondShadeVisible;
|
||||
Set_FinalBaseColor =
|
||||
@@ -206,7 +210,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
#else
|
||||
float3 Set_FinalBaseColor =
|
||||
lerp(_BaseColor_var,
|
||||
lerp(_Is_LightColor_1st_Shade_var,
|
||||
@@ -214,19 +218,19 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
, _Is_LightColor_2nd_Shade)
|
||||
, Set_ShadeShadowMask)
|
||||
, Set_FinalShadowMask);
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
#endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
|
||||
float albedoIntensity = max(0.1, (1 - sqrt(surfaceData.metallic)) * (1.7 - 0.7 * (1 - sqrt(surfaceData.metallic))));
|
||||
Set_FinalBaseColor = Set_FinalBaseColor * albedoIntensity;
|
||||
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 3)
|
||||
{
|
||||
clippingColor = lerp((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb), ((_2nd_ShadeMap_var.rgb * _2nd_ShadeColor.rgb) * Set_LightColor)
|
||||
, _Is_LightColor_2nd_Shade);
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
|
||||
float4 _Set_HighColorMask_var = tex2D(_Set_HighColorMask, TRANSFORM_TEX(Set_UV0, _Set_HighColorMask));
|
||||
|
||||
@@ -237,14 +241,14 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
//Composition: 3 Basic Colors and HighColor as Set_HighColor
|
||||
float3 _HighColorWithOutTweak_var = lerp((_HighColor_Tex_var.rgb * _HighColor.rgb), ((_HighColor_Tex_var.rgb * _HighColor.rgb) * Set_LightColor), _Is_LightColor_HighColor);
|
||||
float3 _HighColor_var = _HighColorWithOutTweak_var * _TweakHighColorMask_var;
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 4)
|
||||
{
|
||||
clippingColor = _HighColorWithOutTweak_var;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
float3 Set_HighColor;
|
||||
{
|
||||
float4 overridingColor = lerp(_HighlightMaskColor, float4(_HighlightMaskColor.w, _HighlightMaskColor.w, _HighlightMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
@@ -261,13 +265,13 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
Set_HighColor += addColor;
|
||||
if (any(addColor))
|
||||
{
|
||||
Set_HighColor = lerp(Set_HighColor, overridingColor, maskEnabled);
|
||||
Set_HighColor = lerp(Set_HighColor, overridingColor.rgb, maskEnabled);
|
||||
channelOutAlpha = _HighlightVisible;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else
|
||||
float3 Set_HighColor = (lerp(SATURATE_IF_SDR((Set_FinalBaseColor - _TweakHighColorMask_var)), Set_FinalBaseColor, lerp(_Is_BlendAddToHiColor, 1.0, _Is_SpecularToHighColor)) + lerp(_HighColor_var, (_HighColor_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
float4 _Set_RimLightMask_var = tex2D(_Set_RimLightMask, TRANSFORM_TEX(Set_UV0, _Set_RimLightMask));
|
||||
@@ -284,7 +288,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float _ApRimLightPower_var = pow(_RimArea_var, exp2(lerp(3, 0, _Ap_RimLight_Power)));
|
||||
//Composition: HighColor and RimLight as _RimLight_var
|
||||
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef UTS_LAYER_VISIBILITY
|
||||
|
||||
float4 overridingRimColor = lerp(_RimLightMaskColor, float4(_RimLightMaskColor.w, _RimLightMaskColor.w, _RimLightMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskRimEnabled = max(_RimLightOverridden, _ComposerMaskMode);
|
||||
@@ -310,7 +314,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
|
||||
_RimLight_var = lerp(_RimLight_var, (_RimLight_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow);
|
||||
|
||||
#else
|
||||
#else
|
||||
float3 Set_RimLight = (saturate((_Set_RimLightMask_var.g + _Tweak_RimLightMaskLevel)) * lerp(_LightDirection_MaskOn_var, (_LightDirection_MaskOn_var + (lerp(_Ap_RimLightColor.rgb, (_Ap_RimLightColor.rgb * Set_LightColor), _Is_LightColor_Ap_RimLight) * saturate((lerp((0.0 + ((_ApRimLightPower_var - _RimLight_InsideMask) * (1.0 - 0.0)) / (1.0 - _RimLight_InsideMask)), step(_RimLight_InsideMask, _ApRimLightPower_var), _Ap_RimLight_FeatherOff) - (saturate(_VertHalfLambert_var) + _Tweak_LightDirection_MaskLevel))))), _Add_Antipodean_RimLight));
|
||||
Set_RimLight *= _RimLight_Strength;
|
||||
float3 _RimLight_var;
|
||||
@@ -324,7 +328,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
}
|
||||
|
||||
_RimLight_var = lerp(_RimLight_var, (_RimLight_var * ((1.0 - Set_FinalShadowMask) + (Set_FinalShadowMask * _TweakHighColorOnShadow))), _Is_UseTweakHighColorOnShadow);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//Matcap
|
||||
//v.2.0.6 : CameraRolling Stabilizer
|
||||
@@ -394,17 +398,17 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float3 matCapColorOnMultiplyMode = Set_HighColor * (1 - _Tweak_MatcapMaskLevel_var_MultiplyMode) + Set_HighColor * Set_MatCap * _Tweak_MatcapMaskLevel_var_MultiplyMode + lerp(float3(0, 0, 0), Set_RimLight, _RimLight);
|
||||
float3 matCapColorFinal = lerp(matCapColorOnMultiplyMode, matCapColorOnAddMode, _Is_BlendAddToMatCap);
|
||||
//v.2.0.4
|
||||
#ifdef _IS_ANGELRING_OFF
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
#ifdef _IS_ANGELRING_OFF
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 5)
|
||||
{
|
||||
clippingColor = float3(0.0f,0.0f,0.0f);
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
float3 diffuseTerm = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before Emissive
|
||||
//
|
||||
#elif _IS_ANGELRING_ON
|
||||
#elif _IS_ANGELRING_ON
|
||||
float3 diffuseTerm = lerp(_RimLight_var, matCapColorFinal, _MatCap);// Final Composition before AR
|
||||
//v.2.0.7 AR Camera Rolling Stabilizer
|
||||
float3 _AR_OffsetU_var = lerp(mul(UNITY_MATRIX_V, float4(utsData.normalDirection, 0)).xyz, float3(0, 0, 1), _AR_OffsetU);
|
||||
@@ -418,7 +422,7 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
float Set_ARtexAlpha = _AngelRing_Sampler_var.a;
|
||||
float3 Set_AngelRingWithAlpha = (_Is_LightColor_AR_var * _AngelRing_Sampler_var.a);
|
||||
//Composition: MatCap and AngelRing as diffuseTerm
|
||||
# ifdef UTS_LAYER_VISIBILITY
|
||||
# ifdef UTS_LAYER_VISIBILITY
|
||||
{
|
||||
float4 overridingColor = lerp(_AngelRingMaskColor, float4(_AngelRingMaskColor.w, _AngelRingMaskColor.w, _AngelRingMaskColor.w, 1.0f), _ComposerMaskMode);
|
||||
float maskEnabled = max(_AngelRingOverridden, _ComposerMaskMode);
|
||||
@@ -431,24 +435,23 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
channelOutAlpha = _AngelRingVisible;
|
||||
}
|
||||
}
|
||||
# else
|
||||
# else
|
||||
diffuseTerm = lerp(diffuseTerm, lerp((diffuseTerm + Set_AngelRing), ((diffuseTerm * (1.0 - Set_ARtexAlpha)) + Set_AngelRingWithAlpha), _ARSampler_AlphaOn), _AngelRing);// Final Composition before Emissive
|
||||
# endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
# endif //#ifdef UTS_LAYER_VISIBILITY
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode == 5)
|
||||
{
|
||||
clippingColor = _Is_LightColor_AR_var;
|
||||
return clippingColor;
|
||||
}
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
#endif // _IS_CLIPPING_MATTE
|
||||
//diffuseTerm = Set_AngelRing * 10 * (1 - Set_FinalShadowMask);
|
||||
#endif //#ifdef _IS_ANGELRING_OFF
|
||||
#endif //#ifdef _IS_ANGELRING_OFF
|
||||
|
||||
// PBR----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//Specular Term
|
||||
float3 specularTerm = ComputeSpecularTerm(V, lightDirection, bsdfData) * (1 - Set_FinalShadowMask) * PI * surfaceData.specularColor * Set_LightColor * utsLightData.specularDimmer;
|
||||
//specularTerm = saturate(specularTerm);
|
||||
|
||||
//SSS
|
||||
if (_Use_SSSLut == 1)
|
||||
@@ -461,10 +464,8 @@ void UTS_MainLight(LightLoopContext lightLoopContext, FragInputs input, UTSLight
|
||||
|
||||
diffuseTerm = diffuseTerm * utsLightData.diffuseDimmer;
|
||||
|
||||
//float3 finalColor = diffuseTerm + specularTerm + emissive;
|
||||
|
||||
utsAggregateLighting.directDiffuse += diffuseTerm;
|
||||
utsAggregateLighting.directSpecular += specularTerm;
|
||||
|
||||
//return finalColor;
|
||||
#endif // _SDFShadow
|
||||
}
|
||||
@@ -6,6 +6,9 @@
|
||||
void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLightData utsLightData, SurfaceData surfaceData, BSDFData bsdfData, int lightType, float3 i_normalDir, float notDirectional, out float channelOutAlpha, inout UTSAggregateLighting utsAggregateLighting)
|
||||
{
|
||||
channelOutAlpha = 1.0f;
|
||||
|
||||
// We dont have to calculate lighting here if we are using sdf shadow
|
||||
#ifndef _SDFShadow
|
||||
#ifdef _IS_CLIPPING_MATTE
|
||||
if (_ClippingMatteMode != 0)
|
||||
{
|
||||
@@ -249,11 +252,8 @@ void UTS_OtherLights(LightLoopContext lightLoopContext, FragInputs input, UTSLig
|
||||
|
||||
specularTerm = specularTerm * (1.0 - Set_FinalShadowMask) * PI * surfaceData.specularColor;
|
||||
diffuseTerm = diffuseTerm * albedoIntensity;
|
||||
|
||||
//float3 finalColor = diffuseTerm + specularTerm;
|
||||
|
||||
utsAggregateLighting.directDiffuse += diffuseTerm;
|
||||
utsAggregateLighting.directSpecular += specularTerm;
|
||||
|
||||
//return finalColor;
|
||||
#endif // _SDFShadow
|
||||
}
|
||||
@@ -6,6 +6,12 @@
|
||||
|
||||
#define fixed half
|
||||
|
||||
#define UNITY_TEXTURE_STREAMING_DEBUG_VARS
|
||||
float4 unity_MipmapStreaming_DebugTex_ST;
|
||||
float4 unity_MipmapStreaming_DebugTex_TexelSize;
|
||||
float4 unity_MipmapStreaming_DebugTex_MipInfo;
|
||||
float4 unity_MipmapStreaming_DebugTex_StreamInfo;
|
||||
|
||||
// Unity Toon Shader
|
||||
#include "UtsTextures.hlsl"
|
||||
|
||||
@@ -114,7 +120,6 @@ SAMPLER(sampler_LayerInfluenceMaskMap);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
|
||||
|
||||
#include "UtsUnityPerMaterial.hlsl"
|
||||
|
||||
// shared constant between lit and layered lit
|
||||
@@ -336,3 +341,11 @@ int _ObjectId;
|
||||
int _PassValue;
|
||||
|
||||
CBUFFER_END
|
||||
|
||||
float _Outline_MaxWidth;
|
||||
|
||||
float _HairShadowDistance;
|
||||
float _HairShadowDistanceScaleFactor;
|
||||
float _HairShadowDepthBias;
|
||||
float _HairShadowFadeInDistance;
|
||||
float _HairShadowFadeOutDistance;
|
||||
@@ -259,7 +259,6 @@ UTSLightData GetCustomMainLightData(BuiltinData builtinData, UTSLightData mainPu
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
utsLightData.lightColor = ApplyCurrentExposureMultiplier(_DirectionalLightDatas[mainLightIndex].color);
|
||||
utsLightData.lightDirection = -_DirectionalLightDatas[mainLightIndex].forward;
|
||||
utsLightData.diffuseDimmer = _DirectionalLightDatas[mainLightIndex].diffuseDimmer;
|
||||
|
||||
@@ -21,11 +21,7 @@ float _SDFShadowLevel;
|
||||
float _SDFSmoothGamma;
|
||||
float _SDFNoseHighlightCoef;
|
||||
float _SDFNoseHighlightSmoothRange;
|
||||
float _HairShadowDistance;
|
||||
float _HairShadowDistanceScaleFactor;
|
||||
float _HairShadowDepthBias;
|
||||
float _HairShadowFadeInDistance;
|
||||
float _HairShadowFadeOutDistance;
|
||||
|
||||
float _EyeParallaxAmount;
|
||||
float _EyeBrowBlendingFactor;
|
||||
|
||||
@@ -178,7 +174,6 @@ fixed _ARSampler_AlphaOn;
|
||||
// Unity Toon Shader Outline
|
||||
|
||||
float _Outline_Width;
|
||||
float _Outline_MaxWidth;
|
||||
float _Farthest_Distance;
|
||||
float _Nearest_Distance;
|
||||
float4 _Outline_Sampler_ST;
|
||||
@@ -205,5 +200,6 @@ float _ToonEvAdjustmentCompensation;
|
||||
#endif //#if !defined(_UTS_TOON_EV_PER_MODEL)
|
||||
|
||||
|
||||
float3 _ObjectCenter;
|
||||
float _BlendMode;
|
||||
float _BlendMode;
|
||||
|
||||
float3 _ObjectCenterPositionWS;
|
||||
Reference in New Issue
Block a user