Revision 62c869ad
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/library/main/DistortedLibrary.java | ||
---|---|---|
123 | 123 |
/// MAIN PROGRAM /// |
124 | 124 |
private static DistortedProgram mMainProgram; |
125 | 125 |
private static int mMainTextureH; |
126 |
private static int mTransformFeedbackH; |
|
126 | 127 |
|
127 | 128 |
/// NORMAL PROGRAM ///// |
128 | 129 |
private static DistortedProgram mNormalProgram; |
129 |
private static int mNormalMVPMatrixH;
|
|
130 |
private static int mNormalProjectionH;
|
|
130 | 131 |
|
131 | 132 |
/// MAIN OIT PROGRAM /// |
132 | 133 |
private static DistortedProgram mMainOITProgram; |
... | ... | |
262 | 263 |
EffectQueue.getUniforms(mainProgramH,0); |
263 | 264 |
MeshBase.getUniforms(mainProgramH,0); |
264 | 265 |
mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture"); |
266 |
mTransformFeedbackH= GLES30.glGetUniformLocation( mainProgramH, "u_TransformFeedback"); |
|
265 | 267 |
|
266 | 268 |
// BLIT PROGRAM //////////////////////////////////// |
267 | 269 |
final InputStream blitVertStream = mResources.openRawResource(R.raw.blit_vertex_shader); |
... | ... | |
321 | 323 |
} |
322 | 324 |
|
323 | 325 |
int normalProgramH = mNormalProgram.getProgramHandle(); |
324 |
mNormalMVPMatrixH = GLES30.glGetUniformLocation( normalProgramH, "u_MVPMatrix");
|
|
326 |
mNormalProjectionH = GLES30.glGetUniformLocation( normalProgramH, "u_Projection");
|
|
325 | 327 |
} |
326 | 328 |
|
327 | 329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
481 | 483 |
|
482 | 484 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
483 | 485 |
|
484 |
private static void displayNormals(EffectQueue[] queues, MeshBase mesh)
|
|
486 |
private static void displayNormals(float[] projection, MeshBase mesh)
|
|
485 | 487 |
{ |
486 | 488 |
if( mNormalProgram==null ) |
487 | 489 |
{ |
... | ... | |
499 | 501 |
int num = mesh.getNumVertices(); |
500 | 502 |
int tfo = mesh.getTFO(); |
501 | 503 |
|
504 |
GLES30.glUniform1i(DistortedLibrary.mTransformFeedbackH, 1); |
|
502 | 505 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfo ); |
503 | 506 |
GLES30.glBeginTransformFeedback( GLES30.GL_POINTS); |
504 | 507 |
InternalRenderState.switchOffDrawing(); |
... | ... | |
508 | 511 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0); |
509 | 512 |
|
510 | 513 |
mNormalProgram.useProgram(); |
511 |
GLES30.glUniformMatrix4fv(mNormalMVPMatrixH, 1, false, EffectQueue.getMVP(queues) , 0);
|
|
514 |
GLES30.glUniformMatrix4fv(mNormalProjectionH, 1, false, projection, 0);
|
|
512 | 515 |
mesh.bindTransformAttribs(mNormalProgram); |
513 | 516 |
GLES30.glLineWidth(8.0f); |
514 | 517 |
GLES30.glDrawArrays(GLES30.GL_LINES, 0, 2*num); |
... | ... | |
574 | 577 |
float mipmap = surface.mMipmap; |
575 | 578 |
float[] projection= surface.mProjectionMatrix; |
576 | 579 |
|
577 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, mesh, 1 );
|
|
580 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, 1 ); |
|
578 | 581 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() ); |
579 | 582 |
|
580 | 583 |
if( mesh.getShowNormals() ) |
581 | 584 |
{ |
582 | 585 |
mMainProgram.useProgram(); |
583 | 586 |
mesh.send(0); |
584 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, mesh, 0 );
|
|
585 |
displayNormals(queues,mesh);
|
|
587 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, 0 ); |
|
588 |
displayNormals(projection,mesh);
|
|
586 | 589 |
} |
587 | 590 |
} |
588 | 591 |
} |
... | ... | |
608 | 611 |
float mipmap = surface.mMipmap; |
609 | 612 |
float[] projection= surface.mProjectionMatrix; |
610 | 613 |
|
611 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, mesh, 0 );
|
|
614 |
EffectQueue.send(queues, distance, mipmap, projection, inflate, 0 ); |
|
612 | 615 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() ); |
613 | 616 |
|
614 |
if( mesh.getShowNormals() ) displayNormals(queues,mesh);
|
|
617 |
if( mesh.getShowNormals() ) displayNormals(projection,mesh);
|
|
615 | 618 |
} |
616 | 619 |
} |
617 | 620 |
|
Also available in: Unified diff
Fix normals in case of MatrixEffectScale / Shear.
Fix displaying the normal vector.