「MonoGameでHLSLにMatrixを渡す」の版間の差分

編集の要約なし
編集の要約なし
31行目: 31行目:
</syntaxhighlight>
</syntaxhighlight>


HLSL側はfloat4が4個で受け取り、シェーダー関数内でmatrixに合成している。
HLSL側は「float4が4個」として受け取り、[[バーテックスシェーダー]]内でmatrixに合成している。
<syntaxhighlight lang="hlsl">
<syntaxhighlight lang="hlsl">
// 「float4が4個」として受け取る。
// 「float4が4個」として受け取る。
struct InstanceInput  
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;
};
};


46行目: 46行目:
     VertexShaderOutput output = (VertexShaderOutput)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);


     // 〜以下略〜
     // 〜以下略〜