URP 接入 Geometric Specular Anti-aliasing
HDRP/Lit中是带了这项功能
1
2
3
4
5
6
7
8
9
//shader..
[Toggle_Switch] _ENABLE_GEOMETRIC_SPECULAR_AA("高光抗锯齿", float) = 0
[Switch(_ENABLE_GEOMETRIC_SPECULAR_AA)] _SpecularAAScreenSpaceVariance("SpecularAAScreenSpaceVariance", Range(0.0, 1.0)) = 0.1
[Switch(_ENABLE_GEOMETRIC_SPECULAR_AA)] _SpecularAAThreshold("SpecularAAThreshold", Range(0.0, 1.0)) = 0.2
..修改smoothness
surfaceData.smoothness = GeometricNormalFiltering(surfaceData.smoothness, inputData.normalWS, _SpecularAAScreenSpaceVariance, _SpecularAAThreshold);
还可以这样做
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
half3 GlassGlobalIllumination(BRDFData brdfData, BRDFData brdfDataClearCoat, float clearCoatMask,
half3 bakedGI, half occlusion, float3 positionWS,
half3 normalWS, half3 viewDirectionWS)
{
half3 reflectVector = reflect(-viewDirectionWS, normalWS);
half NoV = saturate(dot(normalWS, viewDirectionWS));
// TODO 改成Pow5
half fresnelTerm = Pow4(1.0 - NoV) * (1.0 - NoV);
// 抗锯齿奇淫技巧
#define _SpecularAAThreshold 1
fresnelTerm = GeometricNormalFiltering(fresnelTerm, normalWS, _SpecularAAScreenSpaceVariance, _SpecularAAThreshold);
fresnelTerm = saturate(fresnelTerm);
half3 indirectDiffuse = bakedGI;
// 间接镜面反射自定义
half3 indirectSpecular = GlassGlossyEnvironmentReflection(reflectVector, positionWS, brdfData.perceptualRoughness, 1.0h);
half3 color = EnvironmentBRDF(brdfData, indirectDiffuse, indirectSpecular, fresnelTerm);
return color * occlusion;
}
本文由作者按照 CC BY 4.0 进行授权

