Revision 97020807
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
63 | 63 |
mQuadPositions.put(positionData).position(0); |
64 | 64 |
} |
65 | 65 |
|
66 |
/// BLIT DEPTH PROGRAM /// |
|
67 |
private static DistortedProgram mBlitDepthProgram; |
|
68 |
private static int mBlitDepthTextureH; |
|
69 |
private static int mBlitDepthDepthTextureH; |
|
70 |
private static int mBlitDepthDepthH; |
|
71 |
private static int mBlitDepthTexCorrH; |
|
72 |
|
|
66 | 73 |
/// OIT SSBO BUFFER /// |
67 | 74 |
private static int[] mLinkedListSSBO = new int[1]; |
68 | 75 |
private static int[] mAtomicCounter = new int[1]; |
... | ... | |
179 | 186 |
mBlitTextureH = GLES31.glGetUniformLocation( blitProgramH, "u_Texture"); |
180 | 187 |
mBlitDepthH = GLES31.glGetUniformLocation( blitProgramH, "u_Depth"); |
181 | 188 |
|
189 |
// BLIT DEPTH PROGRAM //////////////////////////////////// |
|
190 |
final InputStream blitDepthVertStream = resources.openRawResource(R.raw.blit_depth_vertex_shader); |
|
191 |
final InputStream blitDepthFragStream = resources.openRawResource(R.raw.blit_depth_fragment_shader); |
|
192 |
|
|
193 |
try |
|
194 |
{ |
|
195 |
mBlitDepthProgram = new DistortedProgram(blitDepthVertStream,blitDepthFragStream,Distorted.GLSL_VERSION,Distorted.GLSL_VERSION, Distorted.GLSL); |
|
196 |
} |
|
197 |
catch(Exception e) |
|
198 |
{ |
|
199 |
Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile BLIT DEPTH program: "+e.getMessage()); |
|
200 |
throw new RuntimeException(e.getMessage()); |
|
201 |
} |
|
202 |
|
|
203 |
int blitDepthProgramH = mBlitDepthProgram.getProgramHandle(); |
|
204 |
mBlitDepthTextureH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_Texture"); |
|
205 |
mBlitDepthDepthTextureH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture"); |
|
206 |
mBlitDepthDepthH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_Depth"); |
|
207 |
mBlitDepthTexCorrH = GLES31.glGetUniformLocation( blitDepthProgramH, "u_TexCorr"); |
|
208 |
|
|
182 | 209 |
// OIT CLEAR PROGRAM //////////////////////////////////// |
183 | 210 |
final InputStream oitClearVertStream = resources.openRawResource(R.raw.oit_vertex_shader); |
184 | 211 |
final InputStream oitClearFragStream = resources.openRawResource(R.raw.oit_clear_fragment_shader); |
... | ... | |
430 | 457 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4); |
431 | 458 |
} |
432 | 459 |
|
460 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
461 |
|
|
462 |
static void blitDepthPriv(DistortedOutputSurface surface, float corrW, float corrH) |
|
463 |
{ |
|
464 |
mBlitDepthProgram.useProgram(); |
|
465 |
|
|
466 |
GLES31.glViewport(0, 0, surface.mWidth, surface.mHeight ); |
|
467 |
GLES31.glUniform1i(mBlitDepthTextureH, 0); |
|
468 |
GLES31.glUniform1i(mBlitDepthDepthTextureH, 1); |
|
469 |
GLES31.glUniform2f(mBlitDepthTexCorrH, corrW, corrH ); |
|
470 |
GLES31.glUniform1f( mBlitDepthDepthH , 1.0f-surface.mNear); |
|
471 |
GLES31.glVertexAttribPointer(mBlitDepthProgram.mAttribute[0], 2, GLES31.GL_FLOAT, false, 0, mQuadPositions); |
|
472 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4); |
|
473 |
} |
|
474 |
|
|
433 | 475 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
434 | 476 |
// reset atomic counter to 0 |
435 | 477 |
|
Also available in: Unified diff
Start merging master and OIT.