FXAA: quality regression fix

FXAA wants input texture to use bilinear filtering
so it can be smoothed further, so allow filters to
request bilinear filtering.
experimental
Kirill Vainer 9 years ago
parent 4fef16ee9f
commit 4a37a8f851
  1. 13
      jme3-core/src/main/java/com/jme3/post/Filter.java
  2. 12
      jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java
  3. 6
      jme3-effects/src/main/java/com/jme3/post/filters/FXAAFilter.java

@ -409,6 +409,19 @@ public abstract class Filter implements Savable {
return true;
}
/**
* Override this method and return true if you want the scene (input) texture
* to use bilinear filtering or false to use nearest filtering.
*
* Typically filters that perform samples <em>in between</em> pixels
* should enable filtering.
*
* @return true to use linear filtering, false to use nearest filtering.
*/
protected boolean isRequiresBilinear() {
return false;
}
/**
* returns the list of the postRender passes
* @return

@ -38,6 +38,7 @@ import com.jme3.renderer.*;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;
import com.jme3.ui.Picture;
import com.jme3.util.SafeArrayList;
@ -284,6 +285,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
mat.clearParam("NumSamples");
}
}
boolean wantsBilinear = filter.isRequiresBilinear();
if (wantsBilinear) {
tex.setMagFilter(Texture.MagFilter.Bilinear);
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
}
buff = outputBuffer;
if (i != lastFilterIndex) {
@ -293,6 +300,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable {
}
renderProcessing(r, buff, mat);
filter.postFilter(r, buff);
if (wantsBilinear) {
tex.setMagFilter(Texture.MagFilter.Nearest);
tex.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
}
}
}
}

@ -69,6 +69,12 @@ public class FXAAFilter extends Filter {
protected Material getMaterial() {
return material;
}
@Override
protected boolean isRequiresBilinear() {
// FXAA wants the input texture to be filtered.
return true;
}
public void setSpanMax(float spanMax) {
this.spanMax = spanMax;

Loading…
Cancel
Save