メインメニューを開く

「MonoGameでHLSLにMatrixを渡す」を編集中

警告: ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。ログインまたはアカウントを作成すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。

この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。

最新版 編集中の文章
15行目: 15行目:
 
// 仕方がないので「Vector4が4個」と指定する。
 
// 仕方がないので「Vector4が4個」と指定する。
 
var vertexDeclaration = new VertexDeclaration(
 
var vertexDeclaration = new VertexDeclaration(
    new VertexElement( 0, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0),
+
        new VertexElement( 0, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0),
    new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 1),
+
        new VertexElement(16, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 1),
    new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 2),
+
        new VertexElement(32, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 2),
    new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 3));
+
        new VertexElement(48, VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 3));
  
 
// ダイナミックバーテックスバッファーを生成する
 
// ダイナミックバーテックスバッファーを生成する
31行目: 31行目:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
HLSL側は「float4が4個」として受け取り、[[バーテックスシェーダー]]内でmatrixに合成している。
+
HLSL側はfloat4が4個で受け取り、シェーダー関数内でmatrixに合成している。
 
<syntaxhighlight lang="hlsl">
 
<syntaxhighlight lang="hlsl">
 
// 「float4が4個」として受け取る。
 
// 「float4が4個」として受け取る。
struct VSInstance
+
struct InstanceInput
 
{
 
{
    float4 w1 : BLENDWEIGHT0;
+
float4 w1 : BLENDWEIGHT0;
    float4 w2 : BLENDWEIGHT1;
+
float4 w2 : BLENDWEIGHT1;
    float4 w3 : BLENDWEIGHT2;
+
float4 w3 : BLENDWEIGHT2;
    float4 w4 : BLENDWEIGHT3;
+
float4 w4 : BLENDWEIGHT3;
 
};
 
};
  
VSOutput VSMain(VSInput input, VSInstance instance)
+
VertexShaderOutput MainVS(VertexShaderInput input, InstanceInput instance)
 
{
 
{
     VSOutput output = (VSOutput)0;
+
     VertexShaderOutput output = (VertexShaderOutput)0;
  
    // 「float4が4個」をmatrixに合成する。
+
// 「float4が4個」をmatrixに変換する。
    matrix world = matrix(instance.w1, instance.w2, instance.w3, instance.w4);
+
matrix world = matrix(instance.w1, instance.w2, instance.w3, instance.w4);
  
 
     // 〜以下略〜
 
     // 〜以下略〜
 
 
     return output;
 
     return output;
 
}
 
}

MonoBookへの投稿はすべて、他の投稿者によって編集、変更、除去される場合があります。 自分が書いたものが他の人に容赦なく編集されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください(詳細はMonoBook:著作権を参照)。 著作権保護されている作品は、許諾なしに投稿しないでください!

このページを編集するには、下記の確認用の質問に回答してください (詳細):

取り消し 編集の仕方 (新しいウィンドウで開きます)