Hello.
I have this shader test, originally in HLSL and DirectX, now I tried to convert it to OpenGL and CG.
Is an animation shaders for skinned. I try to set the skinnedmatrix to identity for get the mesh that are equal to as is, without weights and without indexes.
The problem is that appear different stretch and lengthened.
What can 'be?
the same shaders in DirectX HLSL and working properly.
Could be the world view and projection matrices?
work differently in OpenGL?
Thank you.
uniform float4 skinnedMatricesVS20[80*3];
uniform float4 CameraModelPosition;
uniform float4x4 WMatrix;
uniform float4x4 WVPMatrix;
uniform float4x4 VPMatrix;
struct VS_IN
{
float3 pos : POSITION;
float4 blendWeights : TEXCOORD0;
float4 blendIndices : TEXCOORD1;
float3 normalL : NORMAL;
};
struct VS_OUT
{
float4 posH : POSITION;
float3 posW ;
float3 normalW ;
float2 texC : TEXCOORD;
};
float4x4 RebuildSkinMatrix(float index)
{
float4x4 mx;
float4 a = skinnedMatricesVS20[index*3+0];
float4 b = skinnedMatricesVS20[index*3+1];
float4 c = skinnedMatricesVS20[index*3+2];
mx = float4x4(
a,
b,
c,
float4(0, 0, 0, 1));
return mx;
}
VS_OUT v_Skin3(VS_IN vIn)
{
VS_OUT vOut ;
// First transform position with bones that affect this vertex
// Use the 3 indices and blend weights we have precalculated.
float4x4 skinMatrix =
RebuildSkinMatrix(vIn.blendIndices.x) * vIn.blendWeights.x +
RebuildSkinMatrix(vIn.blendIndices.y) * vIn.blendWeights.y +
RebuildSkinMatrix(vIn.blendIndices.z) * vIn.blendWeights.z;
skinMatrix[0] = float4(1,0,0,0);
skinMatrix[1] = float4(0,1,0,0);
skinMatrix[2] = float4(0,0,1,0);
skinMatrix[3] = float4(0,0,0,1);
// Calculate local world matrix with help of the skinning matrix
float4x4 localWorld = mul(WMatrix, skinMatrix);
float4x4 matrixx = RebuildSkinMatrix(0);
// Now calculate final screen position with world and viewProj matrices.
float4 worldPos = mul(localWorld, float4(vIn.pos, 1));
vOut.posH = mul(worldPos, VPMatrix);
vOut.posW = mul(worldPos, VPMatrix);
return vOut;
}
float4 p_Skin3(VS_OUT pIn) :COLOR
{
return float4(1,0,0,1);
};