Next-Generation Character Rendering https://leegoonz.blog/2020/08/24/dual-lobe-for-skin-shader-by-urp/
其实就是模拟了高频信息 现在粗糙度的那张贴图只需要画低频信息就行了
代码引用自 leegoonz
完整实现UE4里也有, leegoonz大佬应该是做了优化 这里我也做了些修改
half3 DirectBDRF_DualLobeSpecular(BRDFData brdfData, half3 normalWS, half3 lightDirectionWS, half3 viewDirectionWS,half mask, half lobeWeight)
{
float3 halfDir = SafeNormalize(float3(lightDirectionWS) + float3(viewDirectionWS));
float NoH = saturate(dot(normalWS, halfDir));
half LoH = saturate(dot(lightDirectionWS, halfDir));
float d = NoH * NoH * brdfData.roughness2MinusOne + 1.00001f;
half nv = saturate(dot(normalWS,lightDirectionWS));
half LoH2 = LoH * LoH;
float sAO = saturate(-0.3f + nv * nv);
sAO = lerp(pow(0.75, 8.00f), 1.0f, sAO);
half SpecularOcclusion = sAO;
half specularTermGGX = brdfData.roughness2 / ((d * d) * max(0.1h, LoH2) * brdfData.normalizationTerm);
half specularTermBeckMann =
(2.0 * (brdfData.roughness2) /
((d * d) * max(0.1h, LoH2) * brdfData.normalizationTerm)) * lobeWeight * mask;
half specularTerm = (specularTermGGX / 2 + specularTermBeckMann) * SpecularOcclusion ;
#if defined (SHADER_API_MOBILE) || defined (SHADER_API_SWITCH)
specularTerm = specularTerm - HALF_MIN;
specularTerm = clamp(specularTerm, 0.0, 100.0);
#endif
half3 color = specularTerm * brdfData.specular;
return color;
}
|