Revision 8777ce17
Added by Leszek Koltunski about 6 years ago
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
390 | 390 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
391 | 391 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
392 | 392 |
|
393 |
// clear buffers |
|
393 |
return 1; |
|
394 |
} |
|
395 |
|
|
396 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
397 |
|
|
398 |
private int blitWithDepthRender(long currTime, DistortedOutputSurface buffer) |
|
399 |
{ |
|
400 |
GLES31.glViewport(0, 0, mWidth, mHeight); |
|
401 |
setAsOutput(currTime); |
|
402 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
|
403 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mDepthStencilH[0]); |
|
404 |
|
|
405 |
DistortedRenderState.enableStencil(); |
|
406 |
|
|
407 |
DistortedEffects.blitDepthRenderPriv(this, buffer.getWidthCorrection(), buffer.getHeightCorrection() ); |
|
408 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
|
409 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
|
410 |
|
|
411 |
DistortedRenderState.restoreStencil(); |
|
412 |
|
|
413 |
return 1; |
|
414 |
} |
|
415 |
|
|
416 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
417 |
|
|
418 |
private void clearBuffer(DistortedOutputSurface buffer) |
|
419 |
{ |
|
394 | 420 |
GLES31.glStencilMask(0xff); |
395 | 421 |
GLES31.glDepthMask(true); |
396 | 422 |
GLES31.glColorMask(true,true,true,true); |
... | ... | |
403 | 429 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT); |
404 | 430 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[0], 0); |
405 | 431 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT); |
406 |
|
|
407 |
return 1; |
|
408 | 432 |
} |
409 | 433 |
|
410 | 434 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
442 | 466 |
|
443 | 467 |
numRenders += lastQueue.postprocess(mBuffer); |
444 | 468 |
numRenders += blitWithDepth(time, mBuffer[quality]); |
445 |
|
|
446 |
mBuffer[quality].setAsOutputAndClear(time); |
|
469 |
clearBuffer(mBuffer[quality]); |
|
447 | 470 |
} |
448 | 471 |
|
449 | 472 |
internalQuality = currQueue.getInternalQuality(); |
... | ... | |
465 | 488 |
|
466 | 489 |
numRenders += currQueue.postprocess(mBuffer); |
467 | 490 |
numRenders += blitWithDepth(time, mBuffer[quality]); |
491 |
numRenders += blitWithDepthRender(time,mBuffer[quality]); // merge the OIT linked list |
|
492 |
clearBuffer(mBuffer[quality]); |
|
468 | 493 |
} |
469 | 494 |
} |
470 | 495 |
|
... | ... | |
504 | 529 |
return (float)mHeight/mRealHeight; |
505 | 530 |
} |
506 | 531 |
|
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 |
|
|
526 | 532 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
527 | 533 |
// PUBLIC API |
528 | 534 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Order Independent Transparency. Does not work yet.