• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

#1lucky6969b  Members

1190
Like
0Likes
Like

Posted 19 August 2012 - 09:52 PM

////////////////////////////////////////////////////////////////////////////
extern float4x4 FinalTransforms[100];
extern int NumVertInfluences = 2; // <--- Normally set dynamically.
//Vertex Input
struct VS_INPUT_SKIN
{
float4 position : POSITION0;
float3 normal   : NORMAL;
float2 tex0	 : TEXCOORD0;
float4 weights  : BLENDWEIGHT0;
int4   boneIndices : BLENDINDICES0;
};

float4 ps_lighting(VS_OUTPUT IN) : COLOR0
{
//float4 color = tex2D(DiffuseSampler, IN.tex0);
return IN.color;
}
VS_OUTPUT vs_Skinning(VS_INPUT_SKIN IN)
{
VS_OUTPUT OUT = (VS_OUTPUT)0;
float4 p = float4(0.0f, 0.0f, 0.0f, 1.0f);
float3 norm = float3(0.0f, 0.0f, 0.0f);
float lastWeight = 0.0f;
int n = NumVertInfluences-1;

IN.normal = normalize(IN.normal);

for(int i = 0; i < n; ++i)
{
lastWeight += IN.weights[i];
p += IN.weights[i] * mul(IN.position, FinalTransforms[IN.boneIndices[i]]);
norm += IN.weights[i] * mul(IN.normal, FinalTransforms[IN.boneIndices[i]]);
}
lastWeight = 1.0f - lastWeight;

p += lastWeight * mul(IN.position, FinalTransforms[IN.boneIndices[n]]);
norm += lastWeight * mul(IN.normal, FinalTransforms[IN.boneIndices[n]]);

p.w = 1.0f;
// matW is the world transform of the "whole" object
// where p is the object transform of the "part" object
float4 posWorld = mul(p, matW);
// matVP is the transform into view-projection space
OUT.position = mul(posWorld, matVP);
OUT.color = vMaterialColor;
OUT.tex0 = IN.tex0;

//Calculate Lighting
norm = normalize(norm);
norm = mul(norm, matW);
OUT.shade = max(dot(norm, normalize(lightPos - posWorld)), 0.2f);

return OUT;
}
technique Skinning
{
pass P0
{
Lighting = false;
AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;

}
}


In the above snippet, there is something wrong with rendering. The pixel shader is no doubt and is correct because I could use different vs and rendered correctly. However when it comes to skinning, it has some problems. First, the mesh cannot be scaled down and the vMaterialColor has no effect unlike the other technique that uses the same pixel shader. When I output just the color of the mesh, it should be okay to work without normals and since the lighting is turned off by default. In the C++ program, I can see the correct material values, it is in the "default" pose where i have actually posed and animated the character.

what is going on?
Thanks
Jack

#2Tordin  Members

604
Like
0Likes
Like

Posted 20 August 2012 - 01:53 AM

have you tried to use PIX? it could debugg a specific pixel for you and show you your output and from there you could see abit more whats causing the problem.

for(int i = 0; i < n; ++i)
{
lastWeight += IN.weights[i];
p += IN.weights[i] * mul(IN.position, FinalTransforms[IN.boneIndices[i]]);
norm += IN.weights[i] * mul(IN.normal, FinalTransforms[IN.boneIndices[i]]);
}
lastWeight = 1.0f - lastWeight;

p += lastWeight * mul(IN.position, FinalTransforms[IN.boneIndices[n]]);
norm += lastWeight * mul(IN.normal, FinalTransforms[IN.boneIndices[n]]);


what im not sure of here is why you after you have calulcated your local net transform, are again adding this
p += lastWeight * mul(IN.position, FinalTransforms[IN.boneIndices[n]]);


it´s like, adding bone 0 twice so you get extra much skinning from this joint.

Edited by Tordin, 20 August 2012 - 01:56 AM.

"There will be major features. none to be thought of yet"

#3lucky6969b  Members

1190
Like
0Likes
Like

Posted 20 August 2012 - 03:58 AM

Hi,
Ran PIX-64-bit. Got the following error
https://www.asuswebstorage.com/navigate/share/GYYAKUIM5Y

#4lucky6969b  Members

1190
Like
0Likes
Like

Posted 20 August 2012 - 03:59 AM

Basically my program runs except there are some memory leaks and crashes at the end of execution

#5Tordin  Members

604
Like
0Likes
Like

Posted 20 August 2012 - 07:16 AM

that hardens the problem some...

But why are you adding the first bone to the netpos after you have calculated the weighted netpos??
"There will be major features. none to be thought of yet"

#6lucky6969b  Members

1190
Like
0Likes
Like

Posted 21 August 2012 - 02:28 AM

You're correct after a deep thought. I need to clean that up later, now I want to concentrate on rendering.

#7Tordin  Members

604
Like
0Likes
Like

Posted 21 August 2012 - 07:15 AM

but... did you solve your problem?
"There will be major features. none to be thought of yet"

#8lucky6969b  Members

1190
Like
0Likes
Like

Posted 21 August 2012 - 09:37 PM

Can run PIX now. Locale problem... thanks

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.