Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!