概要
c#で、3Dやりたかった。
シェーダー書いてみた。
写真
サンプルコード
struct VS_IN {
float4 Pos: POSITION;
float4 color: COLOR;
};
struct VS_OUT {
float4 Pos: POSITION;
float4 color: COLOR;
float2 coord: TEXCOORD;
};
VS_OUT VSmain(VS_IN In)
{
VS_OUT output = (VS_OUT) 0;
output.Pos = In.Pos;
output.color = In.color;
output.coord = In.Pos.xy;
return output;
}
float4 PSmain(VS_OUT In): COLOR
{
float4 color = float4(1.0, 1.0, 1.0, 1.0);
float2 coord = In.coord;
float2 center = float2(0.0, 0.0);
float dist = distance(coord, center);
if (dist < 0.5) color = float4(1.0, 1.0, 1.0, 1.0);
else color = In.color;
return color;
}
technique MyTechnique
{
pass MyPass
{
VertexShader = compile vs_2_0 VSmain();
PixelShader = compile ps_2_0 PSmain();
}
}
以上。