Revision 4bb94a7d
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java | ||
|---|---|---|
| 33 | 33 | 
    import org.distorted.library.main.DistortedNode;  | 
| 34 | 34 | 
    import org.distorted.library.main.InternalOutputSurface;  | 
| 35 | 35 | 
    import org.distorted.library.main.InternalRenderState;  | 
| 36 | 
    import org.distorted.library.main.InternalSurface;  | 
|
| 37 | 36 | 
    import org.distorted.library.mesh.MeshBase;  | 
| 38 | 37 | 
    import org.distorted.library.message.EffectMessageSender;  | 
| 39 | 38 | 
    import org.distorted.library.program.DistortedProgram;  | 
| ... | ... | |
| 159 | 158 | 
     | 
| 160 | 159 | 
    public int preprocess(InternalOutputSurface buffer, DistortedNode node, float distance, float mipmap, float[] projection)  | 
| 161 | 160 | 
        {
   | 
| 162 | 
        buffer.setAsOutput();
   | 
|
| 163 | 
        InternalSurface input = node.getSurface();
   | 
|
| 161 | 
        MeshBase mesh = node.getMesh();
   | 
|
| 162 | 
        DistortedEffects effects = node.getEffects();
   | 
|
| 164 | 163 | 
     | 
| 165 | 
    if( input.setAsInput() )  | 
|
| 166 | 
          {
   | 
|
| 167 | 
    MeshBase mesh = node.getMesh();  | 
|
| 168 | 
    DistortedEffects effects = node.getEffects();  | 
|
| 169 | 
     | 
|
| 170 | 
    float halfW = mesh.getStretchX() / 2.0f;  | 
|
| 171 | 
    float halfH = mesh.getStretchY() / 2.0f;  | 
|
| 172 | 
    float halfZ = mesh.getStretchZ() / 2.0f;  | 
|
| 164 | 
    float halfW = mesh.getStretchX() / 2.0f;  | 
|
| 165 | 
    float halfH = mesh.getStretchY() / 2.0f;  | 
|
| 166 | 
    float halfZ = mesh.getStretchZ() / 2.0f;  | 
|
| 173 | 167 | 
     | 
| 174 | 
          int width   = buffer.getWidth();
   | 
|
| 175 | 
          int height  = buffer.getHeight();
   | 
|
| 168 | 
    int width = buffer.getWidth();  | 
|
| 169 | 
    int height = buffer.getHeight();  | 
|
| 176 | 170 | 
     | 
| 177 | 
          InternalRenderState.setUpStencilMark(mA!=0.0f);
   | 
|
| 178 | 
          InternalRenderState.disableBlending();
   | 
|
| 171 | 
    InternalRenderState.setUpStencilMark(mA!=0.0f);  | 
|
| 172 | 
    InternalRenderState.disableBlending();  | 
|
| 179 | 173 | 
     | 
| 180 | 
          GLES31.glViewport(0, 0, width, height );
   | 
|
| 174 | 
    GLES31.glViewport(0, 0, width, height );  | 
|
| 181 | 175 | 
     | 
| 182 | 
          mPreProgram.useProgram();
   | 
|
| 176 | 
    mPreProgram.useProgram();  | 
|
| 183 | 177 | 
     | 
| 184 | 
          mesh.bindVertexAttribs(mPreProgram);
   | 
|
| 178 | 
    mesh.bindVertexAttribs(mPreProgram);  | 
|
| 185 | 179 | 
     | 
| 186 | 
          EffectQueue[] queues = effects.getQueues();
   | 
|
| 187 | 
          EffectQueueMatrix matrix = (EffectQueueMatrix)queues[0];
   | 
|
| 188 | 
          EffectQueueVertex vertex = (EffectQueueVertex)queues[1];
   | 
|
| 180 | 
    EffectQueue[] queues = effects.getQueues();  | 
|
| 181 | 
    EffectQueueMatrix matrix = (EffectQueueMatrix)queues[0];  | 
|
| 182 | 
    EffectQueueVertex vertex = (EffectQueueVertex)queues[1];  | 
|
| 189 | 183 | 
     | 
| 190 | 
          float inflate=0.0f;
   | 
|
| 184 | 
    float inflate=0.0f;  | 
|
| 191 | 185 | 
     | 
| 192 | 
          matrix.send(distance, mipmap, projection, halfW, halfH, halfZ, 2);
   | 
|
| 186 | 
    matrix.send(distance, mipmap, projection, halfW, halfH, halfZ, 2);  | 
|
| 193 | 187 | 
     | 
| 194 | 
          if( mHalo!=0.0f )
   | 
|
| 195 | 
            {
   | 
|
| 196 | 
            inflate = matrix.magnify(projection, width, height, mipmap, halfW, halfH, halfZ, mHalo);
   | 
|
| 197 | 
            }
   | 
|
| 188 | 
    if( mHalo!=0.0f )  | 
|
| 189 | 
          {
   | 
|
| 190 | 
    inflate = matrix.magnify(projection, width, height, mipmap, halfW, halfH, halfZ, mHalo);  | 
|
| 191 | 
    }  | 
|
| 198 | 192 | 
     | 
| 199 | 
          vertex.send(inflate,2);
   | 
|
| 193 | 
    vertex.send(inflate,2);  | 
|
| 200 | 194 | 
     | 
| 201 | 
          if( mA!=0.0f )
   | 
|
| 202 | 
            {
   | 
|
| 203 | 
            GLES31.glUniform4f(mPreColorH, mR, mG, mB, mA);
   | 
|
| 204 | 
            GLES31.glUniform1i(mPreTextureH, 0);
   | 
|
| 205 | 
            }
   | 
|
| 195 | 
    if( mA!=0.0f )  | 
|
| 196 | 
          {
   | 
|
| 197 | 
    GLES31.glUniform4f(mPreColorH, mR, mG, mB, mA);  | 
|
| 198 | 
    GLES31.glUniform1i(mPreTextureH, 0);  | 
|
| 199 | 
    }  | 
|
| 206 | 200 | 
     | 
| 207 | 
          GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() );
   | 
|
| 201 | 
    GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.getNumVertices() );  | 
|
| 208 | 202 | 
     | 
| 209 | 
          InternalRenderState.restoreBlending();
   | 
|
| 210 | 
          InternalRenderState.unsetUpStencilMark();
   | 
|
| 203 | 
    InternalRenderState.restoreBlending();  | 
|
| 204 | 
    InternalRenderState.unsetUpStencilMark();  | 
|
| 211 | 205 | 
     | 
| 212 | 
    return 1;  | 
|
| 213 | 
    }  | 
|
| 214 | 
    return 0;  | 
|
| 206 | 
    return 1;  | 
|
| 215 | 207 | 
    }  | 
| 216 | 208 | 
     | 
| 217 | 209 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| src/main/java/org/distorted/library/main/InternalOutputSurface.java | ||
|---|---|---|
| 424 | 424 | 
    }  | 
| 425 | 425 | 
    else  | 
| 426 | 426 | 
                {
   | 
| 427 | 
    for(int j=bucketChange; j<i; j++) numRenders += lastQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );  | 
|
| 427 | 
    for(int j=bucketChange; j<i; j++)  | 
|
| 428 | 
                  {
   | 
|
| 429 | 
    DistortedNode node = children.getChild(j);  | 
|
| 430 | 
     | 
|
| 431 | 
    if( node.getSurface().setAsInput() )  | 
|
| 432 | 
                    {
   | 
|
| 433 | 
    buffer.setAsOutput();  | 
|
| 434 | 
    numRenders += lastQueue.preprocess( buffer, node, buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );  | 
|
| 435 | 
    }  | 
|
| 436 | 
    }  | 
|
| 428 | 437 | 
    numRenders += lastQueue.postprocess(buffer);  | 
| 429 | 438 | 
     | 
| 430 | 439 | 
    if( oit )  | 
| ... | ... | |
| 466 | 475 | 
     | 
| 467 | 476 | 
    if( i==numChildren-1 )  | 
| 468 | 477 | 
              {
   | 
| 469 | 
    for(int j=bucketChange; j<numChildren; j++) numRenders += currQueue.preprocess( buffer,children.getChild(j), buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );  | 
|
| 478 | 
    for(int j=bucketChange; j<numChildren; j++)  | 
|
| 479 | 
                {
   | 
|
| 480 | 
    DistortedNode node = children.getChild(j);  | 
|
| 481 | 
     | 
|
| 482 | 
    if( node.getSurface().setAsInput() )  | 
|
| 483 | 
                  {
   | 
|
| 484 | 
    buffer.setAsOutput();  | 
|
| 485 | 
    numRenders += currQueue.preprocess( buffer, node, buffer.mDistance, buffer.mMipmap, buffer.mProjectionMatrix );  | 
|
| 486 | 
    }  | 
|
| 487 | 
    }  | 
|
| 470 | 488 | 
    numRenders += currQueue.postprocess(buffer);  | 
| 471 | 489 | 
     | 
| 472 | 490 | 
    if( oit )  | 
| src/main/java/org/distorted/library/main/InternalSurface.java | ||
|---|---|---|
| 21 | 21 | 
     | 
| 22 | 22 | 
    import android.opengl.GLES31;  | 
| 23 | 23 | 
     | 
| 24 | 
    import org.distorted.library.mesh.MeshBase;  | 
|
| 25 | 
     | 
|
| 26 | 24 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| 27 | 
    /**  | 
|
| 28 | 
    * This is not really part of the public API.  | 
|
| 29 | 
    *  | 
|
| 30 | 
    * @y.exclude  | 
|
| 31 | 
    */  | 
|
| 32 | 
    public abstract class InternalSurface extends InternalObject  | 
|
| 25 | 
     | 
|
| 26 | 
    abstract class InternalSurface extends InternalObject  | 
|
| 33 | 27 | 
    {
   | 
| 34 | 28 | 
    int mColorCreated;  | 
| 35 | 29 | 
    int mNumColors;  | 
| ... | ... | |
| 90 | 84 | 
    return mHeight;  | 
| 91 | 85 | 
    }  | 
| 92 | 86 | 
     | 
| 93 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
|
| 94 | 
    /**  | 
|
| 95 | 
    * Return the depth of this Surface.  | 
|
| 96 | 
    * <p>  | 
|
| 97 | 
    * Admittedly quite a strange method. Why do we need to pass a Mesh to it? Because one cannot determine  | 
|
| 98 | 
    * 'depth' of a Surface (bitmap really!) when rendered based only on the texture itself, that depends  | 
|
| 99 | 
    * on the Mesh it is rendered with.  | 
|
| 100 | 
    *  | 
|
| 101 | 
    * @return depth of the Object, in pixels.  | 
|
| 102 | 
    */  | 
|
| 103 | 
     | 
|
| 104 | 
    /*  | 
|
| 105 | 
    public int getDepth(MeshBase mesh)  | 
|
| 106 | 
        {
   | 
|
| 107 | 
    return mesh==null ? 0 : (int)(mWidth*mesh.getZFactor() );  | 
|
| 108 | 
    }  | 
|
| 109 | 
    */  | 
|
| 110 | 87 | 
    ///////////////////////////////////////////////////////////////////////////////////////////////////  | 
| 111 | 88 | 
    /**  | 
| 112 | 89 | 
    * Bind the underlying rectangle of pixels as a OpenGL Texture.  | 
Also available in: Unified diff
Hide the InternalSurface class inside its package.