# Lines with Orthographic Vertex shader

This topic is 4453 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So I am writing a 2D game for fun and I am drawing circles in the 'background' using line strips, I had it working perfectly fine using transformed vertices, but I figured since I wasn't using the video card for anything much I'd go ahead and offload the circle calculations to a vertex shader, but now of course, I don't see anything. I am using an othographic projection matrix (1024x768), and both the world and view matrices are the identity. The line color is different than the clear color, and I've gone through other things trying to figure out what was wrong, but maybe I just need a different perspective on it. Here is the shader code:
uniform float4x4 mProjMat; //the projection matrix
uniform float2 vCenter; //the center of the current circle
uniform int nNumPoints; //the number of points in the current circle

struct VSInput{
float3 vPos : POSITION;
float4 nColor : COLOR;
};

struct VSOutput{
float4 vPos : POSITION;
float4 color : COLOR;
};

VSOutput output;

int nNumPoint=int(input.nColor.b*256); //get the point index from the blue value

float fDeg=(float)(nNumPoint)/float((nNumPoints-1));
output.color.b=input.nColor.a;
output.color.r=input.nColor.r;
output.color.g=input.nColor.g;
output.color.a=(float)nNumPoints+1-nNumPoints;
output.vPos=mul(input.vPos,mProjMat);
output.vPos=float4(input.vPos.xy,(float)nNumPoints+0.5f-nNumPoints,(float)nNumPoints-nNumPoints);

return output;
};

The number of points I'm using for testing is 64, the circle's center is set at 512,384 (resolution is 1024x768). I've stepped through it, and it seems to be getting correct output values for both the position and the color, I set the z value to 0.5 and the w value to 1. I also have this if statement:
if(!bool(nNumPoints-nNumPoint-1))
{
nNumPoint=0;
}

I'm trying to get the last point to get set to the same position as the first point, but it resolves to true and sets nNumpoint to 0 no matter what, even when I make a bool that is equal to false it STILL resolves to true, I just don't get it. Any help would be much appreciated.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013297
×