【问题标题】:HLSL: Cut a texture radiallyHLSL:径向切割纹理
【发布时间】:2015-08-31 17:33:10
【问题描述】:

我目前有一个像素着色器:

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度一个? 谢谢。

【问题讨论】:

    标签: hlsl


    【解决方案1】:

    我建议使用内在的 atan2 (doc)(wiki) 来计算片段相对于圆心的角度,然后像距离剪辑一样进行剪辑。

    【讨论】:

    • 谢谢!解决了这个问题:float degree = -180 + dg; if (radians(degree) &gt; atan2(dy,dx)) return color; else ...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 2014-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多