Search in sources :

Example 1 with PassType

use of org.rajawali3d.postprocessing.IPass.PassType in project Rajawali by Rajawali.

the class PostProcessingManager method render.

public void render(@IntRange(from = 0) long ellapsedTime, @FloatRange(from = 0d) double deltaTime) {
    if (mComponentsDirty) {
        updatePassesList();
        mComponentsDirty = false;
    }
    mWriteBuffer = mRenderTarget1;
    mReadBuffer = mRenderTarget2;
    boolean maskActive = false;
    IPass pass;
    for (int i = 0; i < mNumPasses; i++) {
        pass = mPasses.get(i);
        if (!pass.isEnabled()) {
            continue;
        }
        PassType type = pass.getPassType();
        if (pass.getRenderToScreen()) {
            mRenderer.clearOverrideViewportDimensions();
        } else {
            mRenderer.setOverrideViewportDimensions(pass.getWidth(), pass.getHeight());
        }
        final boolean depthOrRenderPass = type == PassType.RENDER || type == PassType.DEPTH;
        final Scene renderScene = depthOrRenderPass ? mRenderer.getCurrentScene() : mScene;
        pass.render(renderScene, mRenderer, mScreenQuad, mWriteBuffer, mReadBuffer, ellapsedTime, deltaTime);
        if (pass.needsSwap() && i < mNumPasses - 1) {
            if (maskActive) {
                GLES20.glStencilFunc(GLES20.GL_NOTEQUAL, 1, 0xffffffff);
                mCopyPass.render(mScene, mRenderer, mScreenQuad, mWriteBuffer, mReadBuffer, ellapsedTime, deltaTime);
                GLES20.glStencilFunc(GLES20.GL_EQUAL, 1, 0xffffffff);
            }
            swapBuffers();
        }
        // If the current pass is a mask pass, notify the next pass that mask is active.
        if (type == PassType.MASK) {
            maskActive = true;
        } else if (type == PassType.CLEAR) {
            maskActive = false;
        }
    }
    // Restore the viewport dimensions
    mRenderer.clearOverrideViewportDimensions();
}
Also used : Scene(org.rajawali3d.scene.Scene) PassType(org.rajawali3d.postprocessing.IPass.PassType)

Aggregations

PassType (org.rajawali3d.postprocessing.IPass.PassType)1 Scene (org.rajawali3d.scene.Scene)1