![](https://uploads.gamedev.net/forums/monthly_2020_02/6db013259d8042bd939544dc1c9634fb.temp.jpg)
Can anyone help me with this hlsl error please?
![](https://uploads.gamedev.net/forums/monthly_2020_02/6db013259d8042bd939544dc1c9634fb.temp.jpg)
your “TexCoord” input element should have an offset of 12 + 12 = 24.. Does that help with the issue?
Also, I always use float4x4 for matrices, does matrix work the same?
.:vinterberg:.
@vinterberg Thanks for replying! I was under the impression that the byte offset is supposed to be from the previous element as I see it in the docs https://docs.microsoft.com/en-us/windows/win32/api/d3d11/ns-d3d11-d3d11_input_element_desc
Is this not the case? I originally had it at 24 and it kept giving errors until I saw and changed it to 12. I think the matrix does work the same for the constant buffer as its been working fine for me until I tried adding the normal data :(. Before this I only had position and texcoords, but when trying to add in normal data I face this problem.
It builds and run fine when I remove lines 7-10 in my pixel shader, which I am totally unsure why. Whats wrong with lines 7-10 they look normal to me.
Try arranging input element array and your vshader struct so they are in the same order, does that help?
Normal
TexCoord
Position
- and your vshader output position is float4, but input element is float3..
.:vinterberg:.
![](https://uploads.gamedev.net/forums/monthly_2020_02/a7007ae3e6a8453dbb6b91c8f0545c44.temp.jpg)
The creation of the shaders and input layout code I wrote is here https://github.com/zacharytay1994/GPPAssignment2/blob/TREES/DirectXFramework/SourceFiles/Graphics.cpp
at line 717, in case you want to take a look. I create the shader and inputlayout pointers upon construction and only bind them when I need to. I bind them in a function further down at line 853 called SetUseType() before drawing stuff that needs them.
@vinterberg Just wanted to let you know that your were right! Input element description is the byte offset from the first element and not in between elements, no idea why the documentation says otherwise. Also the problem was because of my Shader Model Level, I guess it was too low so I had to increase it and the error went away! Thanks for the help!
I have a pull request out to update the documentation for AlignedByteOffset - it doesn't seem correct in its current form. Thanks!
Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group