Revision 7170e4eb
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/DistortedEffects.java | ||
---|---|---|
78 | 78 |
mQuadPositions.put(positionData).position(0); |
79 | 79 |
} |
80 | 80 |
|
81 |
/// BLIT DEPTH PROGRAM /// |
|
82 |
private static DistortedProgram mBlitDepthProgram; |
|
83 |
private static int mBlitDepthTextureH; |
|
84 |
private static int mBlitDepthDepthTextureH; |
|
85 |
private static int mBlitDepthDepthH; |
|
86 |
|
|
81 | 87 |
/// NORMAL PROGRAM ///// |
82 | 88 |
private static DistortedProgram mNormalProgram; |
83 | 89 |
private static int mNormalMVPMatrixH; |
... | ... | |
166 | 172 |
mBlitTextureH = GLES30.glGetUniformLocation( blitProgramH, "u_Texture"); |
167 | 173 |
mBlitDepthH = GLES30.glGetUniformLocation( blitProgramH, "u_Depth"); |
168 | 174 |
|
175 |
// BLIT DEPTH PROGRAM //////////////////////////////////// |
|
176 |
final InputStream blitDepthVertStream = resources.openRawResource(R.raw.blit_depth_vertex_shader); |
|
177 |
final InputStream blitDepthFragStream = resources.openRawResource(R.raw.blit_depth_fragment_shader); |
|
178 |
|
|
179 |
try |
|
180 |
{ |
|
181 |
mBlitDepthProgram = new DistortedProgram(blitDepthVertStream,blitDepthFragStream,blitVertHeader,blitFragHeader, Distorted.GLSL); |
|
182 |
} |
|
183 |
catch(Exception e) |
|
184 |
{ |
|
185 |
android.util.Log.e("EFFECTS", "exception trying to compile BLIT DEPTH program: "+e.getMessage()); |
|
186 |
throw new RuntimeException(e.getMessage()); |
|
187 |
} |
|
188 |
|
|
189 |
int blitDepthProgramH = mBlitDepthProgram.getProgramHandle(); |
|
190 |
mBlitDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Texture"); |
|
191 |
mBlitDepthDepthTextureH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_DepthTexture"); |
|
192 |
mBlitDepthDepthH = GLES30.glGetUniformLocation( blitDepthProgramH, "u_Depth"); |
|
193 |
|
|
169 | 194 |
// NORMAL PROGRAM ////////////////////////////////////// |
170 | 195 |
final InputStream normalVertexStream = resources.openRawResource(R.raw.normal_vertex_shader); |
171 | 196 |
final InputStream normalFragmentStream = resources.openRawResource(R.raw.normal_fragment_shader); |
... | ... | |
297 | 322 |
GLES30.glVertexAttribPointer(mBlitProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
298 | 323 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
299 | 324 |
} |
300 |
|
|
325 |
|
|
326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
327 |
|
|
328 |
static void blitDepthPriv(DistortedOutputSurface surface) |
|
329 |
{ |
|
330 |
mBlitDepthProgram.useProgram(); |
|
331 |
|
|
332 |
GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight ); |
|
333 |
GLES30.glUniform1i(mBlitDepthTextureH, 0); |
|
334 |
GLES30.glUniform1i(mBlitDepthDepthTextureH, 1); |
|
335 |
GLES30.glUniform1f( mBlitDepthDepthH , 1.0f-surface.mNear); |
|
336 |
GLES30.glVertexAttribPointer(mBlitDepthProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
|
337 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
|
338 |
} |
|
339 |
|
|
301 | 340 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
302 | 341 |
|
303 | 342 |
private void releasePriv() |
Also available in: Unified diff
Move on to Stencil on both stages of the BLUR + separate 'blit with depth'.
This works wonders on Nexus 5X ( r=50 quality=HIGHIEST 1,4,8 cubes: 59.3,43.6,41.0 FPS! ) but it somehow fails to clear the DEPTH and STENCIL buffers on Nexus 4....