Project

General

Profile

« Previous | Next » 

Revision c9a24bfb

Added by Leszek Koltunski over 7 years ago

Bugfix in renderChildren (postprocess):

for each bucket, first render all the bucket members , only then render all of their Stencils+Depths (avoids this 'black ring' effect)

View differences:

src/main/java/org/distorted/library/DistortedNode.java
259 259

  
260 260
///////////////////////////////////////////////////////////////////////////////////////////////////
261 261

  
262
  int markStencilAndDraw(long currTime, DistortedOutputSurface surface, DistortedEffectsPostprocess effects)
262
  int markStencilAndDepth(long currTime, DistortedOutputSurface surface, DistortedEffectsPostprocess effects)
263 263
    {
264 264
    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
265 265

  
266 266
    if( input.setAsInput() )
267 267
      {
268
      int quality = effects.getQuality();
269
      DistortedFramebuffer buffer = surface.mBuffer[quality];
270
      float w = mSurface.getWidth() /2.0f;
271
      float h = mSurface.getHeight()/2.0f;
272
      buffer.setAsOutput();
273

  
274
      // Draw the color buffer of the object.
275
      mState.apply();
276
      mEffects.drawPriv(w, h, mMesh, buffer, currTime, 0);
277

  
278
      // Draw stencil + depth buffers of the object enlarged by HALO pixels around.
268
      surface.setAsOutput();
279 269
      DistortedRenderState.setUpStencilMark();
280
      mEffects.drawPriv(w, h, mMesh, buffer, currTime, effects.getHalo()*buffer.mMipmap);
270
      mEffects.drawPriv(mSurface.getWidth() /2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime, effects.getHalo()*surface.mMipmap);
281 271
      DistortedRenderState.unsetUpStencilMark();
282 272

  
283 273
      return 1;
src/main/java/org/distorted/library/DistortedOutputSurface.java
237 237
    DistortedNode child;
238 238
    DistortedEffectsPostprocess lastP=null, currP;
239 239
    long lastB=0, currB;
240
    int quality;
240
    int bucketChange=0;
241
    int lastQ=0, currQ;
241 242

  
242 243
    for(int i=0; i<num; i++)
243 244
      {
244 245
      child = children.get(i);
245 246
      currP = child.getEffectsPostprocess();
246 247
      currB = currP==null ? 0 : currP.getBucket();
247

  
248
      if( lastB!=currB && lastB!=0 )
249
        {
250
        quality = lastP.getQuality();
251
        numRenders += lastP.postprocess(time, this);
252
        numRenders += blitWithDepth(quality,time);
253
        }
248
      currQ = currP==null ? 0 : currP.getQuality();
254 249

  
255 250
      if( currB==0 ) numRenders += child.draw(time,this);
256 251
      else
257 252
        {
258 253
        if( mBuffer[0]==null ) createBuffers();
259
        numRenders += child.markStencilAndDraw(time,this,currP);
254

  
255
        if( lastB!=currB )
256
          {
257
          if( lastB!=0 )
258
            {
259
            for(int j=bucketChange; j<i; j++)
260
              {
261
              child = children.get(j);
262
              numRenders += child.markStencilAndDepth(time,mBuffer[lastQ],lastP);
263
              }
264

  
265
            numRenders += lastP.postprocess(time, this);
266
            numRenders += blitWithDepth(lastQ,time);
267
            }
268

  
269
          bucketChange = i;
270
          }
271

  
272
        numRenders += child.draw(time,mBuffer[currQ]);
273

  
260 274
        if( i==num-1 )
261 275
          {
262
          quality = currP.getQuality();
276
          for(int j=bucketChange; j<num; j++)
277
            {
278
            child = children.get(j);
279
            numRenders += child.markStencilAndDepth(time,mBuffer[currQ],currP);
280
            }
281

  
263 282
          numRenders += currP.postprocess(time,this);
264
          numRenders += blitWithDepth(quality,time);
283
          numRenders += blitWithDepth(currQ,time);
265 284
          }
266 285
        }
267 286

  
287
      lastQ = currQ;
268 288
      lastP = currP;
269 289
      lastB = currB;
270 290
      }

Also available in: Unified diff