Hi everyone, I'm new here, and new to HLSL. I'm hoping that some of you may be able to help me understand some of the parts of graphics programming that i don't understand, or can't really seem to find a good explanation on.
I was writing a simple shader last night and realized that I don't understand what's really going on behind the scenes, but instead I'm just memorizing where code is supposed to go.
If we can please start with something as simple as this:
struct VS_INPUT
{ float4 mPosition : POSITION; };
struct VS_OUTPUT
{ float4 mPosition : POSITION; };
float4x4 gWorldMatrix;
float4x4 gViewMatrix;
float4x4 gProjectionMatrix;
VS_OUTPUT vs_main ( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.mPosition = mul(Input.mPosition, gWorldMatrix);
Output.mPosition = mul(Output.mPosition, gViewMatrix);
Output.mPosition = mul(Output.mPosition, gProjectionMatrix);
return Output;
}
I realized that I don't even know what the input and output structs are really doing. For example, they appear to be identical (except for their names, which can be called whatever) I guess I don't understand why we need to declare the same variable twice, and why they look identical.
How does my input struct know that it should contain all the semantics for an object?
Is the output struct only used AFTER the object is *returned* from VS_OUTPUT vs_main()?