Project

General

Profile

« Previous | Next » 

Revision 9455da17

Added by Leszek Koltunski over 6 years ago

Fix for bug #28: looks of the borders of a blurred object depend on if the object is the first in the postprocessing bucket.

View differences:

src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
178 178
    buffer.bindForOutput(1);
179 179
    buffer.setAsInput(0);
180 180

  
181
    GLES31.glColorMask(true,true,true,true);
182
    GLES31.glClearColor(1.0f,1.0f,1.0f,0.0f);
183
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
184

  
181 185
    GLES31.glUniform1f ( mProgram1.mUniform[0] , n );
182 186
    GLES31.glUniform2f ( mProgram1.mUniform[1] , corrW, corrH );
183 187
    GLES31.glUniform1i ( mProgram1.mUniform[2] , 0 );
......
195 199
    buffer.bindForOutput(0);
196 200
    buffer.setAsInput(1);
197 201

  
198
    GLES31.glColorMask(true,true,true,true);
199
    GLES31.glClearColor(1.0f,1.0f,1.0f,0.0f);
200 202
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
201 203

  
202 204
    GLES31.glUniform1f ( mProgram2.mUniform[0] , n );
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
183 183
    outBuffer.bindForOutput(1);
184 184
    inBuffer.setAsInput(0);
185 185

  
186
    GLES31.glColorMask(true,true,true,true);
187
    GLES31.glClearColor(1.0f,1.0f,1.0f,0.0f);
188
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
189

  
186 190
    GLES31.glUniform1f ( mProgram1.mUniform[0] , n );
187 191
    GLES31.glUniform2f ( mProgram1.mUniform[1] , corrW, corrH );
188 192
    GLES31.glUniform1i ( mProgram1.mUniform[2] , 0 );
src/main/java/org/distorted/library/main/DistortedOutputSurface.java
306 306
    GLES31.glStencilMask(0xff);
307 307
    GLES31.glDepthMask(true);
308 308
    GLES31.glColorMask(true,true,true,true);
309
    GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
309
    GLES31.glClearColor(1.0f,1.0f,1.0f,0.0f);
310 310
    GLES31.glClearDepthf(1.0f);
311 311
    GLES31.glClearStencil(0);
312 312

  
......
410 410
///////////////////////////////////////////////////////////////////////////////////////////////////
411 411
// Render all children, one by one. If there are no postprocessing effects, just render to THIS.
412 412
// Otherwise, render to a buffer and on each change of Postprocessing Bucket, apply the postprocessing
413
// to a whole buffer and merge it.
413
// to a whole buffer (lastQueue.postprocess) and merge it (this.blitWithDepth).
414 414

  
415 415
  int renderChildren(long time, int numChildren, ArrayList<DistortedNode> children)
416 416
    {
......
442 442

  
443 443
            numRenders += lastQueue.postprocess(mBuffer);
444 444
            numRenders += blitWithDepth(time, mBuffer[quality]);
445

  
446
            mBuffer[quality].setAsOutputAndClear(time);
445 447
            }
446 448

  
447 449
          internalQuality = currQueue.getInternalQuality();
......
502 504
    return (float)mHeight/mRealHeight;
503 505
    }
504 506

  
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508
/**
509
 * Bind this Surface as a Framebuffer we can render to; always clear it's color bit.
510
 *
511
 * Useful for drawing to the postprocessing buffer, which must sometimes be cleared multiple times
512
 * per frame.
513
 */
514

  
515
  private void setAsOutputAndClear(long time)
516
    {
517
    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
518

  
519
    mTime = time;    // have to do this otherwise on the next setAsOutput() we would clear
520
    DistortedRenderState.colorDepthStencilOn();
521
    GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA);
522
    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
523
    DistortedRenderState.colorDepthStencilRestore();
524
    }
525

  
505 526
///////////////////////////////////////////////////////////////////////////////////////////////////
506 527
// PUBLIC API
507 528
///////////////////////////////////////////////////////////////////////////////////////////////////
......
603 624
      GLES31.glClearStencil(mClearStencil);
604 625
      GLES31.glClear(mClear);
605 626
      DistortedRenderState.colorDepthStencilRestore();
606

  
627
/*
607 628
      if( mSSBO[0]>=0 )
608 629
        {
609 630
        // yes, this DOES keep on working when 'value' overflows into negative territory.
610 631
        int value = mIntBuffer.get(FRAME_DELAY*mSurfaceID+mLastIndex);
611
/*
632

  
612 633
        if( value-mLastValue[mLastIndex]!=mLastDiff )
613 634
          {
614 635
          android.util.Log.d("surface", "id " + mSurfaceID +
......
617 638
                             + " avg: " + (mAvgSum/RUNNING_AVERAGE)
618 639
                            );
619 640
          }
620
*/
641

  
621 642
        mLastDiff = value-mLastValue[mLastIndex];
622 643
        mLastValue[mLastIndex] = value;
623 644

  
......
627 648
        }
628 649

  
629 650
      if( ++mLastIndex >= FRAME_DELAY ) mLastIndex=0;
651
*/
630 652
      }
631 653
    }
632 654

  
src/main/java/org/distorted/library/main/EffectQueue.java
102 102
    }
103 103

  
104 104
///////////////////////////////////////////////////////////////////////////////////////////////////
105
// Every effect queue has an ID, which should be the same iff two queues hold the same effects.
106
// (this is a speedup: then both queues can be applied once, which seriously speeds up stuff -
107
// especially important in case of postprocessing)
105 108

  
106 109
  void regenerateIDandSort()
107 110
    {

Also available in: Unified diff