1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vs2010でmanaged directx その15

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


以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?