赞
踩
- 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;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。