三平方の定理で円を色分け
Code: return MyFunction(texCoord,resolution,R,A,B);
OutputType:Float4
Inputs: texCoord,resolution,R,A,B
Input File Paths: /Project/Circle.usf
pow(V,2.0)でVの2乗って意味
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow
つかわないでみた。
float R2=p.x*p.x+p.y*p.y;//三平方の定理
//Circle.usf
//return MyFunction(texCoord,resolution,R,A,B);
float4 MyFunction(float2 texCoord,float2 resolution,float R,float4 A,float4 B)
{
float2 p = (texCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
//return float3(p.x,p.y,1.0);
//float R=0.5;
//float4 c = float4(1.0,1.0,1.0,1.0);// baseColor
float4 c =A;// baseColor
float R2=p.x*p.x+p.y*p.y;//三平方の定理
//if(pow(p.x,2.0) + pow(p.y,2.0) <= R){
if(R2 <= R){
// c = float4(0.0,0.0,0.0,0.0); //circleColor
c = B;//circleColor
}
return c;
}
参考
コメント