package de.bitbrain.braingdx.graphics.postprocessing;

import de.bitbrain.braingdx.event.GameEventManager;
import de.bitbrain.braingdx.graphics.GraphicsSettings;
import de.bitbrain.braingdx.graphics.event.GraphicsSettingsChangeEvent;
import de.bitbrain.braingdx.graphics.postprocessing.effects.Bloom;
import de.bitbrain.braingdx.graphics.postprocessing.effects.Fxaa;
import de.bitbrain.braingdx.graphics.postprocessing.effects.Vignette;
import de.bitbrain.braingdx.graphics.postprocessing.effects.Zoomer;

public class ShaderManager {

   private final GameEventManager gameEventManager;
   private final GraphicsSettings settings;

   public ShaderManager(GameEventManager gameEventManager, GraphicsSettings settings) {
      this.gameEventManager = gameEventManager;
      this.settings = settings;
   }

   public AutoReloadPostProcessorEffect<Fxaa> createFxaaEffect() {
      return createEffect(new EffectFactory<Fxaa>() {
         @Override
         public Fxaa create(Fxaa original, int newWidth, int newHeight, GraphicsSettings settings) {
            return new Fxaa(newWidth, newHeight);
         }
      });
   }

   public AutoReloadPostProcessorEffect<Bloom> createBloomEffect() {
      return createEffect(new EffectFactory<Bloom>() {
         @Override
         public Bloom create(Bloom original, int newWidth, int newHeight, GraphicsSettings settings) {
            Bloom bloom = new Bloom(newWidth, newHeight);
            if (original != null) {
               bloom.setBaseIntesity(original.getBaseIntensity());
               bloom.setBaseSaturation(original.getBaseSaturation());
               bloom.setBloomIntesity(original.getBloomIntensity());
               bloom.setBloomSaturation(original.getBloomSaturation());
               bloom.setBlurAmount(original.getBlurAmount());
               bloom.setBlurPasses(original.getBlurPasses());
               bloom.setSettings(original.getSettings());
               bloom.setBlurType(original.getBlurType());
               bloom.setThreshold(original.getThreshold());
            }
            return bloom;
         }
      });
   }

   public AutoReloadPostProcessorEffect<Vignette> createVignetteEffect() {
      return createEffect(new EffectFactory<Vignette>() {
         @Override
         public Vignette create(Vignette original, int newWidth, int newHeight, GraphicsSettings settings) {
            Vignette vignette = new Vignette(newWidth, newHeight, false);
            if (original != null) {
               vignette.setCenter(original.getCenterX(), original.getCenterY());
               vignette.setCoords(original.getCoordsX(), original.getCoordsY());
               vignette.setIntensity(original.getIntensity());
               vignette.setLutTexture(original.getLut());
               vignette.setLutIntensity(original.getLutIntensity());
               vignette.setSaturation(original.getSaturation());
               vignette.setSaturationMul(original.getSaturationMul());
               vignette.setEnabled(original.isEnabled());
            }
            return vignette;
         }
      });
   }

   public AutoReloadPostProcessorEffect<Zoomer> createZoomerEffect() {
      return createEffect(new EffectFactory<Zoomer>() {
         @Override
         public Zoomer create(Zoomer original, int newWidth, int newHeight, GraphicsSettings settings) {
            Zoomer zoomer = new Zoomer(newWidth, newHeight);
            if (original != null) {
               zoomer.setBlurStrength(original.getBlurStrength());
               zoomer.setZoom(original.getZoom());
               zoomer.setOrigin(original.getOriginX(), original.getOriginY());
            }
            return zoomer;
         }
      });
   }

   private <T extends PostProcessorEffect> AutoReloadPostProcessorEffect<T> createEffect(EffectFactory<T> factory) {
      AutoReloadPostProcessorEffect<T> effect = new AutoReloadPostProcessorEffect<T>(factory, settings);
      gameEventManager.register(effect, GraphicsSettingsChangeEvent.class);
      return effect;
   }
}

@@ -499,16 +499,84 @@
 oomer;%0A%0A
+/**%0A * Provides factory methods to create a variety of shaders.%0A */%0A
 public c
@@ -860,32 +860,191 @@
 settings;%0A   %7D%0A%0A
+%0A   /**%0A    * Creates an anti-aliasing effect to reduce aliasing.%0A    * It is recommended placing this effect always on top of other effects or layers.%0A    */%0A
    public AutoRe
@@ -1337,32 +1337,123 @@
       %7D);%0A   %7D%0A%0A
+   /**%0A    * Creates a bloom effect which blurs light parts and darkens dark parts.%0A    */%0A
    public AutoRe
@@ -2413,32 +2413,111 @@
       %7D);%0A   %7D%0A%0A
+   /**%0A    * Creates an effect which darkens the corners of the screen.%0A    */%0A
    public AutoRe
@@ -3483,24 +3483,129 @@
   %7D);%0A   %7D%0A%0A
+   /**%0A    * Creates an effect which zooms in our out of the current scene with a blurred effect.%0A    */%0A
    public Au

add javadoc