float2 blurRadius = KernelSize / TextureSize;
float4 finalColor =Texture2DSample(Tex, TexSampler, UVs);
if(KernelSize==0){
return finalColor.a;
}
if(NumSamples==0){
return finalColor.a;
}
float2 newUV = UVs;
float alpha = 0;
for (int i=0;i<NumSamples;++i)
{
float2 pdf = CosineSampleHemisphere(Hammersley(i, NumSamples, 0)).xy;
float2 uvOffset = pdf * blurRadius;
float2 uvShifted = UVs + uvOffset;
float4 hitColor = Texture2DSample(Tex, TexSampler, saturate(uvShifted));
alpha += hitColor.a;
}
alpha = alpha/NumSamples;
if (alpha > finalColor.a)
{
return alpha;
}
return finalColor.a;
文章来源:https://www.toymoban.com/news/detail-543267.html
文章来源地址https://www.toymoban.com/news/detail-543267.html
到了这里,关于UE4滤镜:边缘模糊的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!