Sign in to follow this  

Lines with Orthographic Vertex shader

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;
	float fRadius : PSIZE;
	float4 nColor : COLOR;

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

VSOutput VertShader(VSInput input){
	VSOutput output;
	int nNumPoint=int(input.nColor.b*256); //get the point index from the blue value
	float fDeg=(float)(nNumPoint)/float((nNumPoints-1));
	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:
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this