The Ellipse uvs
uv[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;}
[sharedmedia=gallery:images:5748]
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.