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();
}
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);
}
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;
}
}
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();
}
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();
}
Aggregations