54 |
54 |
|
55 |
55 |
private ArrayList<DistortedNode> mChildren;
|
56 |
56 |
private int mNumChildren; // ==mChildren.length(), but we only create mChildren if the first one gets added
|
|
57 |
private boolean mRenderWayOIT;
|
57 |
58 |
|
58 |
59 |
private class Job
|
59 |
60 |
{
|
... | ... | |
99 |
100 |
{
|
100 |
101 |
super(width,height,createColor,numfbos,numcolors,type);
|
101 |
102 |
|
|
103 |
mRenderWayOIT = false;
|
|
104 |
|
102 |
105 |
mDepthStencilH = new int[numfbos];
|
103 |
106 |
mFBOH = new int[numfbos];
|
104 |
107 |
|
... | ... | |
379 |
382 |
// Otherwise, render to a buffer and on each change of Postprocessing Bucket, apply the postprocessing
|
380 |
383 |
// to a whole buffer (lastQueue.postprocess) and merge it (this.oitBuild).
|
381 |
384 |
|
382 |
|
int renderChildren(long time, int numChildren, ArrayList<DistortedNode> children, int fbo)
|
|
385 |
int renderChildren(long time, int numChildren, ArrayList<DistortedNode> children, int fbo, boolean oit)
|
383 |
386 |
{
|
384 |
387 |
int quality=0, internalQuality = 0, numRenders = 0, bucketChange = 0;
|
385 |
388 |
DistortedNode child1, child2;
|
... | ... | |
406 |
409 |
if( lastBucket==0 )
|
407 |
410 |
{
|
408 |
411 |
clonePostprocessingViewport(this);
|
409 |
|
oitClear(this);
|
|
412 |
|
|
413 |
if( oit )
|
|
414 |
{
|
|
415 |
oitClear(this);
|
|
416 |
}
|
410 |
417 |
}
|
411 |
418 |
else
|
412 |
419 |
{
|
... | ... | |
418 |
425 |
}
|
419 |
426 |
|
420 |
427 |
numRenders += lastQueue.postprocess(mBuffer,fbo);
|
421 |
|
numRenders += oitBuild(time,mBuffer[quality],fbo);
|
422 |
|
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT|GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT);
|
|
428 |
|
|
429 |
if( oit )
|
|
430 |
{
|
|
431 |
numRenders += oitBuild(time, mBuffer[quality], fbo);
|
|
432 |
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT | GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT);
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{
|
|
436 |
numRenders += blitWithDepth(time, mBuffer[quality],fbo);
|
|
437 |
}
|
423 |
438 |
mBuffer[quality].clearBuffer(fbo);
|
424 |
439 |
}
|
425 |
440 |
|
... | ... | |
441 |
456 |
}
|
442 |
457 |
|
443 |
458 |
numRenders += currQueue.postprocess(mBuffer,fbo);
|
444 |
|
numRenders += oitBuild(time,mBuffer[quality],fbo);
|
445 |
|
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT|GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT);
|
446 |
|
numRenders += oitRender(time,fbo); // merge the OIT linked list
|
447 |
|
mBuffer[quality].clearBuffer(fbo);
|
|
459 |
|
|
460 |
if( oit )
|
|
461 |
{
|
|
462 |
numRenders += oitBuild(time, mBuffer[quality], fbo);
|
|
463 |
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT | GLES31.GL_ATOMIC_COUNTER_BARRIER_BIT);
|
|
464 |
numRenders += oitRender(time, fbo); // merge the OIT linked list
|
|
465 |
mBuffer[quality].clearBuffer(fbo);
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
numRenders += blitWithDepth(time, mBuffer[quality],fbo);
|
|
470 |
}
|
448 |
471 |
}
|
449 |
472 |
} // end else (postprocessed child)
|
450 |
473 |
|
... | ... | |
610 |
633 |
numRenders += mChildren.get(i).renderRecursive(time);
|
611 |
634 |
}
|
612 |
635 |
|
613 |
|
numRenders += renderChildren(time,mNumChildren,mChildren,fbo);
|
|
636 |
numRenders += renderChildren(time,mNumChildren,mChildren,fbo, mRenderWayOIT);
|
614 |
637 |
|
615 |
638 |
return numRenders;
|
616 |
639 |
}
|
... | ... | |
824 |
847 |
return (mDepthStencilCreated==CREATED && mDepthStencil==BOTH_DEPTH_STENCIL);
|
825 |
848 |
}
|
826 |
849 |
|
|
850 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
851 |
/**
|
|
852 |
* When rendering this Node, should we use the Order Independent Transparency render more?
|
|
853 |
* <p>
|
|
854 |
* There are two modes of rendering: the fast 'normal' way, which however renders transparent
|
|
855 |
* fragments in different ways depending on which fragments get rendered first, or the slower
|
|
856 |
* 'oit' way, which renders transparent fragments correctly regardless of their order.
|
|
857 |
*
|
|
858 |
* @param oit True if we want to render more slowly, but in a way which accounts for transparency.
|
|
859 |
*/
|
|
860 |
public void setOrderIndependentTransparency(boolean oit)
|
|
861 |
{
|
|
862 |
mRenderWayOIT = oit;
|
|
863 |
}
|
|
864 |
|
827 |
865 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
828 |
866 |
/**
|
829 |
867 |
* Adds a new child to the last position in the list of our Surface's children.
|
Give users API to render OutputSerfaces and attached Nodes in either the 'normal' way of OIT way.