Sphere Point Sprites and Instanced Tubes

From JReality Wiki
Jump to: navigation, search

Points from jreality PointSets can be drawn either as spheres or as point sprites. You can switch between these two modes with the variable pointShader.spheresDraw in the Appearance. See Developer_Tutorial#Appearances on how to use Appearances. When spheresDraw is enabled the jogl3-backend will render a shaded sphere with lighting and reflection mapping for each vertex. This is rather performant, because only one instance of a sphere geometry data is needed in the GPU and only the transformation matrices are changed.

When spheresDraw is disabled we see no reflection map and only very static lighting. By the way, this is only, because I have not gotten around to implement it, it should be rather easy. But the main point is, that with spheresDraw disabled the backend technically only renders a little rectangle in the place of each point and then it cuts off the pixels in the corner to round it off and moves the pixels in the middle slightly towards the camera to create the impression of roundness. This method looks good and is much faster than the spheresDraw. In contrast the spheresDraw disabled method of the jogl2-backend shows flat discs instead of spheres and is fast as well.

For the tubes representing the lines of an IndexedLineSet the jogl3 backend uses instancing, i.e. the geometry for a tube of unit length and diameter exists only once in GPU memory. The result is, that huge number of tubed lines are drawn much faster in the opengl3 backend.

See a comparison in the following screenshots:

jogl2-backend, slow

jogl2-backend, fast, size of the sprites is limited, and their size is independent of the sphere size and does not respect transformations and is flat

jogl3-backend, slow, note the exact phong reflection

jogl3-backend, fast, might have a factor 2 in size difference, bug needs fixing