Revision 0bd9f644
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/library/main/DistortedLibrary.java | ||
---|---|---|
158 | 158 |
private static int mBlitDepthDepthH; |
159 | 159 |
private static int mBlitDepthTexCorrH; |
160 | 160 |
|
161 |
/// Program Handles /// |
|
162 |
private static int mMainProgramH, mFullProgramH, mMainOITProgramH; |
|
163 |
|
|
161 | 164 |
/// OIT SSBO BUFFER /// |
162 | 165 |
private static int[] mLinkedListSSBO = new int[1]; |
163 | 166 |
private static int[] mAtomicCounter; |
... | ... | |
259 | 262 |
throw new RuntimeException(e.getMessage()); |
260 | 263 |
} |
261 | 264 |
|
262 |
int mainProgramH = mMainProgram.getProgramHandle(); |
|
263 |
EffectQueue.getUniforms(mainProgramH,0); |
|
264 |
MeshBase.getUniforms(mainProgramH,0); |
|
265 |
mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture"); |
|
266 |
mTransformFeedbackH= GLES30.glGetUniformLocation( mainProgramH, "u_TransformFeedback"); |
|
265 |
mMainProgramH = mMainProgram.getProgramHandle(); |
|
266 |
EffectQueue.getUniforms(mMainProgramH,0); |
|
267 |
mMainTextureH= GLES30.glGetUniformLocation( mMainProgramH, "u_Texture"); |
|
268 |
mTransformFeedbackH= GLES30.glGetUniformLocation( mMainProgramH, "u_TransformFeedback"); |
|
267 | 269 |
|
268 | 270 |
// BLIT PROGRAM //////////////////////////////////// |
269 | 271 |
final InputStream blitVertStream = mResources.openRawResource(R.raw.blit_vertex_shader); |
... | ... | |
302 | 304 |
mBlitDepthDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture"); |
303 | 305 |
mBlitDepthDepthH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Depth"); |
304 | 306 |
mBlitDepthTexCorrH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_TexCorr"); |
307 |
|
|
308 |
int[] params = new int[1]; |
|
309 |
int index = GLES30.glGetUniformBlockIndex(mMainProgramH, "meshAssociation"); |
|
310 |
GLES30.glGetActiveUniformBlockiv( mMainProgramH, index, GLES30.GL_UNIFORM_BLOCK_DATA_SIZE, params, 0); |
|
311 |
MeshBase.setAssociationSize(params[0]); |
|
305 | 312 |
} |
306 | 313 |
|
307 | 314 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
358 | 365 |
throw new RuntimeException(e.getMessage()); |
359 | 366 |
} |
360 | 367 |
|
361 |
int fullProgramH = mFullProgram.getProgramHandle(); |
|
362 |
EffectQueue.getUniforms(fullProgramH,3); |
|
363 |
MeshBase.getUniforms(fullProgramH,3); |
|
368 |
mFullProgramH = mFullProgram.getProgramHandle(); |
|
369 |
EffectQueue.getUniforms(mFullProgramH,3); |
|
364 | 370 |
} |
365 | 371 |
|
366 | 372 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
393 | 399 |
throw new RuntimeException(e.getMessage()); |
394 | 400 |
} |
395 | 401 |
|
396 |
int mainOITProgramH = mMainOITProgram.getProgramHandle(); |
|
397 |
EffectQueue.getUniforms(mainOITProgramH,1); |
|
398 |
MeshBase.getUniforms(mainOITProgramH,1); |
|
399 |
mMainOITTextureH = GLES30.glGetUniformLocation( mainOITProgramH, "u_Texture"); |
|
400 |
mMainOITSizeH = GLES30.glGetUniformLocation( mainOITProgramH, "u_Size"); |
|
401 |
mMainOITNumRecordsH = GLES30.glGetUniformLocation( mainOITProgramH, "u_numRecords"); |
|
402 |
mMainOITProgramH = mMainOITProgram.getProgramHandle(); |
|
403 |
EffectQueue.getUniforms(mMainOITProgramH,1); |
|
404 |
mMainOITTextureH = GLES30.glGetUniformLocation( mMainOITProgramH, "u_Texture"); |
|
405 |
mMainOITSizeH = GLES30.glGetUniformLocation( mMainOITProgramH, "u_Size"); |
|
406 |
mMainOITNumRecordsH = GLES30.glGetUniformLocation( mMainOITProgramH, "u_numRecords"); |
|
402 | 407 |
|
403 | 408 |
// OIT CLEAR PROGRAM //////////////////////////////////// |
404 | 409 |
final InputStream oitClearVertStream = resources.openRawResource(R.raw.oit_vertex_shader); |
... | ... | |
518 | 523 |
} |
519 | 524 |
|
520 | 525 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
521 |
// execute all VertexEffects and adjust all vertices |
|
522 |
|
|
526 |
/** |
|
527 |
* Execute all VertexEffects and adjust all vertices |
|
528 |
* |
|
529 |
* @y.exclude |
|
530 |
*/ |
|
523 | 531 |
public static void adjustVertices(MeshBase mesh, EffectQueueVertex queue) |
524 | 532 |
{ |
525 | 533 |
if( mFullProgram==null ) |
... | ... | |
542 | 550 |
mesh.bindVertexAttribs(mFullProgram); |
543 | 551 |
queue.compute(1); |
544 | 552 |
queue.send(0.0f,3); |
545 |
mesh.send(3);
|
|
553 |
mesh.send(mFullProgramH);
|
|
546 | 554 |
|
547 | 555 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfo ); |
548 | 556 |
GLES30.glBeginTransformFeedback( GLES30.GL_POINTS); |
... | ... | |
570 | 578 |
GLES30.glUniform2ui(mMainOITSizeH, surface.mWidth, surface.mHeight); |
571 | 579 |
GLES30.glUniform1ui(mMainOITNumRecordsH, (int)(mBufferSize*surface.mWidth*surface.mHeight) ); |
572 | 580 |
mesh.bindVertexAttribs(mMainOITProgram); |
573 |
mesh.send(1);
|
|
581 |
mesh.send(mMainOITProgramH);
|
|
574 | 582 |
|
575 | 583 |
float inflate = mesh.getInflate(); |
576 | 584 |
float distance = surface.mDistance; |
... | ... | |
583 | 591 |
if( mesh.getShowNormals() ) |
584 | 592 |
{ |
585 | 593 |
mMainProgram.useProgram(); |
586 |
mesh.send(0);
|
|
594 |
mesh.send(mMainProgramH);
|
|
587 | 595 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, 0 ); |
588 | 596 |
displayNormals(projection,mesh); |
589 | 597 |
} |
... | ... | |
604 | 612 |
mMainProgram.useProgram(); |
605 | 613 |
GLES30.glUniform1i(DistortedLibrary.mMainTextureH, 0); |
606 | 614 |
mesh.bindVertexAttribs(DistortedLibrary.mMainProgram); |
607 |
mesh.send(0);
|
|
615 |
mesh.send(mMainProgramH);
|
|
608 | 616 |
|
609 | 617 |
float inflate = mesh.getInflate(); |
610 | 618 |
float distance = surface.mDistance; |
Also available in: Unified diff
Introduce an UBO to the vertex shader holding info about mesh effect associations.