commit b10580210dde42758fd65c367d0714522a74a93d
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Jul 31 15:10:50 2018 +0100

    Postprocessing: adjust the Projection of the postprocessing buffers to match the Projection of the surface we are supposed to be rendering to.

diff --git a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
index fbca14b..35dbec1 100644
--- a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
@@ -73,7 +73,7 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
   // Global buffers used for postprocessing.
   private static DistortedFramebuffer[] mBuffer=null;
 
-  private float mFOV;
+  float mFOV;
   float mDistance, mNear;
   float[] mProjectionMatrix;
 
@@ -238,10 +238,14 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
 // set of them) so before we use them for output, we need to adjust the Viewport as if they were
 // smaller. That takes care of outputting pixels to them. When we use them as input, we have to
 // adjust the texture coords - see the get{Width|Height}Correction functions.
+//
+// Also, adjust the Buffers so their Projection is the same like the surface we are supposed to be
+// rendering to.
 
-  private static void clonePostprocessingViewport(DistortedOutputSurface from)
+  private static void clonePostprocessingViewportAndProjection(DistortedOutputSurface from)
     {
-    if( mBuffer[0].mWidth != from.mWidth || mBuffer[0].mHeight != from.mHeight )
+    if( mBuffer[0].mWidth != from.mWidth || mBuffer[0].mHeight != from.mHeight ||
+        mBuffer[0].mFOV   != from.mFOV   || mBuffer[0].mNear   != from.mNear    )
       {
       DistortedOutputSurface surface;
 
@@ -251,11 +255,9 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
 
         surface.mWidth  = (int)(from.mWidth *surface.mMipmap);
         surface.mHeight = (int)(from.mHeight*surface.mMipmap);
-
+        surface.mFOV    = from.mFOV;
         surface.mNear   = from.mNear;  // Near plane is independent of the mipmap level
 
-        //android.util.Log.e("surface", "viewport "+i+" to ("+from.mWidth+"x"+from.mHeight+")");
-
         surface.createProjection();
 
         int maxw = surface.mWidth  > surface.mRealWidth  ? surface.mWidth  : surface.mRealWidth;
@@ -450,7 +452,7 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
           {
           if( lastBucket==0 )
             {
-            clonePostprocessingViewport(this);
+            clonePostprocessingViewportAndProjection(this);
             }
           else
             {
