Class PostProcessShader

java.lang.Object
org.dark.shaders.post.PostProcessShader
All Implemented Interfaces:
ShaderAPI

public class PostProcessShader extends Object implements ShaderAPI
This implementation of ShaderAPI contains the general full-screen post-process shader. Do not modify.

Since:
Beta 1.07
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.dark.shaders.util.ShaderAPI

    ShaderAPI.RenderOrder
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int[]
     
    protected final int[]
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    advance(float amount, List<com.fs.starfarer.api.input.InputEventAPI> events)
    This method will be called for multiple shaders in a particular order, dictated by getRenderOrder().
    void
    This method is called when the current instance is destroyed, such as when the settings are reloaded.
    com.fs.starfarer.api.combat.CombatEngineLayers
    This method determines the combat rendering layer in which the shader is run.
    This method determines the order in which the shader is inserted in the rendering queue.
    void
    This method is called at the beginning of each combat instance.
    boolean
    This method returns whether this shader is rendered within a combat layer or not.
    boolean
    This method returns whether this shader is enabled or not.
    void
    renderInScreenCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
    This method is called before advance() and before the UI is drawn.
    void
    renderInWorldCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
    This method is called before advance() and before the UI is drawn.
    static void
    Resets the post-processing shader to the default settings, taking into account color blindness options.
    static void
    setBlueHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the blue color range.
    static void
    setContrast(boolean post, float amount)
    Sets the screen's contrast to the given amount.
    static void
    setGreenHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the green color range.
    static void
    setHueShift(boolean post, float degrees)
    Shifts the screen's hue by the given amount.
    static void
    setLightness(boolean post, float amount)
    Sets the screen's lightness to the given amount.
    static void
    setMagentaHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the magenta color range.
    static void
    setNoise(boolean post, float amount)
    Gives the screen some degree of black noise.
    static void
    setRedHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the red color range.
    static void
    setSaturation(boolean post, float amount)
    Sets the screen's color saturation to the given amount.
    static void
    setScanLines(boolean post, float amount, int interval, int width)
    Gives the screen CRT-style scan lines.
    static void
    setTealHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the teal color range.
    static void
    setYellowHSL(boolean post, float hue, float saturation, float lightness)
    Sets the hue shift, saturation, and lightness for the yellow color range.
    static void
    useExponentialDarkness(boolean post, boolean value)
    Sets the lightness function to use an exponential curve when lightness is below 1.
    static void
    useExponentialDesaturation(boolean post, boolean value)
    Sets the saturation function to use an exponential curve when saturation is below 1.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • indexPost

      protected final int[] indexPost
    • indexPre

      protected final int[] indexPre
    • programPost

      protected int programPost
    • programPre

      protected int programPre
  • Constructor Details

    • PostProcessShader

      public PostProcessShader()
  • Method Details

    • resetDefaults

      public static void resetDefaults()
      Resets the post-processing shader to the default settings, taking into account color blindness options.

      Since:
      Beta 1.07
    • setBlueHSL

      public static void setBlueHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the blue color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • setContrast

      public static void setContrast(boolean post, float amount)
      Sets the screen's contrast to the given amount.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      amount - The desired contrast. 1 is the default; 0 is completely gray.

      Since:
      Beta 1.07
    • setGreenHSL

      public static void setGreenHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the green color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • setHueShift

      public static void setHueShift(boolean post, float degrees)
      Shifts the screen's hue by the given amount.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      degrees - How much, in degrees, to shift the screen's hue by. For reference, 0 degrees is red, 120 degrees is green, and 240 degrees is blue.

      Since:
      Beta 1.07
    • setLightness

      public static void setLightness(boolean post, float amount)
      Sets the screen's lightness to the given amount.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      amount - The desired lightness. 1 is the default; 0 is completely black.

      Since:
      Beta 1.07
    • setMagentaHSL

      public static void setMagentaHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the magenta color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • setNoise

      public static void setNoise(boolean post, float amount)
      Gives the screen some degree of black noise.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      amount - The desired screen noise intensity. 0 is the default (off); 1 is completely noisy.

      Since:
      Beta 1.07
    • setRedHSL

      public static void setRedHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the red color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • setSaturation

      public static void setSaturation(boolean post, float amount)
      Sets the screen's color saturation to the given amount.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      amount - The desired saturation. 1 is the default; 0 is completely monochrome.

      Since:
      Beta 1.07
    • setScanLines

      public static void setScanLines(boolean post, float amount, int interval, int width)
      Gives the screen CRT-style scan lines.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      amount - The desired scan line intensity. 0 is the default (off); 1 is completely black.

      interval - The interval, given in rows of pixels, by which scan lines are generated. For example, interval 3 means that there is one scan line per three rows of pixels.

      width - The width, in rows of pixels, of each scan line.

      Since:
      Beta 1.07
    • setTealHSL

      public static void setTealHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the teal color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • setYellowHSL

      public static void setYellowHSL(boolean post, float hue, float saturation, float lightness)
      Sets the hue shift, saturation, and lightness for the yellow color range.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      hue - How much, in degrees, to shift the screen's hue by, for the given color range.

      saturation - The desired saturation, for the given color range.

      lightness - The desired lightness, for the given color range.

      Since:
      Beta 1.07
    • useExponentialDarkness

      public static void useExponentialDarkness(boolean post, boolean value)
      Sets the lightness function to use an exponential curve when lightness is below 1. Note: If lightness is above 1, an exponential curve is always used.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      value - Whether to use exponential darkness. Default off.

      Since:
      Beta 1.07
    • useExponentialDesaturation

      public static void useExponentialDesaturation(boolean post, boolean value)
      Sets the saturation function to use an exponential curve when saturation is below 1. Note: If saturation is above 1, an exponential curve is always used.

      Note: This must be called at minimum one frame after combat is initiated, because the settings are overridden by defaults (such as color blind mode) on the first frame. Note: color blind mode is a post-shader effect.

      Parameters:
      post - Selects whether the effect should apply to the pre-shader or post-shader. Set to true to affect the entire screen including UI; set to false to exclude the main UI. Effects can be independently stacked/chained between both steps, as each is a separate shader object.

      value - Whether to use exponential desaturation. Default off.

      Since:
      Beta 1.07
    • advance

      public void advance(float amount, List<com.fs.starfarer.api.input.InputEventAPI> events)
      Description copied from interface: ShaderAPI
      This method will be called for multiple shaders in a particular order, dictated by getRenderOrder(). Make sure that data updates and bookkeeping are done within an advance() method.

      Specified by:
      advance in interface ShaderAPI
      Parameters:
      amount - The amount of time since the last frame.
      events - A list of general input events.
    • destroy

      public void destroy()
      Description copied from interface: ShaderAPI
      This method is called when the current instance is destroyed, such as when the settings are reloaded.

      Specified by:
      destroy in interface ShaderAPI
    • getRenderOrder

      public ShaderAPI.RenderOrder getRenderOrder()
      Description copied from interface: ShaderAPI
      This method determines the order in which the shader is inserted in the rendering queue. This method is read every frame. Note that this is only used if isCombat() is false.

      Specified by:
      getRenderOrder in interface ShaderAPI
      Returns:
      The order by which the shader will render.
    • initCombat

      public void initCombat()
      Description copied from interface: ShaderAPI
      This method is called at the beginning of each combat instance.
      Specified by:
      initCombat in interface ShaderAPI
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: ShaderAPI
      This method returns whether this shader is enabled or not.

      Specified by:
      isEnabled in interface ShaderAPI
      Returns:
      Whether this shader is enabled or not.

    • renderInScreenCoords

      public void renderInScreenCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
      Description copied from interface: ShaderAPI
      This method is called before advance() and before the UI is drawn. Warning: only called if isCombat() is false!

      Specified by:
      renderInScreenCoords in interface ShaderAPI
      Parameters:
      viewport - The screen-based coordinates to draw with.
    • renderInWorldCoords

      public void renderInWorldCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
      Description copied from interface: ShaderAPI
      This method is called before advance() and before the UI is drawn.

      Specified by:
      renderInWorldCoords in interface ShaderAPI
      Parameters:
      viewport - The world-based coordinates to draw with.
    • getCombatLayer

      public com.fs.starfarer.api.combat.CombatEngineLayers getCombatLayer()
      Description copied from interface: ShaderAPI
      This method determines the combat rendering layer in which the shader is run. This method is read every frame. Note that this is only used if isCombat() is true.

      Specified by:
      getCombatLayer in interface ShaderAPI
      Returns:
      The layer in which the shader will render.

    • isCombat

      public boolean isCombat()
      Description copied from interface: ShaderAPI
      This method returns whether this shader is rendered within a combat layer or not.

      Specified by:
      isCombat in interface ShaderAPI
      Returns:
      Whether this shader is rendered within a combat layer.