Skip to main content
edited title
Link
Dollarslice
  • 3.5k
  • 6
  • 33
  • 49

effect file screen coordinate confusionnot working with pixel values

Source Link
Dollarslice
  • 3.5k
  • 6
  • 33
  • 49

effect file screen coordinate confusion

I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why.

If I draw a line that goes from 0,0 to 100, 100 for example, I would expect it to draw a line from one corner of the screen to a little way in. I would expect it to treat these numbers as screen coordinates. Instead, the line is huge! A line of about 2 long fills the whole screen. Why is this? How can I modify my shader to 'think' in screen coordinates?

// a struct for the vertex shader return value
struct VSOut
{
float4 Col : COLOR;    // vertex color
float4 Pos : SV_POSITION;    // vertex screen coordinates
};

// the vertex shader
VSOut VS(float4 Col : COLOR, float4 Pos : POSITION)
{
VSOut Output;
Output.Pos = Pos;    // set the vertex position to the input's position
Output.Col = Col;    // set the vertex color to the input's color

return Output;    // send the modified vertex data to the Rasterizer Stage
}

// the pixel shader
float4 PS(float4 Col : COLOR) : SV_TARGET
{
return Col;    // set the pixel color to the color passed in by the Rasterizer Stage
}

// the primary technique
technique10 Technique_0
{
// the primary pass
pass Pass_0
{
    SetVertexShader(CompileShader(vs_4_0, VS()));
    SetGeometryShader(NULL);
    SetPixelShader(CompileShader(ps_4_0, PS()));
}
}