Project

General

Profile

« Previous | Next » 

Revision cf7394cc

Added by Leszek Koltunski almost 7 years ago

Split up postprocessing into queue of effects + blit with depth.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
198 198
    DistortedNode child;
199 199
    DistortedEffectsPostprocess lastP=null, currP;
200 200
    long lastB=0, currB;
201
    int quality;
201 202

  
202 203
    for(int i=0; i<num; i++)
203 204
      {
......
205 206
      currP = child.getEffectsPostprocess();
206 207
      currB = currP==null ? 0 : currP.getBucket();
207 208

  
208
      if( lastB!=currB && lastB!=0 ) numRenders += lastP.postprocess(time,this);
209
      if( lastB!=currB && lastB!=0 )
210
        {
211
        quality = lastP.getQuality();
212
        numRenders += lastP.postprocess(time, this);
213
        numRenders += blitWithDepth(quality,time);
214
        }
209 215

  
210 216
      if( currB==0 ) numRenders += child.draw(time,this);
211 217
      else
212 218
        {
213 219
        if( mBuffer[0]==null ) createBuffers();
214 220
        numRenders += child.markStencilAndDraw(time,this,currP);
215
        if( i==num-1 ) numRenders += currP.postprocess(time,this);
221
        if( i==num-1 )
222
          {
223
          quality = currP.getQuality();
224
          numRenders += currP.postprocess(time,this);
225
          numRenders += blitWithDepth(quality,time);
226
          }
216 227
        }
217 228

  
218 229
      lastP = currP;
......
222 233
    return numRenders;
223 234
    }
224 235

  
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237

  
238
  int blitWithDepth(int quality, long currTime)
239
    {
240
    DistortedFramebuffer buffer = mBuffer[quality];
241

  
242
    GLES30.glViewport(0, 0, mWidth, mHeight);
243
    setAsOutput(currTime);
244
    GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
245
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mColorH[0]);
246
    GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
247
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
248

  
249
    GLES30.glDisable(GLES30.GL_STENCIL_TEST);
250
    GLES30.glStencilMask(0x00);
251

  
252
    DistortedEffects.blitDepthPriv(this);
253
    GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
254
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
255
    GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
256
    GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
257

  
258
    // clear buffers
259
    GLES30.glStencilMask(0xff);
260
    GLES30.glDepthMask(true);
261
    GLES30.glColorMask(true,true,true,true);
262
    GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
263
    GLES30.glClearDepthf(1.0f);
264
    GLES30.glClearStencil(0);
265

  
266
    buffer.setAsOutput();
267
    GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[1], 0);
268
    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT);
269
    GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[0], 0);
270
    GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
271

  
272
    return 1;
273
    }
274

  
225 275
///////////////////////////////////////////////////////////////////////////////////////////////////
226 276

  
227 277
  void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d)

Also available in: Unified diff