我正在尝试编写一个模糊屏幕中心然后逐渐消失的后期处理着色器。
感谢此处发布的一些代码,我有一个模糊的抗锯齿圆圈,但它位于屏幕的左上角。问题似乎出在我计算圆的算法中:
float4 PS_GaussianBlur(float2 texCoord : TEXCOORD) : COLOR0
{
float4 insideColor = float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 outsideColor = tex2D(colorMap, texCoord);
//Perform the blur:
for (int i = 0; i < KERNEL_SIZE; ++i)
insideColor += tex2D(colorMap, texCoord + offsets[i]) * weights[i];
float dist = (texCoord.x * texCoord.x) + (texCoord.y * texCoord.y);
float distFromCenter = .5 - dist; // positive when inside the circle
float thresholdWidth = 0.1; // a constant you'd tune to get the right level of softness
float antialiasedCircle = saturate((distFromCenter / thresholdWidth) + 0.5);
return lerp(outsideColor, insideColor, antialiasedCircle);
}
提前致谢!