Revision 809dcae3
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
23 | 23 |
import android.opengl.Matrix; |
24 | 24 |
|
25 | 25 |
import org.distorted.library.effect.EffectQuality; |
26 |
import org.distorted.library.effectqueue.EffectQueuePostprocess; |
|
26 | 27 |
import org.distorted.library.mesh.MeshBase; |
27 | 28 |
|
28 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
377 | 378 |
|
378 | 379 |
int renderChildren(long time, int numChildren, DistortedChildrenList children, int fbo, boolean oit) |
379 | 380 |
{ |
380 |
int quality=0, numRenders=0, bucketChange=0;
|
|
381 |
int numRenders=0, bucketChange=0; |
|
381 | 382 |
DistortedNode child; |
383 |
DistortedFramebuffer buffer=null; |
|
382 | 384 |
EffectQueuePostprocess lastQueue=null, currQueue; |
383 | 385 |
long lastBucket=0, currBucket; |
384 | 386 |
boolean renderDirectly=false; |
... | ... | |
431 | 433 |
} |
432 | 434 |
else |
433 | 435 |
{ |
434 |
for(int j=bucketChange; j<i; j++) numRenders += lastQueue.preprocess( mBuffer[quality],children.getChild(j) );
|
|
435 |
numRenders += lastQueue.postprocess(mBuffer[quality]);
|
|
436 |
for(int j=bucketChange; j<i; j++) numRenders += lastQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
|
|
437 |
numRenders += lastQueue.postprocess(buffer);
|
|
436 | 438 |
|
437 | 439 |
if( oit ) |
438 | 440 |
{ |
439 |
numRenders += oitBuild(time, mBuffer[quality], fbo);
|
|
441 |
numRenders += oitBuild(time, buffer, fbo);
|
|
440 | 442 |
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT | GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT); |
441 | 443 |
} |
442 | 444 |
else |
443 | 445 |
{ |
444 |
numRenders += blitWithDepth(time, mBuffer[quality],fbo);
|
|
446 |
numRenders += blitWithDepth(time, buffer, fbo);
|
|
445 | 447 |
} |
446 |
mBuffer[quality].clearBuffer(fbo);
|
|
448 |
buffer.clearBuffer(fbo);
|
|
447 | 449 |
} |
448 | 450 |
|
449 |
quality= currQueue.getQuality();
|
|
451 |
buffer= mBuffer[currQueue.getQuality()];
|
|
450 | 452 |
bucketChange= i; |
451 | 453 |
renderDirectly = currQueue.getRender(); |
452 | 454 |
} |
... | ... | |
467 | 469 |
} |
468 | 470 |
else |
469 | 471 |
{ |
470 |
mBuffer[quality].setAsOutput(time);
|
|
471 |
child.drawNoBlend(time, mBuffer[quality]);
|
|
472 |
buffer.setAsOutput(time);
|
|
473 |
child.drawNoBlend(time, buffer);
|
|
472 | 474 |
} |
473 | 475 |
|
474 | 476 |
if( i==numChildren-1 ) |
475 | 477 |
{ |
476 |
for(int j=bucketChange; j<numChildren; j++) numRenders += currQueue.preprocess( mBuffer[quality],children.getChild(j) );
|
|
477 |
numRenders += currQueue.postprocess(mBuffer[quality]);
|
|
478 |
for(int j=bucketChange; j<numChildren; j++) numRenders += currQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );
|
|
479 |
numRenders += currQueue.postprocess(buffer);
|
|
478 | 480 |
|
479 | 481 |
if( oit ) |
480 | 482 |
{ |
481 |
numRenders += oitBuild(time, mBuffer[quality], fbo);
|
|
483 |
numRenders += oitBuild(time, buffer, fbo);
|
|
482 | 484 |
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT | GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT); |
483 |
mBuffer[quality].clearBuffer(fbo);
|
|
485 |
buffer.clearBuffer(fbo);
|
|
484 | 486 |
} |
485 | 487 |
else |
486 | 488 |
{ |
487 |
numRenders += blitWithDepth(time, mBuffer[quality],fbo);
|
|
489 |
numRenders += blitWithDepth(time, buffer,fbo);
|
|
488 | 490 |
} |
489 | 491 |
} |
490 | 492 |
} // end else (postprocessed child) |
... | ... | |
550 | 552 |
DistortedRenderState.colorDepthStencilRestore(); |
551 | 553 |
} |
552 | 554 |
|
555 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
556 |
|
|
557 |
void setAsOutput(long time) |
|
558 |
{ |
|
559 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[mCurrFBO]); |
|
560 |
|
|
561 |
if( mTime[mCurrFBO]!=time ) |
|
562 |
{ |
|
563 |
mTime[mCurrFBO] = time; |
|
564 |
clear(); |
|
565 |
} |
|
566 |
} |
|
567 |
|
|
553 | 568 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
554 | 569 |
// PUBLIC API |
555 | 570 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
600 | 615 |
return numRenders; |
601 | 616 |
} |
602 | 617 |
|
603 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
604 |
/** |
|
605 |
* Bind this Surface as a Framebuffer we can render to. |
|
606 |
* |
|
607 |
* @param time Present time, in milliseconds. The point: looking at this param the library can figure |
|
608 |
* out if this is the first time during present frame that this FBO is being set as output. |
|
609 |
* If so, the library, in addition to binding the Surface for output, also clears the |
|
610 |
* Surface's color and depth attachments. |
|
611 |
*/ |
|
612 |
public void setAsOutput(long time) |
|
613 |
{ |
|
614 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[mCurrFBO]); |
|
615 |
|
|
616 |
if( mTime[mCurrFBO]!=time ) |
|
617 |
{ |
|
618 |
mTime[mCurrFBO] = time; |
|
619 |
clear(); |
|
620 |
} |
|
621 |
} |
|
622 |
|
|
623 | 618 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
624 | 619 |
/** |
625 | 620 |
* Bind this Surface as a Framebuffer we can render to. |
Also available in: Unified diff
Finally move the EffectQueues to their own package.