Search in sources :

Example 1 with Framebuffer

use of net.minecraft.client.gl.Framebuffer in project BleachHack by BleachDrinker420.

the class ShaderEffectWrapper method drawFramebufferToMain.

public void drawFramebufferToMain(String framebuffer) {
    Framebuffer buffer = getFramebuffer(framebuffer);
    Shader blitshader = mc.gameRenderer.blitScreenShader;
    blitshader.addSampler("DiffuseSampler", buffer.getColorAttachment());
    double w = mc.getWindow().getFramebufferWidth();
    double h = mc.getWindow().getFramebufferHeight();
    float ws = (float) buffer.viewportWidth / (float) buffer.textureWidth;
    float hs = (float) buffer.viewportHeight / (float) buffer.textureHeight;
    RenderSystem.enableBlend();
    RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
    GlStateManager._colorMask(true, true, true, false);
    GlStateManager._disableDepthTest();
    GlStateManager._depthMask(false);
    GlStateManager._viewport(0, 0, (int) w, (int) h);
    blitshader.bind();
    Tessellator tessellator = RenderSystem.renderThreadTesselator();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
    bufferBuilder.vertex(0, h, 0).texture(0f, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, h, 0).texture(ws, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, 0, 0).texture(ws, hs).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(0, 0, 0).texture(0f, hs).color(255, 255, 255, 255).next();
    bufferBuilder.end();
    BufferRenderer.postDraw(bufferBuilder);
    blitshader.unbind();
    GlStateManager._depthMask(true);
    GlStateManager._colorMask(true, true, true, true);
    RenderSystem.disableBlend();
}
Also used : Framebuffer(net.minecraft.client.gl.Framebuffer) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) Shader(net.minecraft.client.render.Shader)

Example 2 with Framebuffer

use of net.minecraft.client.gl.Framebuffer in project isometric-renders by gliscowo.

the class IsometricRenderHelper method renderIntoImage.

public static NativeImage renderIntoImage(int size, RenderCallback renderCallback) {
    Framebuffer framebuffer = new Framebuffer(size, size, true, MinecraftClient.IS_SYSTEM_MAC);
    RenderSystem.pushMatrix();
    RenderSystem.enableBlend();
    RenderSystem.clear(16640, MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.setClearColor(0, 0, 0, 0);
    framebuffer.clear(MinecraftClient.IS_SYSTEM_MAC);
    framebuffer.beginWrite(true);
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    RenderSystem.ortho(-1, 1, 1, -1, -100.0, 100.0);
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.pushMatrix();
    RenderSystem.loadIdentity();
    setupLighting();
    VertexConsumerProvider.Immediate vertexConsumers = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    MatrixStack matrixStack = new MatrixStack();
    renderCallback.render(matrixStack, vertexConsumers, ((MinecraftClientAccessor) MinecraftClient.getInstance()).getRenderTickCounter().tickDelta);
    vertexConsumers.draw();
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_PROJECTION);
    RenderSystem.popMatrix();
    RenderSystem.matrixMode(GL11.GL_MODELVIEW);
    RenderSystem.popMatrix();
    framebuffer.endWrite();
    return takeKeyedSnapshot(framebuffer, RuntimeConfig.backgroundColor, false, false);
}
Also used : MinecraftClientAccessor(com.glisco.isometricrenders.mixin.MinecraftClientAccessor) Framebuffer(net.minecraft.client.gl.Framebuffer) MatrixStack(net.minecraft.client.util.math.MatrixStack) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 3 with Framebuffer

use of net.minecraft.client.gl.Framebuffer in project Client by MatHax.

the class WorldRendererMixin method renderEntity.

@Inject(method = "renderEntity", at = @At("HEAD"))
private void renderEntity(Entity entity, double cameraX, double cameraY, double cameraZ, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo info) {
    if (EntityShaders.shouldDrawOverlay(entity) && vertexConsumers != EntityShaders.overlayVertexConsumerProvider && vertexConsumers != EntityShaders.outlinesVertexConsumerProvider) {
        Framebuffer prevBuffer = this.entityOutlinesFramebuffer;
        this.entityOutlinesFramebuffer = EntityShaders.overlayFramebuffer;
        EntityShaders.overlayVertexConsumerProvider.setColor(0, 0, 0, 100);
        GlStateManager._disableDepthTest();
        renderEntity(entity, cameraX, cameraY, cameraZ, tickDelta, matrices, EntityShaders.overlayVertexConsumerProvider);
        GlStateManager._enableDepthTest();
        this.entityOutlinesFramebuffer = prevBuffer;
    }
    if (EntityShaders.shouldDrawOutline(entity) && vertexConsumers != EntityShaders.outlinesVertexConsumerProvider && vertexConsumers != EntityShaders.overlayVertexConsumerProvider) {
        Framebuffer prevBuffer = this.entityOutlinesFramebuffer;
        this.entityOutlinesFramebuffer = EntityShaders.outlinesFramebuffer;
        Utils.renderingEntityOutline = true;
        Color color = Modules.get().get(ESP.class).getOutlineColor(entity);
        EntityShaders.outlinesVertexConsumerProvider.setColor(color.r, color.g, color.b, color.a);
        GlStateManager._disableDepthTest();
        renderEntity(entity, cameraX, cameraY, cameraZ, tickDelta, matrices, EntityShaders.outlinesVertexConsumerProvider);
        GlStateManager._enableDepthTest();
        Utils.renderingEntityOutline = false;
        this.entityOutlinesFramebuffer = prevBuffer;
    }
}
Also used : Framebuffer(net.minecraft.client.gl.Framebuffer) Color(mathax.client.utils.render.color.Color)

Example 4 with Framebuffer

use of net.minecraft.client.gl.Framebuffer in project Client by MatHax.

the class EntityShaders method renderOutlines.

public static void renderOutlines(Runnable draw, boolean entities, int width, float fillOpacity, ShapeMode shapeMode) {
    WorldRenderer worldRenderer = mc.worldRenderer;
    WorldRendererAccessor wra = (WorldRendererAccessor) worldRenderer;
    Framebuffer fbo = worldRenderer.getEntityOutlinesFramebuffer();
    if (entities)
        wra.setEntityOutlinesFramebuffer(outlinesFramebuffer);
    else {
        outlinesFramebuffer.clear(false);
        outlinesFramebuffer.beginWrite(false);
    }
    draw.run();
    if (entities)
        wra.setEntityOutlinesFramebuffer(fbo);
    mc.getFramebuffer().beginWrite(false);
    GL.bindTexture(outlinesFramebuffer.getColorAttachment());
    outlinesShader.bind();
    outlinesShader.set("u_Size", mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
    outlinesShader.set("u_Texture", 0);
    outlinesShader.set("u_Width", width);
    outlinesShader.set("u_FillOpacity", fillOpacity / 255.0);
    outlinesShader.set("u_ShapeMode", shapeMode.ordinal());
    PostProcessRenderer.render();
}
Also used : WorldRendererAccessor(mathax.client.mixin.WorldRendererAccessor) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer) Framebuffer(net.minecraft.client.gl.Framebuffer) WorldRenderer(net.minecraft.client.render.WorldRenderer)

Example 5 with Framebuffer

use of net.minecraft.client.gl.Framebuffer in project KiwiClient by TangyKiwi.

the class ShaderEffectWrapper method drawFramebufferToMain.

public void drawFramebufferToMain(String framebuffer) {
    Framebuffer buffer = getFramebuffer(framebuffer);
    Shader blitshader = mc.gameRenderer.blitScreenShader;
    blitshader.addSampler("DiffuseSampler", buffer.getColorAttachment());
    double w = mc.getWindow().getFramebufferWidth();
    double h = mc.getWindow().getFramebufferHeight();
    float ws = (float) buffer.viewportWidth / (float) buffer.textureWidth;
    float hs = (float) buffer.viewportHeight / (float) buffer.textureHeight;
    RenderSystem.enableBlend();
    RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
    GlStateManager._colorMask(true, true, true, false);
    GlStateManager._disableDepthTest();
    GlStateManager._depthMask(false);
    GlStateManager._viewport(0, 0, (int) w, (int) h);
    blitshader.bind();
    Tessellator tessellator = RenderSystem.renderThreadTesselator();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
    bufferBuilder.vertex(0, h, 0).texture(0f, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, h, 0).texture(ws, 0f).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(w, 0, 0).texture(ws, hs).color(255, 255, 255, 255).next();
    bufferBuilder.vertex(0, 0, 0).texture(0f, hs).color(255, 255, 255, 255).next();
    bufferBuilder.end();
    BufferRenderer.postDraw(bufferBuilder);
    blitshader.unbind();
    GlStateManager._depthMask(true);
    GlStateManager._colorMask(true, true, true, true);
    RenderSystem.disableBlend();
}
Also used : Framebuffer(net.minecraft.client.gl.Framebuffer) Tessellator(net.minecraft.client.render.Tessellator) BufferBuilder(net.minecraft.client.render.BufferBuilder) Shader(net.minecraft.client.render.Shader)

Aggregations

Framebuffer (net.minecraft.client.gl.Framebuffer)9 SimpleFramebuffer (net.minecraft.client.gl.SimpleFramebuffer)4 WorldRenderer (net.minecraft.client.render.WorldRenderer)4 WorldRendererAccessor (mathax.client.mixin.WorldRendererAccessor)2 WorldRendererAccessor (meteordevelopment.meteorclient.mixin.WorldRendererAccessor)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 Shader (net.minecraft.client.render.Shader)2 Tessellator (net.minecraft.client.render.Tessellator)2 MinecraftClientAccessor (com.glisco.isometricrenders.mixin.MinecraftClientAccessor)1 Color (mathax.client.utils.render.color.Color)1 Color (meteordevelopment.meteorclient.utils.render.color.Color)1 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1