Search in sources :

Example 1 with GlFramebuffer

use of net.coderbot.iris.gl.framebuffer.GlFramebuffer in project Iris by IrisShaders.

the class RenderTargets method createColorFramebuffer.

public GlFramebuffer createColorFramebuffer(ImmutableSet<Integer> stageWritesToMain, int[] drawBuffers) {
    if (drawBuffers.length == 0) {
        throw new IllegalArgumentException("Framebuffer must have at least one color buffer");
    }
    GlFramebuffer framebuffer = new GlFramebuffer();
    ownedFramebuffers.add(framebuffer);
    int[] actualDrawBuffers = new int[drawBuffers.length];
    for (int i = 0; i < drawBuffers.length; i++) {
        actualDrawBuffers[i] = i;
        if (drawBuffers[i] >= getRenderTargetCount()) {
            // TODO: This causes resource leaks, also we should really verify this in the shaderpack parser...
            throw new IllegalStateException("Render target with index " + drawBuffers[i] + " is not supported, only " + getRenderTargetCount() + " render targets are supported.");
        }
        net.coderbot.iris.rendertarget.RenderTarget target = this.get(drawBuffers[i]);
        int textureId = stageWritesToMain.contains(drawBuffers[i]) ? target.getMainTexture() : target.getAltTexture();
        framebuffer.addColorAttachment(i, textureId);
    }
    framebuffer.drawBuffers(actualDrawBuffers);
    framebuffer.readBuffer(0);
    if (!framebuffer.isComplete()) {
        throw new IllegalStateException("Unexpected error while creating framebuffer");
    }
    return framebuffer;
}
Also used : GlFramebuffer(net.coderbot.iris.gl.framebuffer.GlFramebuffer)

Example 2 with GlFramebuffer

use of net.coderbot.iris.gl.framebuffer.GlFramebuffer in project Iris by IrisShaders.

the class RenderTargets method createColorFramebufferWithDepth.

public GlFramebuffer createColorFramebufferWithDepth(ImmutableSet<Integer> stageWritesToMain, int[] drawBuffers) {
    GlFramebuffer framebuffer = createColorFramebuffer(stageWritesToMain, drawBuffers);
    framebuffer.addDepthAttachment(this.getDepthTexture().getTextureId());
    return framebuffer;
}
Also used : GlFramebuffer(net.coderbot.iris.gl.framebuffer.GlFramebuffer)

Example 3 with GlFramebuffer

use of net.coderbot.iris.gl.framebuffer.GlFramebuffer in project Iris by IrisShaders.

the class DeferredWorldRenderingPipeline method createPassInner.

private Pass createPassInner(ProgramBuilder builder, IdMap map, ProgramDirectives programDirectives, PackDirectives packDirectives) {
    CommonUniforms.addCommonUniforms(builder, map, packDirectives, updateNotifier);
    Supplier<ImmutableSet<Integer>> flipped = () -> isBeforeTranslucent ? flippedAfterPrepare : flippedAfterTranslucent;
    TextureStage textureStage = TextureStage.GBUFFERS_AND_SHADOW;
    ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap().getOrDefault(textureStage, Object2ObjectMaps.emptyMap()));
    IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
    IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
    IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, customTextureManager.getNormals(), customTextureManager.getSpecular());
    IrisSamplers.addWorldDepthSamplers(customTextureSamplerInterceptor, renderTargets);
    IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
    if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
        createShadowMapRenderer.run();
        IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowMapRenderer);
        IrisImages.addShadowColorImages(builder, shadowMapRenderer);
    }
    GlFramebuffer framebufferBeforeTranslucents = renderTargets.createGbufferFramebuffer(flippedAfterPrepare, programDirectives.getDrawBuffers());
    GlFramebuffer framebufferAfterTranslucents = renderTargets.createGbufferFramebuffer(flippedAfterTranslucent, programDirectives.getDrawBuffers());
    builder.bindAttributeLocation(11, "mc_Entity");
    builder.bindAttributeLocation(12, "mc_midTexCoord");
    builder.bindAttributeLocation(13, "at_tangent");
    AlphaTestOverride alphaTestOverride = programDirectives.getAlphaTestOverride().orElse(null);
    Pass pass = new Pass(builder.build(), framebufferBeforeTranslucents, framebufferAfterTranslucents, alphaTestOverride, programDirectives.getBlendModeOverride());
    allPasses.add(pass);
    return pass;
}
Also used : AlphaTestOverride(net.coderbot.iris.gl.blending.AlphaTestOverride) ImmutableSet(com.google.common.collect.ImmutableSet) TextureStage(net.coderbot.iris.shaderpack.texture.TextureStage) ProgramSamplers(net.coderbot.iris.gl.program.ProgramSamplers) GlFramebuffer(net.coderbot.iris.gl.framebuffer.GlFramebuffer)

Example 4 with GlFramebuffer

use of net.coderbot.iris.gl.framebuffer.GlFramebuffer in project Iris by IrisShaders.

the class RenderTargets method destroy.

public void destroy() {
    for (GlFramebuffer owned : ownedFramebuffers) {
        owned.destroy();
    }
    for (net.coderbot.iris.rendertarget.RenderTarget target : targets) {
        target.destroy();
    }
    depthTexture.destroy();
    noTranslucents.destroy();
    noHand.destroy();
}
Also used : GlFramebuffer(net.coderbot.iris.gl.framebuffer.GlFramebuffer)

Example 5 with GlFramebuffer

use of net.coderbot.iris.gl.framebuffer.GlFramebuffer in project Iris by IrisShaders.

the class RenderTargets method createGbufferFramebuffer.

public GlFramebuffer createGbufferFramebuffer(ImmutableSet<Integer> stageWritesToAlt, int[] drawBuffers) {
    if (drawBuffers.length == 0) {
        throw new IllegalArgumentException("Framebuffer must have at least one color buffer");
    }
    ImmutableSet<Integer> stageWritesToMain = invert(stageWritesToAlt, drawBuffers);
    GlFramebuffer framebuffer = createColorFramebuffer(stageWritesToMain, drawBuffers);
    framebuffer.addDepthAttachment(this.getDepthTexture().getTextureId());
    return framebuffer;
}
Also used : GlFramebuffer(net.coderbot.iris.gl.framebuffer.GlFramebuffer)

Aggregations

GlFramebuffer (net.coderbot.iris.gl.framebuffer.GlFramebuffer)5 ImmutableSet (com.google.common.collect.ImmutableSet)1 AlphaTestOverride (net.coderbot.iris.gl.blending.AlphaTestOverride)1 ProgramSamplers (net.coderbot.iris.gl.program.ProgramSamplers)1 TextureStage (net.coderbot.iris.shaderpack.texture.TextureStage)1