Search in sources :

Example 1 with Shader

use of meteordevelopment.meteorclient.renderer.Shader in project meteor-client by MeteorDevelopment.

the class EntityShaders method initOverlay.

// Overlay
public static void initOverlay(String shaderName) {
    overlayShader = new Shader("outline.vert", shaderName + ".frag");
    overlayFramebuffer = new SimpleFramebuffer(mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight(), false, false);
    overlayVertexConsumerProvider = new OutlineVertexConsumerProvider(mc.getBufferBuilders().getEntityVertexConsumers());
    timer = 0;
}
Also used : OutlineVertexConsumerProvider(net.minecraft.client.render.OutlineVertexConsumerProvider) Shader(meteordevelopment.meteorclient.renderer.Shader) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer)

Example 2 with Shader

use of meteordevelopment.meteorclient.renderer.Shader in project meteor-client by MeteorDevelopment.

the class EntityShaders method initOutlines.

// Outlines
@Init(stage = InitStage.Pre)
public static void initOutlines() {
    outlinesShader = new Shader("outline.vert", "outline.frag");
    outlinesFramebuffer = new SimpleFramebuffer(mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight(), false, false);
    outlinesVertexConsumerProvider = new OutlineVertexConsumerProvider(mc.getBufferBuilders().getEntityVertexConsumers());
}
Also used : OutlineVertexConsumerProvider(net.minecraft.client.render.OutlineVertexConsumerProvider) Shader(meteordevelopment.meteorclient.renderer.Shader) SimpleFramebuffer(net.minecraft.client.gl.SimpleFramebuffer) Init(meteordevelopment.meteorclient.utils.Init)

Example 3 with Shader

use of meteordevelopment.meteorclient.renderer.Shader in project meteor-client by MeteorDevelopment.

the class Blur method onRenderAfterWorld.

private void onRenderAfterWorld() {
    // Enable / disable with fading
    boolean shouldRender = shouldRender();
    long time = System.currentTimeMillis();
    if (enabled) {
        if (!shouldRender) {
            if (fadeEndAt == -1)
                fadeEndAt = System.currentTimeMillis() + fadeTime.get();
            if (time >= fadeEndAt) {
                enabled = false;
                fadeEndAt = -1;
            }
        }
    } else {
        if (shouldRender) {
            enabled = true;
            fadeEndAt = System.currentTimeMillis() + fadeTime.get();
        }
    }
    if (!enabled)
        return;
    // Initialize shader and framebuffer if running for the first time
    if (shader == null) {
        shader = new Shader("blur.vert", "blur.frag");
        fbo1 = new Framebuffer();
        fbo2 = new Framebuffer();
    }
    // Prepare stuff for rendering
    int sourceTexture = mc.getFramebuffer().getColorAttachment();
    shader.bind();
    shader.set("u_Size", mc.getWindow().getFramebufferWidth(), mc.getWindow().getFramebufferHeight());
    shader.set("u_Texture", 0);
    // Update progress
    double progress = 1;
    if (time < fadeEndAt) {
        if (shouldRender)
            progress = 1 - (fadeEndAt - time) / fadeTime.get().doubleValue();
        else
            progress = (fadeEndAt - time) / fadeTime.get().doubleValue();
    } else {
        fadeEndAt = -1;
    }
    // Render the blur
    shader.set("u_Radius", Math.floor(radius.get() * progress));
    PostProcessRenderer.beginRender();
    fbo1.bind();
    GL.bindTexture(sourceTexture);
    shader.set("u_Direction", 1.0, 0.0);
    PostProcessRenderer.render();
    if (mode.get() == Mode.Fancy)
        fbo2.bind();
    else
        fbo2.unbind();
    GL.bindTexture(fbo1.texture);
    shader.set("u_Direction", 0.0, 1.0);
    PostProcessRenderer.render();
    if (mode.get() == Mode.Fancy) {
        fbo1.bind();
        GL.bindTexture(fbo2.texture);
        shader.set("u_Direction", 1.0, 0.0);
        PostProcessRenderer.render();
        fbo2.unbind();
        GL.bindTexture(fbo1.texture);
        shader.set("u_Direction", 0.0, 1.0);
        PostProcessRenderer.render();
    }
    PostProcessRenderer.endRender();
}
Also used : Framebuffer(meteordevelopment.meteorclient.renderer.Framebuffer) Shader(meteordevelopment.meteorclient.renderer.Shader)

Aggregations

Shader (meteordevelopment.meteorclient.renderer.Shader)3 SimpleFramebuffer (net.minecraft.client.gl.SimpleFramebuffer)2 OutlineVertexConsumerProvider (net.minecraft.client.render.OutlineVertexConsumerProvider)2 Framebuffer (meteordevelopment.meteorclient.renderer.Framebuffer)1 Init (meteordevelopment.meteorclient.utils.Init)1