差分

ナビゲーションに移動 検索に移動

頂点

2,501 バイト追加, 2018年8月31日 (金) 09:33
ページの作成:「'''頂点'''(英語:vertex)とは、ベクトル図形を描く際に用いられる制御点のことである。 == 概要 == 2つの頂点を...」
'''頂点'''([[英語]]:vertex)とは、[[ベクトル]]で[[図形]]を描く際に用いられる制御点のことである。

== 概要 ==
2つの頂点を使えば線を引ける。

3つの頂点を使えば面を描ける。いわゆる[[ポリゴン]]だ。

== 保持する情報 ==
3Dのポリゴンであれば頂点は最低限度の情報として「[[XYZ座標]]」を持つ。これがないと始まらない。その他にも陰影をつけるライティングに使用する「[[法線]]」や「[[頂点カラー]]」、[[テクスチャ]]を貼るための「[[UV座標]]」を持つこともある。

近代的な[[プログラマブルシェーダー]]であれば、頂点のデータ・フォーマットはある程度自由に定義することができる。たとえば[[MonoGame]]であれば以下のようにIVertexTypeインターフェースを継承すれば独自の頂点を定義できる。<syntaxhighlight lang="csharp">
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

public struct VertexPositionColorNormalTexture : IVertexType
{
public Vector3 Position;
public Color Color;
public Vector3 Normal;
public Vector2 TextureCoordinate;

public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration(
new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement((sizeof(float) * 3), VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement((sizeof(float) * 3) + (4), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement((sizeof(float) * 3 * 2) + (4), VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
);

public VertexPositionColorNormalTexture(Vector3 position, Color color, Vector3 normal, Vector2 textureCoordinate)
{
Position = position;
Color = color;
normal.Normalize();
Normal = normal;
TextureCoordinate = textureCoordinate;
}

VertexDeclaration IVertexType.VertexDeclaration
{
get { return VertexDeclaration; }
}
}
</syntaxhighlight>

== 関連項目 ==
* [[MonoGameで位置と色と法線とUV座標を持つカスタム頂点を使いたい]]
* [[バーテックスバッファ]]
* [[バーテックスシェーダー]]
* [[ジオメトリシェーダー]]
匿名利用者

案内メニュー