ich versuche gerade meine Engine etwas schneller und schöner zu machen. V.a. erstmal schöner.
Problem ist, mein Shader ist ziemlich langsam. Und bei Shadern gibt es ja immer jede Menge Tücken, sodass selbst ein eigentlich äquivalenter Ausdruck plötzlich performanter wird. Daher hoffe ich auf eure Erfahrung!
Hier mein Shader für einfaches Vertexskinning über BoneMatrices:
Code: Alles auswählen
struct inner
{
float4 position : POSITION;
float4 color : COLOR;
float3 normal : NORMAL;
float4 texCoords : TEXCOORD0;
float3 boneWeights : TEXCOORD1;
float4 boneIndices : TEXCOORD2;
};
struct outer
{
float4 position : POSITION;
float4 color : COLOR;
float4 texCoords : TEXCOORD0;
};
outer main(inner IN,
uniform float4x4 ModelViewProj,
uniform float4 BoneMatrices[120]
)
{
outer OUT;
float3 objPos;
float4 allWeights = float4(IN.boneWeights, 1.0f - IN.boneWeights.x - IN.boneWeights.y - IN.boneWeights.z);
for(float n = 0; n < 4; ++n)
{
float3x4 matrix = float3x4( BoneMatrices[IN.boneIndices[n] * 3],
BoneMatrices[IN.boneIndices[n] * 3 + 1],
BoneMatrices[IN.boneIndices[n] * 3 + 2]);
objPos+= mul(matrix, IN.position) * allWeights[n];
}
OUT.position = mul(ModelViewProj, float4(objPos, 1));
OUT.color = IN.color;
OUT.texCoords = IN.texCoords;
return OUT;
}
Ok, also es sind an sich schon nur 50 FPS und die werden bei eingeschalteter Animation dann zu 22. Wenn ich im Vollbild laufen lasse, habe ich um die 200 FPS, aber es geht trotzdem auf 22 oder so runter. =/