drawing circles on the gpu

Hey all

i would like to draw a (half) circle between two (dynamic) u/v points on a sphere, much like shown here:


i would like to draw it directly in a shader while also emulating an animated carve (so that a pointsprite can travel along that path).

any ideas/examples out there?

thx
Akeem

any ideas?

point position transformation with sin and cos in a vertex shader?

Rather than thinking about choosing points on the sphere, another way to think about it could be to get the location of the center of the sphere and the radius of the sphere. Then choose two points using spherical coordinates and convert to Cartesian coordinates to get your actual surface locations.

Then once you have your two points you could find the distance between the two points and then use spherical coordinates again to draw your curve possibly with the center of the new curve offset in the direction of the center of the original sphere so you would be able to get any size arc not just a half a circle.

Then again you could just use the position of two points on the sphere and skip the whole first part.

cheers
Keith

thx keith, I’ll look into those suggestions

Hi Achim I have GLSL shader I wrote that draws curves that I thought I would attempt to modify to do what your talking about. It’s not perfect and it doesn’t do all the calculations inside of the shader but I’m sure it could be modified to do so.

A couple of things to note;

  • it won’t draw more than half a circle precisely on the surface of the sphere (ThetaValue max = 1.57)
  • the RadiusMult uniform (circle radius multiplier) has to be sphere radius
  • I’m not to sure about animating a point sprite along the path but some ideas might be to use the same math in a point sprite shader for the sprite position, draw another curve using Tscript, or write the vertex positions to the RGB (16bit float) channels of the pixel shader and use a TOP to chop to get your vertex positions out of the shader (I did successfully do this once but I found it a little slow because I had 5000 points)

Maybe you could use it and or modify it…
CurveOnSphere.toe (61.8 KB)