Hello,
I'm looking for some flexibility on sending data for each vertex. In my situation I'd like to pass some array for every vertex to specify which texture it should use (the array won't me too big, like 5, 6 maybe 7 values; I cannot send only one value with texture id because I need blending between them), like:
[1.0, 0.0, 0.0 ...] - first texture
[0.0, 1.0, 0.0 ...] - second texture and so on
Currently I am packing these values into some TEXCOORD etc. but it is not flexible, because when I want to add next texture I need to change the vertex structure and try to pack the value somewhere in the shader.
So short question: is it possible to send an array with each vertex in DirectX/HLSL?
EDIT:
I have such structure (variable t is unused but it works with it):
struct TerrainVertex {
DirectX::XMFLOAT3 position;
DirectX::XMFLOAT4 color;
DirectX::XMFLOAT3 normals;
DirectX::XMFLOAT2 texture;
DirectX::XMFLOAT2 t;
};
and changed it to (for testing):
struct TerrainVertex {
DirectX::XMFLOAT3 position;
DirectX::XMFLOAT4 color;
DirectX::XMFLOAT3 normals;
DirectX::XMFLOAT2 texture;
float t[2];
};
but my whole terrain disappears and I have random artifacts on the screen (plus Microsoft C++ exception: _com_error at memory location 0x002EF170.)
input layout:
D3D11_INPUT_ELEMENT_DESC inputLayout[] =
{
{ "POSITION", 0U, DXGI_FORMAT_R32G32B32_FLOAT, 0U, 0U, D3D11_INPUT_PER_VERTEX_DATA, 0U },
{ "COLOR", 0U, DXGI_FORMAT_R32G32B32A32_FLOAT, 0U, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0U },
{ "NORMAL", 0U, DXGI_FORMAT_R32G32B32_FLOAT, 0U, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0U },
{ "TEXCOORD", 0U, DXGI_FORMAT_R32G32_FLOAT, 0U, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0U },
{ "TEXCOORD", 1U, DXGI_FORMAT_R32G32_FLOAT, 0U, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0U }
};
Thanks for help!