What I’m doing:
I’m blending 2 frames to get a resulting tween… I do that for 2 different animations and then blend those together to get a final blended animation tween. Works great in software.
Question:
I’m wondering how to set it up so that I can have each frame in a different vertex buffer and then blend together in the shader. I did it but in the shader it is only receiving data for anything in the first vertex buffer. Here’s what I did:
// S E T B U F F E R S
int a1 = playerDesc.animation1, a2 = playerDesc.animation2;
int f1 = playerDesc.frame_1, f2 = playerDesc.frame_2;
vertbuffs[0] = sys[a1].obj[o].MeshList[f1].vbuf_bind; // works
vertbuffs[1] = sys[a1].obj[o].MeshList[f2].vbuf_bind; // not working
vertbuffs[2] = sys[a2].obj[o].MeshList[f1].vbuf_bind; // "
vertbuffs[3] = sys[a2].obj[o].MeshList[f2].vbuf_bind; // "
gpu.SetVertexBuffers(vertbuffs);
gpu.Indices = sys[0].obj[o].MeshList[0].ibuf;
// applies textures, lighting, etc:
light.SetDrawParams(world, cam, mat, playerDesc.frame_tween, playerDesc.anim_tween);
// D R A W
gpu.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, start_index, triangle_count);
I’ve seen mentioned that I may need to add channels to a vertex declaration but then would I need to fill those elements with different data for each frame? Hoping to avoid something like that ;p
Shader takes these:
struct VS_In
{
float4 Position1: POSITION0;
float4 Position2: POSITION1;
float4 Position3: POSITION2;
float4 Position4: POSITION3;
float4 Normal1 : NORMAL0;
float4 Normal2 : NORMAL1;
float4 Normal3 : NORMAL2;
float4 Normal4 : NORMAL3;
float2 UV: TEXCOORD0;
};
Pretty sure everything else works fine - just that Position 2-4 seem to have nothing in them when it gets into the shader.
Probably something about vertex declaration where I need more channels?
Or maybe something needs to be enabled?
Btw - I’ve never used lerp in shader - I’m using 0-1 for tweens. This should be correct right?
// tween frames and then blend different animations (for positions):
float4 p1 = lerp(input.Position1, input.Position2, frame_tween);
float4 p2 = lerp(input.Position3, input.Position4, frame_tween);
float4 position = lerp(p1, p2, anim_tween);
// tween frames and then blend different animations (for normals):
p1 = lerp(input.Normal1, input.Normal2, frame_tween);
p2 = lerp(input.Normal3, input.Normal4, frame_tween);
float4 normal = lerp(p1, p2, anim_tween);