• Create Account

### #Actualiedoc

Posted 15 November 2012 - 11:06 AM

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove NORMAL from the input layout and change TANGENT offset to 20.

### #6iedoc

Posted 15 November 2012 - 10:55 AM

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,	0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove NORMAL from the input layout and change TANGENT offset to 20.

I forgot to say, you will ALSO have to change the vertex shaders inputs to match the input layout. I've found that you can have more elements in your input layout than in your vertex shaders input, but not the other way around (i think, haha)

### #5iedoc

Posted 15 November 2012 - 10:53 AM

that code you posted isn't your input layout, its your vertex structure.

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove NORMAL from the input layout and change TANGENT offset to 20.

### #4iedoc

Posted 15 November 2012 - 10:51 AM

that code you posted isn't your input layout, its your vertex structure.

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, so the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove it from the input layout and change TANGENT offset to 20.

### #3iedoc

Posted 15 November 2012 - 10:51 AM

that code you posted isn't your input layout, its your vertex structure.

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, so the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove it from the input layout and change TANGENT offset to 20.

### #2iedoc

Posted 15 November 2012 - 10:51 AM

that code you posted isn't your input layout, its your vertex structure.

The input layout tells the input assembler what your giving it. When you don't define NORMALMAP, you will also have to not define it in your input assembler. you will also have to adjust each element's offset after the NORMALMAP element in the input layout, otherwise what will happen is your input assembler will still think you are giving it tangent data, but since you did not define NORMALMAP, it will actually be reading the next member in your structure, which looks like weights. by the time it gets to the bones data, it will have run out of data for that vertex, and either give you an error right there, or start reading into the next vertex, which then every vertex after will be off, and eventually you will run into an error anyway after there is no more vertex data.

if NORMALMAP is defined, everything will work just fine, but if NORMALMAP is not defined, but the input layout has not changed, so the input assembler will still expect it.

struct Vertex	// Vertex Structure
{
XMFLOAT3 pos;
XMFLOAT2 texCoord;
#ifdef NORMALMAP
XMFLOAT3 normal;
#endif
XMFLOAT3 tangent;
};

// input layout
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL",	 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT,    0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}
};

even if you changed the code so that you took out NORMAL from the input layout when NORMALMAP is not defined, there would still be a problem because TANGENT offset is still 32. if NORMALMAP is not defined, you will need to remove it from the input layout and change TANGENT offset to 20.

PARTNERS