-
Notifications
You must be signed in to change notification settings - Fork 4
Shader Files
Firefly makes extensive use of shaders when displaying points. All shader files are written in GLSL (GL Shading Language), which closely resembles C syntax. Shaders in Firefly use a three tiered structure to generate a 2D Texture from 3D data.
The first shader to run is the point shader, which is run for every individual point within a pointCloud. The Vertex shader is intended to set the position of the point in projection space, as well as prepare certain attributes for the Geometry shader.
The attributes 'x', 'y' and 'z' are passed to the shader using the dimensions specified by the PointCloud.setDimensions()
variable. To account for changes in camera position and projection, you use the modelView
transformation matrix.
The size
attribute is passed to the shader from the pointCloud using the PointCloud.setSize(Dimension size) function, and is by default set to use Smoothing Length as the size dimension. The size can also be set to a fixed value using the
PointCloud.setPointScale()` function.
The datafilter
attribute is passed to the shader from the pointCloud using the `PointCloud.setData(Dimension dat) function.
The shader can also output the attributes attrib_size
and attrib_filter
to the geometry shader, and by default directly copies the attributes size
and datafilter
to those variables.
Geometry shaders are called immediately after vertex shaders on the same set of points. It is inteneded to transform a infinitesimal point particle to a larger "geometric" representation of the point with area, which is then used to calculate colormaps when sent to the Fragment shader
The attrib_filter
and attrib_size
attribute is passed to the shader from the vertex shader output attributes with the same names, which by default, are identical to the variables set using the PointCloud.setData
and PointCloud.setSize
functions.
The data
output attribute specifies the weight of a particular point when using the colormap.
The fragment shader, unlike the previous shaders, is called one time for every pixel in the current display. It is responsible for determining the exact color of every pixel in the 2d texture that is eventually displayed on screen.