[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
プログラミング、3DCGとその他いろいろについて
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
| メンバ名 | 説明 |
| Zero | × 0 |
| One | × 1 |
| SourceColor |
× "これから描くポリゴンの色" ※正確には掛け算と言うより、「それぞれの色の要素が”これから書くポリゴンの色”の対応する色の要素倍される」です。 例えば、(1, 1, 1)と(0.1, 0.2, 0.3)なら(0.1, 0.2, 0.3)。 (0.1, 0.2, 0.3)と(0.1, 0.2, 0.3)なら(0.01, 0.04, 0.09) |
| InverseSourceColor | × (白 - "これから描くポリゴンの色") |
| SourceAlpha | × "これから描くポリゴンの不透明度" |
| InverseSourceAlpha | × (1 - "これから描くポリゴンの不透明度") |
| DestinationAlpha | × "背景の不透明度" |
| InverseDestinationAlpha | × (1 - "背景の不透明度") |
| DestinationColor | × 背景の色 |
| InverseDestinationColor | × (白 - "背景の色") |
| SourceAlphaSaturation | × Min("これから描くポリゴンの不透明度", 1 - 描画前の不透明度) |
| BothInverseSourceAlpha |
これはDestinationBlendプロパティにセットする必要はありません。これをSourceBlendプロパティにセットするとDestinationBlendの中身は上書きされます(ただしプロパティの値には反映されず、Zeroのままですが)。 この値をセットすると、 最終的な色 = 描画前の色 × 描画するポリゴンの不透明度 + 描画するポリゴンの色 × (1 - 描画するポリゴンの不透明度) となります。 |
| BlendFactor | × "RenderState.BlendFactorプロパティにセットした色" |
| InverseBlendFactor |
× (白 - "RenderState.BlendFactorプロパティにセットした色") ただしこのモードは、GraphicsDeviceCapabilitiesクラスでSourceBlendCapabilitiesプロパティかDestinationBlendCapabilitiesプロパティのSupportsBlendFactorプロパティ(こいつはgetだけでsetはできません)がtrueのときにしか使えません。 |
| BothSourceAlpha | Obsoleteです。他のメンバを使いましょう。 |
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
class Triangle
{
VertexPositionColor[] vertices = new VertexPositionColor[3];
public Triangle(Vector3 p1, Vector3 p2, Vector3 p3, Color color)
{
vertices[0] = new VertexPositionColor(p1, color);
vertices[1] = new VertexPositionColor(p2, color);
vertices[2] = new VertexPositionColor(p3, color);
}
public void Draw(GraphicsDevice graphicsDevice, BasicEffect effect)
{
graphicsDevice.VertexDeclaration = new VertexDeclaration(
graphicsDevice,
VertexPositionColor.VertexElements);
effect.VertexColorEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(
PrimitiveType.TriangleList,
vertices,
0,
1
);
pass.End();
}
effect.End();
}
}
class MyGame : Game
{
GraphicsDeviceManager graphics;
BasicEffect basicEffect;
Triangle redTriangle = new Triangle(
new Vector3(1, 0.5f, -1),
new Vector3(0, -1, -1),
new Vector3(-1, 0.5f, -1),
Color.Red
);
public MyGame()
{
graphics = new GraphicsDeviceManager(this);
}
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
basicEffect = new BasicEffect(graphics.GraphicsDevice, null);
basicEffect.View = Matrix.CreateLookAt(
new Vector3(0, 0, 3),
new Vector3(0, 0, 0),
new Vector3(0, 1, 0)
);
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45),
Window.ClientBounds.Width / (float)Window.ClientBounds.Height,
1, 100
);
}
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.One;
redTriangle.Draw(graphics.GraphicsDevice, basicEffect);
}
}
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
class Triangle
{
VertexPositionColor[] vertices = new VertexPositionColor[3];
public Triangle(Vector3 p1, Vector3 p2, Vector3 p3, Color color)
{
vertices[0] = new VertexPositionColor(p1, color);
vertices[1] = new VertexPositionColor(p2, color);
vertices[2] = new VertexPositionColor(p3, color);
}
public void Draw(GraphicsDevice graphicsDevice, BasicEffect effect)
{
graphicsDevice.VertexDeclaration = new VertexDeclaration(
graphicsDevice,
VertexPositionColor.VertexElements);
effect.VertexColorEnabled = true;
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Begin();
graphicsDevice.DrawUserPrimitives<VertexPositionColor>(
PrimitiveType.TriangleList,
vertices,
0,
1
);
pass.End();
}
effect.End();
}
}
class MyGame : Game
{
GraphicsDeviceManager graphics
BasicEffect basicEffect;
Triangle redTriangle = new Triangle(
new Vector3(1, 0.5f, -1),
new Vector3(0, -1, -1),
new Vector3(-1, 0.5f, -1),
new Color(255, 0, 0, 20)
);
public MyGame()
{
graphics = new GraphicsDeviceManager(this);
}
protected override void LoadGraphicsContent(bool loadAllContent)
{
if (loadAllContent)
{
basicEffect = new BasicEffect(graphics.GraphicsDevice, null);
basicEffect.View = Matrix.CreateLookAt(
new Vector3(0, 0, 3),
new Vector3(0, 0, 0),
new Vector3(0, 1, 0)
);
basicEffect.Projection = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45),
Window.ClientBounds.Width / (float)Window.ClientBounds.Height,
1, 100
);
}
}
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
graphics.GraphicsDevice.RenderState.AlphaBlendEnable = true;
graphics.GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
graphics.GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
redTriangle.Draw(graphics.GraphicsDevice, basicEffect);
}
}