LoginSignup
1
1

More than 5 years have passed since last update.

vs2010でmanaged directx その17

Posted at

概要

c#で、3Dやりたかった。
レイトレやってみた。

写真

image

サンプルコード

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();
    }
}


以上。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1