Permalink
Browse files

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.
  • Loading branch information...
1 parent 4fef16e commit 4a37a8f8514c67613c0874ef1ff15825a939e3f1 @shadowislord shadowislord committed Sep 23, 2015
@@ -410,6 +410,19 @@ protected boolean isRequiresSceneTexture() {
}
/**
+ * 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.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 @@ private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {
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 @@ private void renderFilterChain(Renderer r, FrameBuffer sceneFb) {
}
renderProcessing(r, buff, mat);
filter.postFilter(r, buff);
+
+ if (wantsBilinear) {
+ tex.setMagFilter(Texture.MagFilter.Nearest);
+ tex.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
+ }
}
}
}
@@ -69,6 +69,12 @@ protected void initFilter(AssetManager manager,
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;

0 comments on commit 4a37a8f

Please sign in to comment.