public static class Blur implements IMinecraft {
private static final Supplier<RenderTarget> TEMP_FBO_SUPPLIER = Suppliers
.memoize(() -> new MainTarget(1920, 1024, false));
public static void drawBlur(GuiGraphics guiGraphics, float x, float y, float width, float height, float radius, float blurRadius, int color) {
RenderTarget MAIN_FBO = mc.getMainRenderTarget();
RenderTarget fbo = TEMP_FBO_SUPPLIER.get();
if (fbo.width != MAIN_FBO.width || fbo.height != MAIN_FBO.height) {
fbo.resize(MAIN_FBO.width, MAIN_FBO.height);
}
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
fbo.bindWrite(false);
MAIN_FBO.blitToScreen(fbo.width, fbo.height);
MAIN_FBO.bindWrite(false);
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
Matrix4f matrix4f = guiGraphics.pose.last().pose();
CompiledShaderProgram shader = RenderSystem.setShader(CoreShaders.RENDERTYPE_BLUR);
shader.getUniform("Size").set(width, height);
shader.getUniform("Radius").set(radius, radius, radius, radius);
shader.getUniform("Smoothness").set(1.f);
shader.getUniform("BlurRadius").set(blurRadius);
BufferBuilder builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
builder.addVertex(matrix4f, x, y, 0).setColor(color);
builder.addVertex(matrix4f, x, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y, 0).setColor(color);
tesselator.draw(builder);
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
public static void drawBlur(GuiGraphics guiGraphics, float x, float y, float width, float height, Vector4f radius, float blurRadius, int color) {
RenderTarget MAIN_FBO = mc.getMainRenderTarget();
RenderTarget fbo = TEMP_FBO_SUPPLIER.get();
if (fbo.width != MAIN_FBO.width || fbo.height != MAIN_FBO.height) {
fbo.resize(MAIN_FBO.width, MAIN_FBO.height);
}
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
fbo.bindWrite(false);
MAIN_FBO.blitToScreen(fbo.width, fbo.height);
MAIN_FBO.bindWrite(false);
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
Matrix4f matrix4f = guiGraphics.pose.last().pose();
CompiledShaderProgram shader = RenderSystem.setShader(CoreShaders.RENDERTYPE_BLUR);
shader.getUniform("Size").set(width, height);
shader.getUniform("Radius").set(radius.x, radius.y, radius.z, radius.w);
shader.getUniform("Smoothness").set(1.f);
shader.getUniform("BlurRadius").set(blurRadius);
BufferBuilder builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
builder.addVertex(matrix4f, x, y, 0).setColor(color);
builder.addVertex(matrix4f, x, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y, 0).setColor(color);
tesselator.draw(builder);
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
public static void drawBlur(GuiGraphics guiGraphics, float x, float y, float width, float height, float radius, float blurRadius, int color, float smoothness) {
RenderTarget MAIN_FBO = mc.getMainRenderTarget();
RenderTarget fbo = TEMP_FBO_SUPPLIER.get();
if (fbo.width != MAIN_FBO.width || fbo.height != MAIN_FBO.height) {
fbo.resize(MAIN_FBO.width, MAIN_FBO.height);
}
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
fbo.bindWrite(false);
MAIN_FBO.blitToScreen(fbo.width, fbo.height);
MAIN_FBO.bindWrite(false);
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
Matrix4f matrix4f = guiGraphics.pose.last().pose();
CompiledShaderProgram shader = RenderSystem.setShader(CoreShaders.RENDERTYPE_BLUR);
shader.getUniform("Size").set(width, height);
shader.getUniform("Radius").set(radius, radius, radius, radius);
shader.getUniform("Smoothness").set(smoothness);
shader.getUniform("BlurRadius").set(blurRadius);
BufferBuilder builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
builder.addVertex(matrix4f, x, y, 0).setColor(color);
builder.addVertex(matrix4f, x, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y, 0).setColor(color);
tesselator.draw(builder);
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
public static void drawBlur(GuiGraphics guiGraphics, float x, float y, float width, float height, Vector4f radius, float blurRadius, int color, float smoothness) {
RenderTarget MAIN_FBO = mc.getMainRenderTarget();
RenderTarget fbo = TEMP_FBO_SUPPLIER.get();
if (fbo.width != MAIN_FBO.width || fbo.height != MAIN_FBO.height) {
fbo.resize(MAIN_FBO.width, MAIN_FBO.height);
}
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.disableCull();
fbo.bindWrite(false);
MAIN_FBO.blitToScreen(fbo.width, fbo.height);
MAIN_FBO.bindWrite(false);
RenderSystem.setShaderTexture(0, fbo.getColorTextureId());
Matrix4f matrix4f = guiGraphics.pose.last().pose();
CompiledShaderProgram shader = RenderSystem.setShader(CoreShaders.RENDERTYPE_BLUR);
shader.getUniform("Size").set(width, height);
shader.getUniform("Radius").set(radius.x, radius.y, radius.z, radius.w);
shader.getUniform("Smoothness").set(smoothness);
shader.getUniform("BlurRadius").set(blurRadius);
BufferBuilder builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
builder.addVertex(matrix4f, x, y, 0).setColor(color);
builder.addVertex(matrix4f, x, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y + height, 0).setColor(color);
builder.addVertex(matrix4f, x + width, y, 0).setColor(color);
tesselator.draw(builder);
RenderSystem.setShaderTexture(0, 0);
RenderSystem.enableCull();
RenderSystem.disableBlend();
}
}