Revision 81f0078a
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedNode.java | ||
---|---|---|
277 | 277 |
mEffects.drawPriv(w, h, mMesh, buffer1, currTime, 0); |
278 | 278 |
|
279 | 279 |
// Mark area of our object + marginInPixels pixels around with 1s in Stencil buffer |
280 |
//buffer2.setAsOutput();
|
|
280 |
buffer2.setAsOutput(); |
|
281 | 281 |
DistortedRenderState.setUpStencilMark(); |
282 |
mEffects.drawPriv(w, h, mMesh, buffer1, currTime, effects.getHalo()*buffer1.mMipmap);
|
|
282 |
mEffects.drawPriv(w, h, mMesh, buffer2, currTime, effects.getHalo()*buffer2.mMipmap);
|
|
283 | 283 |
DistortedRenderState.unsetUpStencilMark(); |
284 | 284 |
|
285 | 285 |
return 1; |
src/main/java/org/distorted/library/DistortedRenderState.java | ||
---|---|---|
143 | 143 |
} |
144 | 144 |
} |
145 | 145 |
|
146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
147 |
|
|
148 |
static void switchOffDepthWriting() |
|
149 |
{ |
|
150 |
if( cState.depthMask!=0 ) |
|
151 |
{ |
|
152 |
sState.depthMask = cState.depthMask; |
|
153 |
cState.depthMask = 0; |
|
154 |
GLES30.glDepthMask(false); |
|
155 |
} |
|
156 |
} |
|
157 |
|
|
158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
159 |
|
|
160 |
static void restoreDepthWriting() |
|
161 |
{ |
|
162 |
if( sState.depthMask!=cState.depthMask ) |
|
163 |
{ |
|
164 |
cState.depthMask = sState.depthMask; |
|
165 |
GLES30.glDepthMask(cState.depthMask==1); |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
170 | 147 |
|
171 | 148 |
static void switchOffDrawing() |
... | ... | |
300 | 277 |
cState.stencilFuncMask = STENCIL_MASK; |
301 | 278 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask); |
302 | 279 |
} |
303 |
|
|
304 |
// TODO: Debatable |
|
305 | 280 |
if( cState.stencilMask!= 0x00 ) |
306 | 281 |
{ |
307 | 282 |
sState.stencilMask = cState.stencilMask; |
308 | 283 |
cState.stencilMask = 0x00; |
309 | 284 |
GLES30.glStencilMask(cState.stencilMask); |
310 | 285 |
} |
286 |
if( cState.depthMask!=0 ) |
|
287 |
{ |
|
288 |
sState.depthMask = cState.depthMask; |
|
289 |
cState.depthMask = 0; |
|
290 |
GLES30.glDepthMask(false); |
|
291 |
} |
|
292 |
if( cState.depthTest!=0 ) |
|
293 |
{ |
|
294 |
sState.depthTest = cState.depthTest; |
|
295 |
cState.depthTest = 0; |
|
296 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST); |
|
297 |
} |
|
311 | 298 |
} |
312 | 299 |
|
313 | 300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
327 | 314 |
GLES30.glEnable(GLES30.GL_STENCIL_TEST); |
328 | 315 |
} |
329 | 316 |
} |
330 |
|
|
331 | 317 |
if( sState.stencilFuncFunc!=cState.stencilFuncFunc || sState.stencilFuncRef!=cState.stencilFuncRef || sState.stencilFuncMask!=cState.stencilFuncMask ) |
332 | 318 |
{ |
333 | 319 |
cState.stencilFuncFunc = sState.stencilFuncFunc; |
... | ... | |
335 | 321 |
cState.stencilFuncMask = sState.stencilFuncMask; |
336 | 322 |
GLES30.glStencilFunc(cState.stencilFuncFunc,cState.stencilFuncRef,cState.stencilFuncMask); |
337 | 323 |
} |
338 |
|
|
339 | 324 |
if( sState.stencilMask!=cState.stencilMask ) |
340 | 325 |
{ |
341 | 326 |
cState.stencilMask = sState.stencilMask; |
342 | 327 |
GLES30.glStencilMask(cState.stencilMask); |
343 | 328 |
} |
329 |
if( sState.depthMask!=cState.depthMask ) |
|
330 |
{ |
|
331 |
cState.depthMask = sState.depthMask; |
|
332 |
GLES30.glDepthMask(cState.depthMask==1); |
|
333 |
} |
|
334 |
if( sState.depthTest!=cState.depthTest ) |
|
335 |
{ |
|
336 |
cState.depthTest = sState.depthTest; |
|
337 |
|
|
338 |
if (cState.depthTest == 0) |
|
339 |
{ |
|
340 |
GLES30.glDisable(GLES30.GL_DEPTH_TEST); |
|
341 |
} |
|
342 |
else |
|
343 |
{ |
|
344 |
GLES30.glEnable(GLES30.GL_DEPTH_TEST); |
|
345 |
} |
|
346 |
} |
|
344 | 347 |
} |
345 | 348 |
|
346 | 349 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectQueuePostprocess.java | ||
---|---|---|
302 | 302 |
GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
303 | 303 |
GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture); |
304 | 304 |
|
305 |
//DistortedRenderState.switchOffDepthWriting(); |
|
306 |
//DistortedRenderState.useStencilMark(); |
|
305 |
DistortedRenderState.useStencilMark(); |
|
307 | 306 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
308 |
//DistortedRenderState.unuseStencilMark(); |
|
309 |
//DistortedRenderState.restoreDepthWriting(); |
|
307 |
DistortedRenderState.unuseStencilMark(); |
|
310 | 308 |
|
311 | 309 |
// vertical blur |
312 | 310 |
GLES30.glViewport(0, 0, (int)w2, (int)h2); |
313 | 311 |
mBlur2Program.useProgram(); |
314 | 312 |
buffer2.setAsInput(); |
315 |
buffer1.setAsDepth();
|
|
313 |
buffer2.setAsDepth();
|
|
316 | 314 |
surface.setAsOutput(time); |
317 | 315 |
|
318 | 316 |
GLES30.glUniform1fv( mWeights2H, radius+1, weightsCache,offset); |
Also available in: Unified diff
Switch on Stencil in Postprocessing.
This is a clear win on Nexus 5X; on Nexus 4 it is debatable - faster on loads where area to be postprocessed is not much (~20% ?) of the screen; slower otherwise.