Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Directx, What a pain in the butt! I learned opengl with no problems when it came to using uniform data and sending it to the shaders. Constant Buffers are not nearly as user friendly. I am sure they have wonderful attributes to them, but geez. But I did get my ellipses working along with my curved lines. I am using control points to define the length and width of both and then creating triangles that have u,v points to define the curves.

The Ellipse uvsuv[0] = Vector2f(0.0f, 2.0f);uv[1] = Vector2f(2.0f, 0.0f);uv[2] = Vector2f(0.0f, 2.0f);
The uvs are 2.0 so a curve of 1 radius will touch the hypotenuse (longest side of a right triangle).
The vertices are added along with indices to form a diamond of triangles. The ellipse will be within the triangle.objects[a].shapes.AddVertex(p[0], col[2], uv[0]);objects[a].shapes.AddVertex(p[1], col[2], uv[1]);objects[a].shapes.AddVertex(p[2], col[2], uv[1]);objects[a].shapes.AddVertex(p[3], col[0], uv[2]);objects[a].shapes.AddVertex(p[4], col[2], uv[0]);objects[a].shapes.AddTriangle(0, 3, 1);objects[a].shapes.AddTriangle(0, 2, 3);objects[a].shapes.AddTriangle(4, 1, 3);objects[a].shapes.AddTriangle(4, 3, 2);
The pixel shader for ellipse

I am discarding any pixel that is greater than a length of 1. I am using the uvs to determine length.float4 PShader(float4 position : SV_POSITION, float4 color : COLOR, float2 uv : UV) : SV_TARGET{float result = sqrt(uv.x * uv.x + uv.y * uv.y);if (color.a < 1.0) color = float4(.50, .50, .50, 1.0) * color;if (result > 1) discard; return color;}
Sign in to follow this  

1 Comment

Recommended Comments

Just realized the sqrt part was not needed.  Anything less than one squared will still be less than one.  Anything more than one squared will still be more than one.

Share this comment

Link to comment

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
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!