• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Saad Manzur

How to debug an fx file

26 posts in this topic

Hi, 

Can anyone tell me how to debug an fx file ? I have tried using gpu perfstudio, PIX and visual studio ultimate 2013 but all of them gives me an error when I try to debug..

0

Share this post


Link to post
Share on other sites

Be a little bit more specific, what kind of error do you get? Which version of DirectX, 9 or newer?

 

For visual studio ultimate 2013, alt+f5 will start application in diagnstic mode, there you press print screen (not sure if was prt sc), close application and you get a lot of stuff. You either need to go through even list to find draw call you want to debug or pick pixel and check it's history.

 

Note:

What I wrote here is from memory, I mostly use built in profiler instinctively :) For more accurate information, check this link:

http://msdn.microsoft.com/en-us/library/hh873207.aspx#fbid=cfoh58W0Z1l

0

Share this post


Link to post
Share on other sites

I used that graphics debugger and most recently I have noticed one thing in the output window. This message is kept showing the whole time : 

 

1. ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (WEIGHTS,0) as input, but it is not provided by the output stage.

2. ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (BONEINDICES,0) as input, but it is not provided by the output stage.

 

My vertex structure is :

 

struct PosNormalTexSkin
	{
		XMFLOAT3 Pos;
		XMFLOAT3 Normal;
		XMFLOAT2 Tex;
		float Weights[3];
		UINT BoneIndices[4];
	};

And my input layout is :

 

const D3D11_INPUT_ELEMENT_DESC InputLayoutDesc::PosNormalTexSkin[5] = 
{
	{"POSITION",     0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0},
	{"NORMAL",       0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
	{"TEXCOORD",     0, DXGI_FORMAT_R32G32_FLOAT,    0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
	{"WEIGHTS",      0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0},
	{"BONEINDICES",  0, DXGI_FORMAT_R32G32B32A32_UINT, 0, 44, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
And my skinning code is :

# include "LightHelper.fx"

cbuffer cbPerFrame
{
	DirectionalLight gDirLights[3];
	float3 gEyePosW;
	float gFogStart;
	float gFogRange;
	float4 gFogColor;
};

cbuffer cbPerObject
{
	float4x4 gWorld;
	float4x4 gWorldInvTranspose;
	float4x4 gWorldViewProj;
	float4x4 gTexTransform;
	Material gMaterial;
};

cbuffer cbSkinned
{
	float4x4 gBoneTransforms[96];
};

Texture2D gDiffuseMap;

SamplerState samAnisotropic
{
	Filter = ANISOTROPIC;
	MaxAnisotropy = 4;

	AddressU = WRAP;
	AddressV = WRAP;
};

struct VertexIn
{
	float3 PosL : POSITION;
	float3 NormalL : NORMAL;
	float2 Tex : TEXCOORD;
};

struct SkinnedVertexIn
{
	float3 PosL : POSITION;
	float3 NormalL : NORMAL;
	float2 Tex : TEXCOORD;
	float3 Weights : WEIGHTS;
	uint4 BoneIndices : BONEINDICES;
};

struct VertexOut
{
	float4 PosH : SV_POSITION;
	float3 PosW : POSITION;
	float3 NormalW : NORMAL;
	float2 Tex : TEXCOORD;
};


VertexOut VS(VertexIn vin)
{
	VertexOut vout;

	vout.PosW = mul(float4(vin.PosL, 1.0f), gWorld).xyz;
	vout.NormalW = mul(vin.NormalL, (float3x3) gWorldInvTranspose);

	vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj);
	vout.Tex = mul(float4(vin.Tex, 0.0f, 1.0f), gTexTransform).xy;
	
	return vout;
}

VertexOut SkinnedVS(SkinnedVertexIn vin)
{
	VertexOut vout;

	float weights[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
	weights[0] = vin.Weights.x;
	weights[1] = vin.Weights.y;
	weights[2] = vin.Weights.z;
	weights[3] = 1.0f - vin.Weights.x - vin.Weights.y - vin.Weights.z;
	
	float3 posL = float3(0.0f, 0.0f, 0.0f);
	float3 normalL = float3(0.0f, 0.0f, 0.0f);

	for (int i = 0; i < 4; i++)
	{
		posL += weights[i] * mul(float4(vin.PosL, 1.0f), gBoneTransforms[vin.BoneIndices[i]]).xyz;
		normalL += weights[i] * mul(vin.NormalL, (float3x3)gBoneTransforms[vin.BoneIndices[i]]).xyz;
	}

	vout.PosW = mul(float4(posL, 1.0f), gWorld).xyz;
	vout.NormalW = mul(normalL, (float3x3)gWorldInvTranspose);
	vout.PosH = mul(float4(posL, 1.0f), gWorldViewProj);
	vout.Tex = mul(float4(vin.Tex, 0.0f, 1.0f), gTexTransform).xy;

	return vout;
}

float4 PS(VertexOut pin, uniform int gLightCount, uniform bool gUseTexure, uniform bool gAlphaClip, uniform bool gFogEnabled) : SV_Target
{
	// Interpolating normal can unnormalize it, so normalize it.
	pin.NormalW = normalize(pin.NormalW);

	// The toEye vector is used in lighting.
	float3 toEye = gEyePosW - pin.PosW;

		// Cache the distance to the eye from this surface point.
		float distToEye = length(toEye);

	// Normalize.
	toEye /= distToEye;

	// Default to multiplicative identity.
	float4 texColor = float4(1, 1, 1, 1);
	if (gUseTexure)
	{
		// Sample texture.
		texColor = gDiffuseMap.Sample(samAnisotropic, pin.Tex);

		if (gAlphaClip)
		{
			// Discard pixel if texture alpha < 0.1.  Note that we do this
			// test as soon as possible so that we can potentially exit the shader 
			// early, thereby skipping the rest of the shader code.
			clip(texColor.a - 0.1f);
		}
	}

	//
	// Lighting.
	//

	float4 litColor = texColor;
	if (gLightCount > 0)
	{
		// Start with a sum of zero. 
		float4 ambient = float4(0.0f, 0.0f, 0.0f, 0.0f);
			float4 diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f);
			float4 spec = float4(0.0f, 0.0f, 0.0f, 0.0f);

			// Sum the light contribution from each light source.  
			[unroll]
		for (int i = 0; i < gLightCount; ++i)
		{
			float4 A, D, S;
			ComputeDirectionalLight(gMaterial, gDirLights[i], pin.NormalW, toEye,
				A, D, S);

			ambient += A;
			diffuse += D;
			spec += S;
		}

		// Modulate with late add.
		litColor = texColor*(ambient + diffuse) + spec;
	}

	//
	// Fogging
	//

	if (gFogEnabled)
	{
		float fogLerp = saturate((distToEye - gFogStart) / gFogRange);

		// Blend the fog color and the lit color.
		litColor = lerp(litColor, gFogColor, fogLerp);
	}

	// Common to take alpha from diffuse material and texture.
	litColor.a = gMaterial.Diffuse.a * texColor.a;

	return litColor;
}


technique11 Light1
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}

technique11 Light2
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, false)));
	}
}

technique11 Light3
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, false)));
	}
}

technique11 Light0Tex
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, false)));
	}
}

technique11 Light1Tex
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, false)));
	}
}

technique11 Light2Tex
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, false)));
	}
}

technique11 Light3Tex
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, false)));
	}
}

technique11 Light0TexAlphaClip
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, false)));
	}
}

technique11 Light1TexAlphaClip
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, false)));
	}
}

technique11 Light2TexAlphaClip
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, false)));
	}
}

technique11 Light3TexAlphaClip
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, false)));
	}
}

technique11 Light1Fog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, true)));
	}
}

technique11 Light2Fog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, true)));
	}
}

technique11 Light3Fog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, true)));
	}
}

technique11 Light0TexFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, true)));
	}
}

technique11 Light1TexFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, true)));
	}
}

technique11 Light2TexFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, true)));
	}
}

technique11 Light3TexFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, true)));
	}
}

technique11 Light0TexAlphaClipFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, true)));
	}
}

technique11 Light1TexAlphaClipFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, true)));
	}
}

technique11 Light2TexAlphaClipFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, true)));
	}
}

technique11 Light3TexAlphaClipFog
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, true)));
	}
}

technique11 Light1Reflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}

technique11 Light2Reflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, false)));
	}
}

technique11 Light3Reflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, false)));
	}
}

technique11 Light0TexReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, false)));
	}
}

technique11 Light1TexReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, false)));
	}
}

technique11 Light2TexReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, false)));
	}
}

technique11 Light3TexReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, false)));
	}
}

technique11 Light0TexAlphaClipReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, false)));
	}
}

technique11 Light1TexAlphaClipReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, false)));
	}
}

technique11 Light2TexAlphaClipReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, false)));
	}
}

technique11 Light3TexAlphaClipReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, false)));
	}
}

technique11 Light1FogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, true)));
	}
}

technique11 Light2FogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, true)));
	}
}

technique11 Light3FogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, true)));
	}
}

technique11 Light0TexFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, true)));
	}
}

technique11 Light1TexFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, true)));
	}
}

technique11 Light2TexFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, true)));
	}
}

technique11 Light3TexFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, true)));
	}
}

technique11 Light0TexAlphaClipFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, true)));
	}
}

technique11 Light1TexAlphaClipFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, true)));
	}
}

technique11 Light2TexAlphaClipFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, true)));
	}
}

technique11 Light3TexAlphaClipFogReflect
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, true)));
	}
}

technique11 Light1Skinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}

technique11 Light2Skinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, false)));
	}
}

technique11 Light3Skinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, false)));
	}
}

technique11 Light0TexSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, false)));
	}
}

technique11 Light1TexSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, false)));
	}
}

technique11 Light2TexSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, false)));
	}
}

technique11 Light3TexSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, false)));
	}
}

technique11 Light0TexAlphaClipSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, false)));
	}
}

technique11 Light1TexAlphaClipSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, false)));
	}
}

technique11 Light2TexAlphaClipSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, false)));
	}
}

technique11 Light3TexAlphaClipSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, false)));
	}
}

technique11 Light1FogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, true)));
	}
}

technique11 Light2FogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, true)));
	}
}

technique11 Light3FogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, true)));
	}
}

technique11 Light0TexFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, true)));
	}
}

technique11 Light1TexFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, true)));
	}
}

technique11 Light2TexFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, true)));
	}
}

technique11 Light3TexFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, true)));
	}
}

technique11 Light0TexAlphaClipFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, true)));
	}
}

technique11 Light1TexAlphaClipFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, true)));
	}
}

technique11 Light2TexAlphaClipFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, true)));
	}
}

technique11 Light3TexAlphaClipFogSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, true)));
	}
}

technique11 Light1ReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}

technique11 Light2ReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, false)));
	}
}

technique11 Light3ReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, false)));
	}
}

technique11 Light0TexReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, false)));
	}
}

technique11 Light1TexReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, false)));
	}
}

technique11 Light2TexReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, false)));
	}
}

technique11 Light3TexReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, false)));
	}
}

technique11 Light0TexAlphaClipReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, false)));
	}
}

technique11 Light1TexAlphaClipReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, false)));
	}
}

technique11 Light2TexAlphaClipReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, false)));
	}
}

technique11 Light3TexAlphaClipReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, false)));
	}
}

technique11 Light1FogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, true)));
	}
}

technique11 Light2FogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, false, false, true)));
	}
}

technique11 Light3FogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, false, false, true)));
	}
}

technique11 Light0TexFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, false, true)));
	}
}

technique11 Light1TexFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, false, true)));
	}
}

technique11 Light2TexFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, false, true)));
	}
}

technique11 Light3TexFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, false, true)));
	}
}

technique11 Light0TexAlphaClipFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(0, true, true, true)));
	}
}

technique11 Light1TexAlphaClipFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, true, true, true)));
	}
}

technique11 Light2TexAlphaClipFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(2, true, true, true)));
	}
}

technique11 Light3TexAlphaClipFogReflectSkinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(3, true, true, true)));
	}
}

I guess the problem might lie in the SkinnedVertexIn. 

 

And one more thing : If I try to debug the shader it says failed to generate shader trace and therefore it is unable to debug shader.

 

Edit : I cannot see the Pixel shader stage in the graphics pipline .

Edited by Saad Manzur
0

Share this post


Link to post
Share on other sites
These are errors, the draw call fails. I'm not surprised the graphics debugger can't work with that. I still use PIX, but I cannot remember how it reacts in such a case, since I usually fire it up only after I have fixed such pipeline errors.

Looks pretty obvious to me. You are either binding the wrong input layout or the input layout creation is at fault.
1

Share this post


Link to post
Share on other sites


1. ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (WEIGHTS,0) as input, but it is not provided by the output stage.

2. ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (BONEINDICES,0) as input, but it is not provided by the output stage.

 

Since you have one vertex shader that offers those two semantics (SkinnedVS) and one that does not (VS) it is my quess that you are drawing with the wrong technique, one that uses VS. To solve this error, you need to ensure that input layout always matches VS input elements.

1

Share this post


Link to post
Share on other sites

  

Since you have one vertex shader that offers those two semantics (SkinnedVS) and one that does not (VS) it is my quess that you are drawing with the wrong technique, one that uses VS. To solve this error, you need to ensure that input layout always matches VS input elements.

 

I am using the "Light1Skinned" technique as follows :
 

technique11 Light1Skinned
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, SkinnedVS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}

But when I use the Light1 Technique all is perfect:
 

technique11 Light1
{
	pass P0
	{
		SetVertexShader(CompileShader(vs_5_0, VS()));
		SetGeometryShader(NULL);
		SetPixelShader(CompileShader(ps_5_0, PS(1, false, false, false)));
	}
}
0

Share this post


Link to post
Share on other sites

@Unbird

These are errors, the draw call fails. I'm not surprised the graphics debugger can't work with that. I still use PIX, but I cannot remember how it reacts in such a case, since I usually fire it up only after I have fixed such pipeline errors.



I cannot get the PIX to work with directx 11 and windows 8.


Looks pretty obvious to me. You are either binding the wrong input layout or the input layout creation is at fault

 

Ok so I checked the input layout again and found this problem :

 

Effects::SkinFX->Light1Tech->GetPassByIndex(0)->GetDesc(&passDesc);
	HR(device->CreateInputLayout(InputLayoutDesc::PosNormalTexSkin, 5, passDesc.pIAInputSignature, 
		passDesc.IAInputSignatureSize, &PosNormalTexSkin));

Used this instead of this:

 

Effects::SkinFX->Light1SkinnedTech->GetPassByIndex(0)->GetDesc(&passDesc);
	HR(device->CreateInputLayout(InputLayoutDesc::PosNormalTexSkin, 5, passDesc.pIAInputSignature, 
		passDesc.IAInputSignatureSize, &PosNormalTexSkin));

The error line seems to be gone. But the problem still persists. The bones and weights are correctly present in the vertex buffer. But I still cannot see the model on the screen. I am trying to debug the shader . But it is giving me the same error : 

**Graphics Diagnostics failed to build shader trace. Therefore, it is unable to debug shader.**

 

What sort of problem is this ? 

0

Share this post


Link to post
Share on other sites

One thing I still can see that in the graphics pipline input assembler looks ok. But the vertex shader is blank and there is no pixel shader stage. And output merger stage is transparent.

0

Share this post


Link to post
Share on other sites
Hmmm, quite stubborn dry.png
 
Can't help you with the graphics debugger, still using PIX here. I wonder if that thing works at all: Ever successfully tried a simpler sample ? Preferably one not using the effect framework ? I remember AMD PerfStudio never wanted to work with the D3D9 effects with my C#/SlimDX stuff or something.

If you don't get it to work that leaves only manual debugging. Unfortunately it can get quite involved:
  • First double check you don't have other errors/warnings lurking.
  • Reading back data with CopyResource to a staging buffer, then map and read back to CPU, to check if shader constants are set correctly (bone transformations,...)
  • One can actually grab the data after the vertex shader with a special geometry shader (so-called stream output). This is not that easy to setup, though.
  • Alternatively, setup special VS and PS (and vertex buffers) to visualize vertex data or shader constants (e.g. output weights as colored pixels).
  • Simplify the thing. Use a Mesh with one triangle, one Bone/Weight. It sounds silly, but as soon you have some output you can usually work from there more easily.
  • Since it could be a bug in the effect framework, try without. Last resort I'd say, because doing it manually even more can go wrong. Though: I still use it myself and I don't remember a related problem. But it is obsolete and could behave buggy in a new runtime/OS I guess.
I'm just brainstorming here, sorry, no idea what could be wrong. Also read the recent thread about graphics debugging.

Edit: Could you show all relevant code that goes into that draw call, please ? Or even put the whole project on github or something ? Maybe we spot something.
2

Share this post


Link to post
Share on other sites

I tried PIX. But does it work with Directx 11 ?

 


Reading back data with CopyResource to a staging buffer, then map and read back to CPU, to check if shader constants are set correctly (bone transformations,...)

 

Silly question ... But how to do that ? I am seeing some constant buffers in the VSSetShader(). But couldn't make much from it coz the variable names in the shader files are not mentioned there. Though I can definetely see that one constant buffer object is just initialized to 0. I mean every variable inside it is 0. I have only 2 constant buffers here.

 

Again, my vertex shader stays blank .And if I try to debug it throws an error. So, my guess the input assembler fails to link with the shader at all, If I use the SkinnedVS() in the shader code. But if I use the VS() it works and I can debug and the vertex shader shows a wireframed model.

0

Share this post


Link to post
Share on other sites
PIX works to a certain extent. One cannot debug D3D11-only features (tesselation, compute), nonetheless, inspecting buffers/textures/render output works usually fine. Your code should pose little problems. Edit: I'm running Windows 7 and vanilla D3D11, though. PIX does not run with platform update a year ago and I don't think it runs on Win 8 either.
 

Silly question ... But how to do that ? I am seeing some constant buffers in the VSSetShader(). But couldn't make much from it coz the variable names in the shader files are not mentioned there. Though I can definetely see that one constant buffer object is just initialized to 0. I mean every variable inside it is 0. I have only 2 constant buffers here.


Aaah, so you can inspect buffers. Well, good. In PIX one can define the structure, meaning, copy-paste from the HLSL cbuffer definition, more or less. No idea how to do that in your case.

All zeroes sounds bad, though. As requested, show the code that updates the shader constants. Edited by unbird
1

Share this post


Link to post
Share on other sites

Ok here goes.....

These are the function I am using to set the variables. I am not good in Effects framework. Its based on the concept of Frank D Luna. May contain huge mistakes.]

void SetWorldViewProj(CXMMATRIX M) { WorldViewProj->SetMatrix(reinterpret_cast<const float*>(&M)); }
	void SetWorld(CXMMATRIX M) { World->SetMatrix(reinterpret_cast<const float*>(&M)); }
	void SetWorldInvTranspose(CXMMATRIX M) { WorldInvTranspose->SetMatrix(reinterpret_cast<const float *> (&M)); }
	void SetBoneTransforms(const XMFLOAT4X4 *M, int cnt) { BoneTransforms->SetMatrixArray(reinterpret_cast<const float*>(M), 0, sizeof(M)*cnt); }
	void SetTexTransform(CXMMATRIX M) { TexTransform->SetMatrix(reinterpret_cast<const float *> (&M)); }
	void SetEyePosW(const XMFLOAT3 &v) { EyePosW->SetRawValue(&v,0,sizeof(XMFLOAT3)); }
	void SetFogColor(const FXMVECTOR v) { FogColor->SetFloatVector(reinterpret_cast<const float *>(&v)); }
	void SetFogStart(float f) { FogStart->SetFloat(f); }
	void SetFogRange(float f) { FogRange->SetFloat(f); }
	void SetDirLights(const DirectionalLight* lights)   { DirLights->SetRawValue(lights, 0, 3 * sizeof(DirectionalLight)); }
	void SetMaterial(const Material& mat)               { Mat->SetRawValue(&mat, 0, sizeof(Material)); }
	void SetDiffuseMap(ID3D11ShaderResourceView *tex) { DiffuseMap->SetResource(tex); }

And this is how I store variables in SkinEffect class.

 

        WorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
	World = mFX->GetVariableByName("gWorld")->AsMatrix();
	WorldInvTranspose = mFX->GetVariableByName("gWorldInvTranspose")->AsMatrix();
	TexTransform = mFX->GetVariableByName("gTexTransform")->AsMatrix();
	EyePosW = mFX->GetVariableByName("gEyePosW")->AsVector();
	FogColor = mFX->GetVariableByName("gFogColor")->AsVector();
	FogStart = mFX->GetVariableByName("gFogStart")->AsScalar();
	FogRange = mFX->GetVariableByName("gFogRange")->AsScalar();
	DirLights = mFX->GetVariableByName("gDirLights");
	Mat = mFX->GetVariableByName("gMaterial");
	DiffuseMap = mFX->GetVariableByName("gDiffuseMap")->AsShaderResource();
	BoneTransforms = mFX->GetVariableByName("gBoneTransforms")->AsMatrix();

My main concern would be BoneTransforms. Am I setting it right ? I am setting the variables before rendering in this way :
 

        Effects::SkinFX->SetEyePosW(mCam.GetPosition());
        Effects::SkinFX->SetWorld(World);
	Effects::SkinFX->SetWorldInvTranspose(worldInvTranspose);
	Effects::SkinFX->SetWorldViewProj(worldViewProj);
	Effects::SkinFX->SetTexTransform(XMMatrixScaling(1.0f, 1.0f, 1.0f));
	Effects::SkinFX->SetDirLights(&dirLight[0]);
	
	Effects::SkinFX->SetBoneTransforms(&mBones.mBoneTransforms[0], mBones.mBoneTransforms.size());

        Effects::SkinFX->SetMaterial(Materials[i]);
        Effects::SkinFX->SetDiffuseMap(DiffuseMapSRV[i]);

There is huge possiblity that I am setting them in a wrong way. mBoneTransforms is a vector of type XMFLOAT4X4.mCam.GetPosition() returns XMFLOAT3 value.

0

Share this post


Link to post
Share on other sites
Your concern is spot on.
 

void SetBoneTransforms(const XMFLOAT4X4 *M, int cnt) { BoneTransforms->SetMatrixArray(reinterpret_cast<const float*>(M), 0, sizeof(M)*cnt); }
sizeof(M) is the size in bytes, times how many matrices gives ... a lot. Edit: My C++ reading skills at fault. M is a pointer, so this is probably 4 or 8. Still wrong though.

The doc for this function is a bit confusing (not sure if 'elements' means array or matrix elements). Luna uses it like so:
 

void SetBoneTransforms(const XMFLOAT4X4* M, int cnt){ BoneTransforms->SetMatrixArray(reinterpret_cast<const float*>(M), 0, cnt); }
Worth a shot. Also check (or compare to Luna's) the other calls. Edited by unbird
1

Share this post


Link to post
Share on other sites

Unbird, 

I can kiss you. I owe you a drink buddy.... biggrin.png biggrin.png biggrin.png . This stupid mistake made me waste 3 weeks . An average catastrophe in the life of a programmer. 

I imported it. But it does not seem perfect. Mesh is somewhat distorted. I used only 4 weights where my model contained 6 weights at some vertices . May be that's the reason. Do you know any DXGI format to take 6 input in the input layout. Here is what it looks like now.

Distorted_zps9059219d.png 

0

Share this post


Link to post
Share on other sites

Devil's in the details. Three weeks sounds really frustrating, glad it (somehow) works now.

 

Just one question: Can you now debug the shaders ?

 

6 components ? Nope, but no need to. You can distribute it across a 4- and a 2-component. Or use 6 one-component (scalars). Probably need to play around a bit to find out which is most convenient (or even works) and what performance implications arise. 

 

One can go even further and pack more info with some bit-hackery. Only do this if you do have a bottleneck in the vertex size. Just one hint: bone indices probably don't need full 32 bit ints.

 

 

1

Share this post


Link to post
Share on other sites

Again, thanks unbird. Now debugger works. But it seems when I try to use the default offset matrix provided by the model, it gets more distorted. Guess I have got some more matrix multiplication to do. Just one question is it necessary to multiply each offset matrix with its parent matrix and global inverse transform ?

Fact about 6 weights. Yes I guess I can use 2 separate format to store 6 weights . Do I have to change the semantic index in the input layout then ? 

About the integer part, I think 8 bit is sufficient. DXGI_FORMAT_R8G8B8A8_UINT.

0

Share this post


Link to post
Share on other sites


is it necessary to multiply each offset matrix with its parent matrix and global inverse transform ?

Not sure what you mean by "parent" matrix and "global inverse" transform. Can you describe?

 

Also, take another look at my skinned mesh article. The names I use for various matrix arrays aren't the same as you seem to be using, but you should be able to find your equivalents.

 

You mention that your mesh uses 6 weights, but you're only inputting 4. How do you do that? You can't simply ignore the other two. Can you explain a little?

0

Share this post


Link to post
Share on other sites


You mention that your mesh uses 6 weights, but you're only inputting 4. How do you do that? You can't simply ignore the other two

 

Guess gotta fix that first . But identity matrix shows something now that's a relief even if it is some what distorted.


Not sure what you mean by "parent" matrix and "global inverse" transform.

 

I am not so sure about assimp myself . This is what I did :

 

1. Got the offset matrix for each bone stored in the model. [I am not sure if it is really offset matrix you meant, but Assimp is referring to it as offset matrix in the aiBone structure. (http://assimp.sourceforge.net/lib_html/structai_bone.html

 

2. Now got the scene root node's global transformation matrix and inversed it. According to Ogglev's tutorial(http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html)

 

3. Then I traversed the whole scene to find the bones. I used this technique according to the above tutorial.

 

  •      Pass parent's transformation matrix and child in the function.
  •      Multiply it by child's offset
  •      Multiply the above product with child's offset again and global inverse transform to get child transform (confused)
  •      Recursively called the function

I am really confused about this whole thing. Can you tell me what is the mOffsetMatrix in Assimp. And which matrix it represents in your article. That would be really helpful.

 

0

Share this post


Link to post
Share on other sites

I'm not familiar with Assimp's implementation but it appears the ReadNodeHierarchy function is the combined equivalent of the CalulateTransformationMatrices, CalcCombinedMatrix and CalculateFinalMatrix functions in my tutorial. Although I looked at the link you posted (labeled Tutorial 38) I don't see the steps you outline.

 

The NodeTransformation is the bone's to-Parent animation matrix. That's multiplied by the parent's animation matrix to form the bone's to-Root animation matrix. That's multiplied by the bone's offset matrix. The role of the "global inverse transform" isn't quite clear to me, I'm afraid.

 

FYI, it appears that the author of that tutorial doesn't quite understand the code he provides. He describes it as starting with a child and "traveling" to it's parent. The code itself, however, clearly indicates that ReadNodeHierarchy is first called [ ReadNodeHeirarchy(AnimationTime, m_pScene->mRootNode, Identity);] with a root node (the "ultimate" parent) argument, the node's transforms are calculated, and ReadNodeHierarchy is called for each child - working it's way from parent to child, not the other way 'round. The code is straightforward but the author's description is very misleading.

Edited by Buckeye
1

Share this post


Link to post
Share on other sites

In the assimp's documentation it says that mOffsetMatrix is the "Matrix that transforms from mesh space to bone space in bind pose." . So, can you tell me what does it mean actually ?

0

Share this post


Link to post
Share on other sites

In my article, take a look at the section A Slight Diversion from the Initialization Process.

 

Each bone's animation transform (I think they're the NodeTransformation in the article you referenced) orients the bone LOCALLY. "Locally" means (e.g.) a hand bone rotates about it's own Y-axis a little during an animation. That rotation about the bone's Y-axis is to take place wherever the bone is in the world. Maybe the arm is raised into the air or off to one side. The hand bone moves with the arm, but the rotation is still to take place about the bone's Y-axis, not the world Y-axis.

 

So, if the vertices around the character's hand are to be rotated about the hand bone's Y-axis, that rotation needs to take place relative to the hand bone, not the world Y-axis. See the illustration in the section of the article I linked. The vertex positions in the mesh around the hand are in world(*) space. The offset matrix transforms the vertex from world space to bone space. The animation (scale-rotate-translate) then takes place in bone space. Then the combined animation transforms move the vertex back to world space for rendering.

 

(*) that's really root-node space. I'm calling it "world" to give you a better visualization.

1

Share this post


Link to post
Share on other sites


In my article, take a look at the section A Slight Diversion from the Initialization Process.

 

Buck, from what I read from the article. Here is what I learned. Correct me if I am wrong....
 

1. I am given the offset matrix by Assimp [which you calculated]

2. And the transformation matrix is given by Assimp's aiNode structure's mTransformation.(Assimp's documentation : "The transformation relative to the node's parent.")

3. Now all I have to do is recursively calculate the transformation matrix for each bone by multiplying it with it's parent transformation.

4. And to render it I have to multiply the offset matrix with each bone's transformation matrix...

 

I just want to create the bind pose first.

0

Share this post


Link to post
Share on other sites

As mentioned previously, I'm not familiar with Assimp and how they implement the node hierarchy. The best I can do is say "It sounds like it."

0

Share this post


Link to post
Share on other sites

Buck, 

I wrote this function to calculate the transformation matrices. It is similar to the tutorial of the blog. And also I did some research in Assimp. It seems mTransformation "is local in relation to its parent node" . So I am guessing it transforms mesh space to bone space. I have to multiply it with each of its children. And the offset matrices are pre calculated. Here is the function:

 

void Bones::UpdateNode(const aiNode *pNode, const XMFLOAT4X4 parentMatrix) //Bone Index, Parent Matrix (Transformation)
{
	const char *name = pNode->mName.C_Str();
	XMFLOAT4X4 temp;
	AItoXM(pNode->mTransformation, temp);
	XMMATRIX NodeTransformation = XMLoadFloat4x4(&temp);

	XMMATRIX finalTransform = NodeTransformation * XMLoadFloat4x4(&parentMatrix);

	if (mBoneInfoMap.find(name) != mBoneInfoMap.end())
	{
		int boneID = mBoneInfoMap[name];
		XMMATRIX temp2 = XMLoadFloat4x4(&m_GlobalInverseTransform) * finalTransform * XMLoadFloat4x4(&mBoneInfo[boneID].offsetMatrix);
		XMStoreFloat4x4(&mBoneInfo[boneID].Transform, temp2);
	}

	XMFLOAT4X4 temp3;
	XMStoreFloat4x4(&temp3, finalTransform);

	for (int i = 0; i < pNode->mNumChildren; i++)
	{
		UpdateNode(pNode->mChildren[i], temp3);
	}
}

The author of the tutorial passed the scene's RootNode and an identity matrix . But if I do that the mesh is distorted. Do I have to pass the RootNode of the scene ?

Edited by Saad Manzur
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0