I have two questions with regard to passing vertices to the Vertex Shader.
1) I have seen code samples (i.e. DirectXTK) using the semantic SV_Position (instead of POSITION/POSITION0) for passing the position of a vertex to the Vertex Shader.
Why do you want to do that?
2)
A vertex structure could look like this:
struct VertexPosition {
XMFLOAT3 p;
};
The corresponding input element descriptor looks like this:
const D3D11_INPUT_ELEMENT_DESC desc[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
The GPU vertex shader input structure looks like this:
struct VSInputPosition {
float4 p : POSITION0;
};
So how is it possible that affine transformations (especially the translation component) work in the following Vertex Shader:
PSInputPosition Transform_VS(VSInputPosition input) {
PSInputPosition output;
output.p = mul(input.p, g_local_to_projection);
return output;
}
It makes more sense to use the following code:
struct VSInputPosition {
float3 p : POSITION0;
};
PSInputPosition Transform_VS(VSInputPosition input) {
PSInputPosition output;
output.p = mul(float4(input.p, 1.0f), g_local_to_projection);
return output;
}