Hey Guys,
I have the following vs and ps working properly
struct PosTex
{
float4 Pos : SV_Position;
float2 Tex : TEXCOORD0;
};
PosTex vs_heightmap_main( in uint VertID : SV_VertexID)
{
PosTex output;
uint2 xy = uint2(VertID % DepthInfraredReso.x, VertID / DepthInfraredReso.x);
float z = DepthMap[xy] * 0.001f;
float4 pos = float4((xy - DepthCxyFxy.xy) / DepthCxyFxy.zw * z, z, 1.f);
float4 pos_col = mul( Depth2Color, pos );
output.Tex= pos_col.xy / pos_col.z * ColorCxyFxy.zw + ColorCxyFxy.xy;
pos = pos * float4(1.f,-1.f,1.f,1.f) + Offset;
output.Pos = mul( ViewProjMat, pos );
return output;
}
float4 psmain(PosTex input ) : SV_Target0
{
return ColorMap[input.Tex];
}
Then after reading something about the HLSL keyword 'in' 'out' 'inout' I decide to play around with it. So I modified the previous code as the following
void vs_heightmap_main( in uint VertID : SV_VertexID, out float4 Pos : SV_Position, out float2 Tex : TEXCOORD0)
{
uint2 xy = uint2(VertID % DepthInfraredReso.x, VertID / DepthInfraredReso.x);
float z = DepthMap[xy] * 0.001f;
float4 pos = float4((xy - DepthCxyFxy.xy) / DepthCxyFxy.zw * z, z, 1.f);
float4 pos_col = mul( Depth2Color, pos );
Tex= pos_col.xy / pos_col.z * ColorCxyFxy.zw + ColorCxyFxy.xy;
pos = pos * float4(1.f,-1.f,1.f,1.f) + Offset;
Pos = mul( ViewProjMat, pos );
}
float4 psmain(float2 Tex:TEXCOORD0 ) : SV_Target0
{
return ColorMap[Tex];
}
Basically I get rid of vs return and use the 'out' keyword to pass data in between shader stages, but I only end up getting error:
Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage.
So there must be something I missed about when and how to use out keyword. It will be greatly appreciated if someone could enlightening me on that.
Thanks