Revision 809dcae3
Added by Leszek Koltunski about 5 years ago
src/main/java/org/distorted/library/main/Distorted.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import org.distorted.library.R; |
30 | 30 |
import org.distorted.library.effect.Effect; |
31 |
import org.distorted.library.effectqueue.EffectQueue; |
|
32 |
import org.distorted.library.effectqueue.EffectQueuePostprocess; |
|
31 | 33 |
import org.distorted.library.effect.EffectType; |
32 | 34 |
import org.distorted.library.effect.FragmentEffect; |
33 | 35 |
import org.distorted.library.effect.PostprocessEffect; |
... | ... | |
100 | 102 |
* https://community.arm.com/graphics/f/discussions/10285/opengl-es-3-1-on-mali-t880-flashes |
101 | 103 |
*/ |
102 | 104 |
static final int FBO_QUEUE_SIZE = 4; |
103 |
/** |
|
104 |
* Number of Main program variants (ATM 3: MAIN, MAIN OIT, PREPROCESS) |
|
105 |
*/ |
|
106 |
static final int MAIN_VARIANTS = 3; |
|
107 | 105 |
|
108 | 106 |
private static boolean mInitialized=false; |
109 | 107 |
|
... | ... | |
200 | 198 |
|
201 | 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
202 | 200 |
|
203 |
static void createPrograms(Resources resources) |
|
201 |
private static void createPrograms(Resources resources)
|
|
204 | 202 |
{ |
205 | 203 |
// MAIN PROGRAM //////////////////////////////////// |
206 | 204 |
final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader); |
... | ... | |
289 | 287 |
|
290 | 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
291 | 289 |
|
292 |
static void createProgramsOIT(Resources resources) |
|
290 |
private static void createProgramsOIT(Resources resources)
|
|
293 | 291 |
{ |
294 | 292 |
// MAIN OIT PROGRAM //////////////////////////////// |
295 | 293 |
final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader); |
... | ... | |
406 | 404 |
mOITRenderSizeH = GLES31.glGetUniformLocation( oitRenderProgramH, "u_Size"); |
407 | 405 |
} |
408 | 406 |
|
409 |
|
|
410 | 407 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
411 | 408 |
|
412 | 409 |
private static void displayNormals(EffectQueue[] queues, MeshBase mesh) |
... | ... | |
445 | 442 |
|
446 | 443 |
mesh.bindVertexAttribs(Distorted.mMainOITProgram); |
447 | 444 |
|
448 |
float inflate = mesh.getInflate(); |
|
445 |
float inflate = mesh.getInflate(); |
|
446 |
int width = surface.mWidth; |
|
447 |
int height = surface.mHeight; |
|
448 |
float distance = surface.mDistance; |
|
449 |
float mipmap = surface.mMipmap; |
|
450 |
float[] projection= surface.mProjectionMatrix; |
|
449 | 451 |
|
450 |
EffectQueue.send(queues, surface, inflate, halfW, halfH, halfZ, 1 );
|
|
452 |
EffectQueue.send(queues, width, height, distance, mipmap, projection, inflate, halfW, halfH, halfZ, 1 );
|
|
451 | 453 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() ); |
452 | 454 |
|
453 | 455 |
if( mesh.getShowNormals() ) |
454 | 456 |
{ |
455 | 457 |
Distorted.mMainProgram.useProgram(); |
456 |
EffectQueue.send(queues, surface, inflate, halfW, halfH, halfZ, 0 );
|
|
458 |
EffectQueue.send(queues, width, height, distance, mipmap, projection, inflate, halfW, halfH, halfZ, 0 );
|
|
457 | 459 |
displayNormals(queues,mesh); |
458 | 460 |
} |
459 | 461 |
} |
... | ... | |
469 | 471 |
Distorted.mMainProgram.useProgram(); |
470 | 472 |
GLES31.glUniform1i(Distorted.mMainTextureH, 0); |
471 | 473 |
mesh.bindVertexAttribs(Distorted.mMainProgram); |
472 |
EffectQueue.send(queues, surface, mesh.getInflate(), halfW, halfH, halfZ, 0 ); |
|
474 |
|
|
475 |
float inflate = mesh.getInflate(); |
|
476 |
int width = surface.mWidth; |
|
477 |
int height = surface.mHeight; |
|
478 |
float distance = surface.mDistance; |
|
479 |
float mipmap = surface.mMipmap; |
|
480 |
float[] projection= surface.mProjectionMatrix; |
|
481 |
|
|
482 |
EffectQueue.send(queues, width, height, distance, mipmap, projection, inflate, halfW, halfH, halfZ, 0 ); |
|
473 | 483 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() ); |
474 | 484 |
|
475 | 485 |
if( mesh.getShowNormals() ) displayNormals(queues,mesh); |
... | ... | |
581 | 591 |
} |
582 | 592 |
|
583 | 593 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
584 |
// Pass1 of the OIT algorithm. Clear per-pixel head-poiners. |
|
594 |
// Pass1 of the OIT algorithm. Clear per-pixel head-pointers.
|
|
585 | 595 |
|
586 | 596 |
static void oitClear(DistortedOutputSurface surface, int counter) |
587 | 597 |
{ |
Also available in: Unified diff
Finally move the EffectQueues to their own package.