Class PostProcessEffect

java.lang.Object
com.massifmaps.renderers.PostProcessEffect

public class PostProcessEffect extends Object
A full-screen post-processing effect. When attached to the map via
MapRenderer::setPostProcessEffect, the map is rendered into an offscreen buffer
and the effect fragment shader produces the final screen output.

The fragment shader must be GLSL ES 1.00 (#version 100) source. The following
uniforms are provided by the renderer:
- sampler2D uColorTex: the rendered map frame (premultiplied alpha).
- sampler2D uTerrainDepthTex: packed terrain depth buffer (only if terrain depth is required;
RGB = 24-bit fixed point linear depth 0..1 relative to the far plane, A = terrain coverage).
Use dot(rgb, vec3(1.0, 1.0/255.0, 1.0/65025.0)) to unpack.
- vec2 uInvScreenSize: 1/width, 1/height of the screen in pixels.
- float uNear, uFar: view frustum distances (internal units).
- vec2 uProjInvScale: tan(fovy/2) * aspect, tan(fovy/2). With the terrain depth this
reconstructs the eye-space position of a pixel:
vec3(ndc * uProjInvScale, -1.0) * depth * uFar, ndc = uv * 2 - 1.
- float uTime: seconds since the effect was attached.
Additionally all float parameters set via setFloatParameter are available as float
uniforms, and all colors set via setColorParameter as vec4 uniforms (rgba 0..1).
Screen texture coordinates can be computed as gl_FragCoord.xy * uInvScreenSize.

Note: this class is experimental and may change or even be removed in future SDK versions.
  • Constructor Details

    • PostProcessEffect

      public PostProcessEffect(String name, String fragmentShader)
      Constructs a post-process effect from a fragment shader.
      Parameters:
      name - The name of the effect (used for shader caching, should be unique).
      fragmentShader - The GLSL ES 1.00 fragment shader source.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Checks if this object is equal to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - The reference object.
      Returns:
      True when objects are equal, false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash value of this object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash value of this object.
    • getName

      public String getName()
      Returns the name of the effect.
      Returns:
      The name of the effect.
    • getFragmentShader

      public String getFragmentShader()
      Returns the fragment shader source of the effect.
      Returns:
      The fragment shader source.
    • isTerrainDepthRequired

      public boolean isTerrainDepthRequired()
      Returns true if the effect needs the terrain depth pre-pass (uTerrainDepthTex).
      Returns:
      True if terrain depth is rendered for the effect. The default is false.
    • setTerrainDepthRequired

      public void setTerrainDepthRequired(boolean required)
      Sets whether the effect needs the terrain depth pre-pass.
      Parameters:
      required - True if the terrain depth should be rendered for the effect.
    • getFloatParameter

      public float getFloatParameter(String name)
      Returns the value of a float parameter.
      Parameters:
      name - The name of the parameter.
      Returns:
      The value of the parameter, or 0 if not set.
    • setFloatParameter

      public void setFloatParameter(String name, float value)
      Sets a float parameter. The parameter is exposed to the fragment shader as a uniform.
      Parameters:
      name - The name of the parameter (must be a valid GLSL identifier).
      value - The new value for the parameter.
    • getColorParameter

      public Color getColorParameter(String name)
      Returns the value of a color parameter.
      Parameters:
      name - The name of the parameter.
      Returns:
      The value of the parameter, or transparent black if not set.
    • setColorParameter

      public void setColorParameter(String name, Color color)
      Sets a color parameter. The parameter is exposed to the fragment shader as a vec4
      uniform with components in the 0..1 range.
      Parameters:
      name - The name of the parameter (must be a valid GLSL identifier).
      color - The new value for the parameter.