Project

General

Profile

« Previous | Next » 

Revision ae2802b1

Added by Leszek Koltunski about 6 years ago

Postprocessing buffers mBuffer[] are now shared among all postprocessing operations. This saves a lot of memory, but also means that when doing each particular postprocessing, the textures backing up the mBuffer might be too large. We need to fix two things here: when outputting to those too large textures, we need to adjust the Viewport, and when binding those too large textures as input - we need to adjust the TexCoords to compensate.

This commit does just that. Verified as working by the 'PostprocessTree' app.

View differences:

src/main/java/org/distorted/library/main/DistortedOutputSurface.java
331 331
    }
332 332

  
333 333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
// The postprocessing buffers mBuffer[] are generally speaking too large (there's just one static
335
// set of them) so before we use them for output, we need to adjust the Vieport as if they were
336
// smaller. That takes care of outputting pixels to them. When we use them as input, we have to
337
// adjust the texture coords - see the get{Width|Height}Correction functions.
334 338

  
335 339
  private static void cloneViewport(DistortedOutputSurface from)
336 340
    {
......
347 351

  
348 352
        surface.mNear   = from.mNear;  // Near plane is independent of the mipmap level
349 353

  
350
        android.util.Log.e("surface", "viewport "+i+" to ("+from.mWidth+"x"+from.mHeight+")");
354
        //android.util.Log.e("surface", "viewport "+i+" to ("+from.mWidth+"x"+from.mHeight+")");
351 355

  
352 356
        surface.createProjection();
353 357

  
......
380 384
    GLES31.glDisable(GLES31.GL_STENCIL_TEST);
381 385
    GLES31.glStencilMask(0x00);
382 386

  
383
    DistortedEffects.blitDepthPriv(this);
387
    DistortedEffects.blitDepthPriv(this, buffer.getWidthCorrection(), buffer.getHeightCorrection() );
384 388
    GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
385 389
    GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
386 390
    GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
......
476 480
    return mChildren;
477 481
    }
478 482

  
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484
/**
485
 * Not part of the Public API.
486
 *
487
 * @y.exclude
488
 */
489
  public float getWidthCorrection()
490
    {
491
    return (float)mWidth/mRealWidth;
492
    }
493

  
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495
/**
496
 * Not part of the Public API.
497
 *
498
 * @y.exclude
499
 */
500
  public float getHeightCorrection()
501
    {
502
    return (float)mHeight/mRealHeight;
503
    }
504

  
479 505
///////////////////////////////////////////////////////////////////////////////////////////////////
480 506
// PUBLIC API
481 507
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff