Update custom pass to global custom pass
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user