OpenGL Particle Shader
 
 
 

OGL Particle Shader Type | Type (Primitive) | Type (HW Acc. Sprites) | Type (Billboard) | Type (Velocity Vectors) | Type (Density) | Type (Line Trails) | Lighting and Blending | Render Tree Usage

Category: RealTime > OpenGL

Shader Family: Realtime

Output: Realtime

The OpenGL Particle shader allows for the realtime shading of particles in a 3D view set to the OpenGL display mode. This realtime particle shader implements multiple shader types within a single node. Each shader type applies a different realtime effect to the particle cloud.

NoteThe OpenGL Particle shader is provided as an integrated working example of how you can override the viewing attributes in Softimage by writing your own realtime particle shader. The source code for the OpenGL Particle shader is available from <Install_Path>\XSISDK\examples\realtimeshader\Particles\OGL.

Type (Primitive)

Shader Type

Primitive: Draws each particle point as a specific primitive type such as a sphere, snowflake, cube, etc.

Primitive

Primitive Type

Specifies the type of primitive used to draw the particle. You can choose Points, Cubes, Spheres (Solid), Spheres (Wireframe), Snowflake, Debris, Quad, or Arrows.

Point Size

Sets the size (width) of the point primitive in pixels. The default is 1.0.

Available when Primitive Type is set to Points.

Smooth Point

Enables primitive antialiasing.

Available when Primitive Type is set to Points.

Stretch Along Velocity

Stretches the primitive along the length of each particle's velocity vector.

Available when Primitive Type is set to Cubes, Spheres (Solid), Spheres (Wireframe), Snowflake, Debris, Quad, or Arrows.

Use GPU Instancing

GPU instancing is way of transforming the particles using the GPU which can double your render speeds, particularly for very large particle clouds. Instead of transforming the vertices of the primitive on the CPU (basically positioning each particle and then rendering an instance), the GPU renders the instance and then passes the position as an attribute of the vertex. The position of the particle is retrieved and transformed in the vertex shader.

When disabled, the primitive is rendered using the traditional method of transforming the instances on the CPU.

Available when Primitive Type is set to Cubes, Spheres (Solid), Spheres (Wireframe), Snowflake, Debris, Quad, or Arrows.

Custom Fragment Shader

Opens a text editor where you can enter the code for a fragment shader. This allows you to override the fixed functionality part of the pipeline with your own custom fragment shader code.

Available when Primitive Type is set to Cubes, Spheres (Solid), Spheres (Wireframe), Snowflake, Debris, Quad, or Arrows.

Fragment Shader

The text editor widget supports text customization (font, color, size), syntax styling, folding (hiding blocks such as functions and subroutines), auto-completion and highlighting for keywords.

To implement this text editor widget in your own plug-ins, see Text Editor Widget [SDK Guide].

Sprite Settings

Sprite Layout

When you are using a texture as a sprite, you can use the entire image as a tile (Single) or you can separate the texture into tiles of 2x2, 3x3, 4x4, all the way up to 8x8. The texture's coordinates are updated to use only the tile portion specified by this option.

This is particularly useful if you're using a multi-image texture (such as the image below) to achieve texture animation in the sprite.

Type (HW Acc. Sprites)

Shader Type

HW Accelerated Sprites: Draws OpenGL hardware accelerated point sprites at each point position.

Primitive

Point Size

Sets the size (width) of the point primitive in pixels. The default is 1.0.

Sprite Settings

Point Size Minimum

Sets the attenuated minimum point size. The default is 0.0. Values less than zero are invalid.

Note: If you set the minimum point size greater than the maximum point size then the point size will be undefined.

Point Size Max

Sets the attenuated maximum point size. Values less than zero are invalid.

Fade Threshold

Sets the threshold for alpha attenuation. This fades the point alpha when the point width goes below the given threshold. Values less than zero are invalid.

Attenuation

Attenuation is the effect of points appearing to diminish in size as a function of distance. Each point has constant, linear, and quadratic attenuation factors that are taken into account when the point size is computed.

Constant

Allows the size of a point to be affected by constant distance attenuation.

Linear

Allows the size of a point to be affected by linear distance attenuation.

Quadratic

Allows the size of a point to be affected by quadratic distance attenuation.

Type (Billboard)

Shader Type

Billboard Sprites: Draws billboard sprites for each point primitive using the OpenGL point sprite extension. This shader is similar to the hardware accelerated sprites shader, expect that billboard sprites are expanded on the CPU and then sent to the GPU. This means that the size of the sprites remain the same regardless of the viewing angle.

Sprite Settings

Sprite Layout

When you are using a texture as a sprite, you can use the entire image as a tile (Single) or you can separate the texture into tiles of 2x2, 3x3, 4x4, all the way up to 8x8. The texture's coordinates are updated to use only the tile portion specified by this option.

This is particularly useful if you're using a multi-image texture (such as the image below) to achieve texture animation in the sprite.

Type (Velocity Vectors)

Shader Type

Velocity Vectors: Draws a line behind each point primitive, the length of which is dependent on the particle's velocity.

Sprite Settings

Sprite Layout

When you are using a texture as a sprite, you can use the entire image as a tile (Single) or you can separate the texture into tiles of 2x2, 3x3, 4x4, all the way up to 8x8. The texture's coordinates are updated to use only the tile portion specified by this option.

This is particularly useful if you're using a multi-image texture (such as the image below) to achieve texture animation in the sprite.

Type (Density)

Shader Type

Density: Draws each point and displays the cloud density encoded as colors. For each point, the density shader will check the distance of neighboring particles and, depending on the Density Falloff and Density Limit, will shade the point using the Sparse or Dense color settings. This shader is useful for visualizing the density of particle clouds.

Primitive

Point Size

Sets the size (width) of the point primitive in pixels. The default is 1.0.

Smooth Point

Enables primitive antialiasing.

Density Field

Density Falloff

Sets the rate at which the particle color blends from the Dense color to the Sparse color, and vise versa.

Density Limit (in # of particles)

Sets the number of particles whose proximity to each other (based on a hard-coded distance to neighboring particles) is considered dense.

Sparse

Sets the color to shade the particles that are considered sparse in terms of their proximity to each other.

Dense

Sets the color to shade the particles that are considered dense in terms of their proximity to each other.

Type (Line Trails)

Shader Type

Line Trails: Draws particle trails as lines.

Primitive

Use GPU Instancing

GPU instancing is way of transforming the particles using the GPU which can double your render speeds, particularly for very large particle clouds. Instead of transforming the vertices of the primitive on the CPU (basically positioning each particle and then rendering an instance), the GPU renders the instance and then passes the position as an attribute of the vertex. The position of the particle is retrieved and transformed within the vertex shader.

Custom Fragment Shader

Opens a text editor where you can enter the code for a fragment shader. This allows you to override the fixed functionality part of the pipeline with your own custom fragment shader code.

Fragment Shader

The text editor widget supports text customization (font, color, size), syntax styling, folding (hiding blocks such as functions and subroutines), auto-completion and highlighting for keywords.

To implement this text editor widget in your own plug-ins, see Text Editor Widget [SDK Guide].

Lighting and Blending

Use OpenGL Lighting

Turns on or off lighting. GL lighting produces a primary and secondary color for each vertex. The effects from enabled light sources are used in conjunction with surface material properties to determine the lit color at a particular vertex.

Blending

In RGBA mode, pixels can be drawn using a function (glBlendFunc) that blends the incoming (source) RGBA values with the RGBA values that are already in the frame buffer (the destination values). For more information, see How Blending Works.

Use Blending

Enable or disable blending. When enabled, the blend function defines the operation of blending.

BlendScr

The blend source factor (sfactor) specifies which method is used to scale the source color components.

Select one of the supported methods from the drop-down menu. Each method defines four scale factors, one each for red, green, blue, and alpha. All scale factors have range [0,1].

BlendDest

The blend destination factor (dfactor) specifies which method is used to scale the destination color components.

Select one of the supported methods from the drop-down menu. Each method defines four scale factors, one each for red, green, blue, and alpha. All scale factors have range [0,1].

Alpha Testing

Alpha testing (glAlphaFunc) discards fragments depending on the outcome of a comparison between an incoming fragment's alpha value and a constant reference value. The alpha test specifies the reference value and the comparison function. The comparison is performed only if alpha testing is enabled.

The alpha function and alpha reference specify the conditions under which the pixel is drawn. The incoming alpha value is compared to AlphaRef using the function specified by AlphaFunc. If the value passes the comparison, the incoming fragment is drawn if it also passes subsequent stencil and depth buffer tests. If the value fails the comparison, no change is made to the frame buffer at that pixel location.

Alpha testing operates on all pixel write operations, including those resulting from the scan conversion of points, lines, polygons, and bitmaps, and from pixel draw and copy operations. It does not affect screen clear operations.

NoteAlpha testing is performed only in RGBA mode.

Perform Alpha Testing

Enable or disable alpha testing.

AlphaFunc

Specifies the alpha comparison function (func).

Select one of the supported comparison functions from the drop-down menu. The functions are defined as follows:

  • ¥GL_NEVER

    Never passes.

  • GL_LESS

    Passes if the incoming alpha value is less than the reference value.

  • GL_EQUAL

    Passes if the incoming alpha value is equal to the reference value.

  • GL_LEQUAL

    Passes if the incoming alpha value is less than or equal to the reference value.

  • GL_GREATER

    Passes if the incoming alpha value is greater than the reference value.

  • GL_NOTEQUAL

    Passes if the incoming alpha value is not equal to the reference value.

  • GL_GEQUAL

    Passes if the incoming alpha value is greater than or equal to the reference value.

  • GL_ALWAYS

    Always passes.

AlphaRef

Specifies the reference value (ref) that incoming alpha values are compared to. This value is clamped to the range [0,1], where 0 represents the lowest possible alpha value and 1 the highest possible value.

Render Tree Usage

This is a typical render tree set up using the OGL Particle shader.