commit 5fdae11dfe68a250658acdbe53717663a61c21f3
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed May 23 13:56:26 2018 +0100

    OIT: more fixes

diff --git a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
index 7bdc82c..96bb1b8 100644
--- a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
@@ -299,14 +299,19 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
     float corrH = getHeightCorrection();
 
     GLES31.glViewport(0, 0, mWidth, mHeight);
-    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
-    GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
-    GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[0]);
 
-    DistortedRenderState.switchOffColorDepthStencil();
-    DistortedEffects.oitCollapse(this, corrW, corrH );
+    // Do the Collapse Pass only if we do have a Depth attachment.
+    // Otherwise there's no point (in fact we then would create a feedback loop!)
 
-    GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
+    if( mDepthStencilH[0] != 0 )
+      {
+      GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
+      GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
+      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[0]);
+      DistortedRenderState.switchOffColorDepthStencil();
+      DistortedEffects.oitCollapse(this, corrW, corrH);
+      GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
+      }
 
     setAsOutput(currTime);
     DistortedRenderState.switchColorDepthOnStencilOff();
