Hi,
I am trying to develop with Cg. I have a basic problem.
Here’s the my very simple code :
For Vp:
struct VertexIn
{
float4 mPosition : POSITION; // World space
float4 mTexCoord : TEXCOORD0; // Texture coord for unit 0.
};
struct VertexToFragment
{
float4 mOutPosition : POSITION; // Clip space
};
VertexToFragment main( VertexIn pInVertex,
uniform float4x4 pModelViewProj)
{
VertexToFragment lOutVertex;
lOutVertex.mOutPosition = mul(pModelViewProj, pInVertex.mPosition);
return lOutVertex;
}
For Fp:
struct VertexToFragment
{
float4 mOutPosition : POSITION;
};
// Main shader.
half4 main( VertexToFragment pInFragment) : COLOR
{
half4 lColor;
lColor.x = (mOutPosition.x + 1.0) / 2.0; // From [-1..1] To [0..1]
lColor.x = 0.0;
lColor.x = 0.0;
lColor.x = 1.0;
return lColor;
}
I use those programs with a simple test where i draw a quad on the entire viewport. And normally, if i understand well, the result should be a quad with a red gradient in the X direction. I tested a lot of things, the clip coordinates of my fragments are always (0,0,0,1). I don’t understand why The VP works fine but the connection between the VP and the FP seems to be wrong.
Is there someone who can give me a tip, plz ?
Thx.