0

I'm trying to render a non uniformly scaled sphere(ellipsoid) using point sprite in GLSL 440 or GLSL version higher than 330.

As we know, the point sprite in GLSL, can easily draw a unit sphere, but it's difficult to draw a ellipsoid with special requirements.

My thoughts are as follows:

  1. Firstly, I have a point(center of the sphere);
  2. Then, render a unit sphere using the point sprite;
  3. Suppose that the sphere is transformed by a rotate-scale matrix(non uniformly scaled);
  4. Then the transformed ellipsoid is rendered on the screen. reference: Line-ellipsoid intersection

In old OpenGL version, the function glutSloidSphere() in GLUT lib can easily realize this, but how can I code in the modern OpenGL 4.x using fragment shader? Thanks a lot!

The final effect I want is similar to the one shown below.

Effect Image01

Effect Image02

Spektre
  • 49,595
  • 11
  • 110
  • 380
SigCon
  • 1
  • 1
  • I never used point sprites but there are more ways how to do this see these: [ray and ellipsoid intersection accuracy improvement](https://stackoverflow.com/q/25470493/2521214) and [How can i make gradient sphere on glsl?](https://stackoverflow.com/a/41442375/2521214) and [How to draw 3D point verts without generating geometry?](https://stackoverflow.com/a/54158783/2521214). – Spektre May 31 '19 at 08:09
  • so Either use geometry shader to emit geometry per each point or pass data as Texture ... rendering is done by form of raytrace see [raytrace through 3D mesh](https://stackoverflow.com/a/45140313/2521214) .... so read all linked QAs chose the best approach for you and let us know so we know on what focus our answers ... Also do you got a sample input (the ellipsoids in ASCII ... ideally a C++ array definition with data) – Spektre May 31 '19 at 08:13
  • "*In old OpenGL version, the function glutSloidSphere() in GLUT lib can easily realize this, but how can I code in the modern OpenGL 4.x using fragment shader?*" glutSolidSphere created a *mesh*. Using point sprites and a fragment shader would mean ray tracing. Why not just create a sphere mesh yourself, just like glutSolidSphere did? – Nicol Bolas May 31 '19 at 13:30
  • Thanks a lot! I have more than 1 million points to render , so it may be expensive to create a sphere mesh for each point myself. – SigCon May 31 '19 at 13:42

0 Answers0