概要
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(0.0, 0.0, 0.0, 0.0);
float2 coord = In.coord;
float2 center = float2(0.0, 0.0);
float dist = distance(coord, center);
if (dist < 0.5)
{
center = float2(0.1, 0.1);
dist = 1.0 - distance(coord, center) * 2.0;
color = float4(1.0, dist, 0.0, 1.0);
}
return color;
}
technique MyTechnique
{
pass MyPass
{
VertexShader = compile vs_2_0 VSmain();
PixelShader = compile ps_2_0 PSmain();
}
}
以上。