HLSL:径向切割纹理

时间:2015-08-31 08:35:34

标签: hlsl

我目前正在使用像素着色器:

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0   
{

float4 color = tex2D(Sampler0,coords);
float dx = coords.x - 0.5f;
float dy = coords.y - 0.5f;

float tpos = dx * dx + dy * dy;
if(tpos <= 0.25f && tpos > 0.25f-width )
    return color;
else
    return float4(0.0f, 0.0f, 0.0f, 0.0f);
}

这样我就能画一个圆圈。但是我该如何剪切圆圈,例如画30度圈?还是60度一个? 感谢。

1 个答案:

答案 0 :(得分:1)

我建议使用内在atan2doc)(wiki)来计算片段相对于圆心的角度,然后像你的距离一样剪裁削波。

相关问题