Use the default point shader

From JReality Wiki
Jump to: navigation, search

Source file: PointShaderExample

JavaDoc: DefaultPointShader


Run as Java webstart


This example demonstrates many of the features of the default point shader provided in the jReality scene graph. It is best studied in conjunction with the tutorial example featuring point set factories.


The underlying scene graph in this example consists of a cylindrical stack of circular point sets. Each layer of the stack is attached to a different instance of the default point shader. The underlying geometric point sets are identical to each other, with the exception of some optional vertex attributes (colors and relative radii) which interact with the settings of the point shader to produce different effects. In the center of each circle is a text label containing a number from 1 to 6, which can be matched to the index used in the source code to generate the scene.


The shader attributes for the point shader are created using the shader interfaces, rather than directly setting Appearance attributes. (See Introductory tutorial for more details about this distinction.)


The first two examples demonstrate the display of points in the simplest form. The rest of the examples render each point as a true (but approximate) geometric sphere. In the latter case, many of the rendering parameters are derived from the polygon shader contained in the point shader. In the case of non-sphere rendering, the size of the representation is set with the method setPointSize which is a specified in pixels, while with sphere rendering the size is specified with setPointRadius.


To see the difference between these two coordinate systems, use the click wheel camera zoom tool provided in the example, to zoom in on the scene. The points drawn in the first two example (non-sphere) do not get larger (since pixels remain the same size) but the other points, drawn as spheres, do get larger when one zooms in.


The features demonstrated here include:

  • Simple (non-sphere) rendering, using diffuse color and size from point shader.
  • Same as previous, but using a different texture for sprite (non-sphere) rendering in the JOGL backend.
  • Rendering using true spheres, single color, single sphere radius, opaque.
  • Same as previous, but transparency enabled.
  • Colors from vertex colors in the point set
  • Radius of spheres modulated by values appearing in point set vertex attribute Attribute.RELATIVE_RADII.


See also This entry on jReality developer forum about point size, entry from Sept. 1, 2008


Some of the features of the point shader (particularly those related to rendering hints, such as the rhs.setOpaqueTubesAndSpheres(), are only implemented at the current time for the JOGL backend.

Previous: Use a geometry shader Developer Tutorial: Contents Next: Use the default line shader