Search in sources :

Example 1 with ShaderGroup

use of v1_8_9.net.minecraft.client.shader.ShaderGroup in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionRenderer method switchAndRenderTheWorld.

// code from immersive portals, test may not have been successful, code may be removed in future
private static void switchAndRenderTheWorld(ClientWorld newWorld, Vector3d thisTickCameraPos, Vector3d lastTickCameraPos, Consumer<Runnable> invokeWrapper, int renderDistance) {
    resetGlStates();
    Entity cameraEntity = client.cameraEntity;
    Vector3d oldEyePos = McHelper.getEyePos(cameraEntity);
    Vector3d oldLastTickEyePos = McHelper.getLastTickEyePos(cameraEntity);
    RegistryKey<World> oldEntityDimension = cameraEntity.level.dimension();
    ClientWorld oldEntityWorld = (ClientWorld) cameraEntity.level;
    RegistryKey<World> newDimension = newWorld.dimension();
    McHelper.setEyePos(cameraEntity, thisTickCameraPos, lastTickCameraPos);
    cameraEntity.level = newWorld;
    WorldRenderer worldRenderer = ClientWorldLoader.getWorldRenderer(newDimension);
    // CHelper.checkGlError();
    float tickDelta = RenderStates.tickDelta;
    if (com.qouteall.immersive_portals.CGlobal.useHackedChunkRenderDispatcher) {
        ((IEWorldRenderer) worldRenderer).getBuiltChunkStorage().repositionCamera(cameraEntity.getX(), cameraEntity.getZ());
    }
    IEGameRenderer ieGameRenderer = (IEGameRenderer) client.gameRenderer;
    DimensionRenderHelper helper = ClientWorldLoader.getDimensionRenderHelper(RenderDimensionRedirect.getRedirectedDimension(newDimension));
    NetworkPlayerInfo playerListEntry = Minecraft.getInstance().getConnection().getPlayerInfo(Minecraft.getInstance().player.getGameProfile().getId());
    ActiveRenderInfo newCamera = new ActiveRenderInfo();
    WorldRenderer oldWorldRenderer = client.levelRenderer;
    LightTexture oldLightmap = client.gameRenderer.lightTexture();
    GameType oldGameMode = playerListEntry.getGameMode();
    boolean oldNoClip = client.player.noPhysics;
    boolean oldDoRenderHand = ieGameRenderer.getDoRenderHand();
    OFInterface.createNewRenderInfosNormal.accept(worldRenderer);
    ObjectList oldVisibleChunks = ((IEWorldRenderer) oldWorldRenderer).getVisibleChunks();
    RayTraceResult oldCrosshairTarget = client.hitResult;
    ActiveRenderInfo oldCamera = client.gameRenderer.getMainCamera();
    ShaderGroup oldTransparencyShader = ((IEWorldRenderer) oldWorldRenderer).portal_getTransparencyShader();
    ShaderGroup newTransparencyShader = ((IEWorldRenderer) worldRenderer).portal_getTransparencyShader();
    RenderTypeBuffers oldBufferBuilder = ((IEWorldRenderer) worldRenderer).getBufferBuilderStorage();
    RenderTypeBuffers oldClientBufferBuilder = client.renderBuffers();
    boolean oldChunkCullingEnabled = client.smartCull;
    ((IEWorldRenderer) oldWorldRenderer).setVisibleChunks(new ObjectArrayList());
    int oldRenderDistance = ((IEWorldRenderer) worldRenderer).portal_getRenderDistance();
    ((IEMinecraftClient) client).setWorldRenderer(worldRenderer);
    client.level = newWorld;
    ieGameRenderer.setLightmapTextureManager(helper.lightmapTexture);
    TileEntityRendererDispatcher.instance.level = newWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(GameType.SPECTATOR);
    client.player.noPhysics = true;
    ieGameRenderer.setDoRenderHand(false);
    GlStateManager._matrixMode(5888);
    GlStateManager._pushMatrix();
    // FogRendererContext.swappingManager.pushSwapping(RenderDimensionRedirect.getRedirectedDimension(newDimension));
    ((IEParticleManager) client.particleEngine).mySetWorld(newWorld);
    if (BlockManipulationClient.remotePointedDim == newDimension) {
        client.hitResult = BlockManipulationClient.remoteHitResult;
    }
    ieGameRenderer.setCamera(newCamera);
    if (Global.useSecondaryEntityVertexConsumer) {
    // ((IEWorldRenderer)worldRenderer).setBufferBuilderStorage(secondaryBufferBuilderStorage);
    // ((IEMinecraftClient)client).setBufferBuilderStorage(secondaryBufferBuilderStorage);
    }
    // ((IEWorldRenderer)worldRenderer).portal_setRenderDistance(renderDistance);
    if (Global.looseVisibleChunkIteration) {
        client.smartCull = false;
    }
    if (!RenderStates.isDimensionRendered(newDimension)) {
        helper.lightmapTexture.updateLightTexture(0.0F);
    }
    try {
        invokeWrapper.accept(() -> {
            // /client.getProfiler().push("render_portal_content");
            client.gameRenderer.renderLevel(tickDelta, Util.getNanos(), new MatrixStack());
        // client.getProfiler().pop();
        });
    } catch (Throwable var34) {
    // limitedLogger.invoke(var34::printStackTrace);
    }
    // SodiumInterface.switchRenderingContext.apply(worldRenderer, oldSodiumContext);
    ((IEMinecraftClient) client).setWorldRenderer(oldWorldRenderer);
    client.level = oldEntityWorld;
    ieGameRenderer.setLightmapTextureManager(oldLightmap);
    TileEntityRendererDispatcher.instance.level = oldEntityWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(oldGameMode);
    client.player.noPhysics = oldNoClip;
    ieGameRenderer.setDoRenderHand(oldDoRenderHand);
    GlStateManager._matrixMode(5888);
    GlStateManager._popMatrix();
    ((IEParticleManager) client.particleEngine).mySetWorld(oldEntityWorld);
    client.hitResult = oldCrosshairTarget;
    ieGameRenderer.setCamera(oldCamera);
    // ((IEWorldRenderer)oldWorldRenderer).portal_setTransparencyShader(oldTransparencyShader);
    // ((IEWorldRenderer)worldRenderer).portal_setTransparencyShader(newTransparencyShader);
    // FogRendererContext.swappingManager.popSwapping();
    ((IEWorldRenderer) oldWorldRenderer).setVisibleChunks(oldVisibleChunks);
    ((IEWorldRenderer) worldRenderer).setBufferBuilderStorage(oldBufferBuilder);
    ((IEMinecraftClient) client).setBufferBuilderStorage(oldClientBufferBuilder);
    ((IEWorldRenderer) worldRenderer).portal_setRenderDistance(oldRenderDistance);
    if (Global.looseVisibleChunkIteration) {
        client.smartCull = oldChunkCullingEnabled;
    }
    client.getEntityRenderDispatcher().prepare(client.level, oldCamera, client.crosshairPickEntity);
    // CHelper.checkGlError();
    cameraEntity.level = oldEntityWorld;
    McHelper.setEyePos(cameraEntity, oldEyePos, oldLastTickEyePos);
    resetGlStates();
}
Also used : Entity(net.minecraft.entity.Entity) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GameType(net.minecraft.world.GameType) AirshipWorld(com.eriksonn.createaeronautics.dimension.AirshipWorld) World(net.minecraft.world.World) ClientWorld(net.minecraft.client.world.ClientWorld) NetworkPlayerInfo(net.minecraft.client.network.play.NetworkPlayerInfo) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ShaderGroup(net.minecraft.client.shader.ShaderGroup) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vector3d(net.minecraft.util.math.vector.Vector3d) ObjectList(it.unimi.dsi.fastutil.objects.ObjectList) ClientWorld(net.minecraft.client.world.ClientWorld)

Example 2 with ShaderGroup

use of v1_8_9.net.minecraft.client.shader.ShaderGroup in project Client by Sol-Client.

the class ColourSaturationMod method update.

public void update() {
    if (group == null) {
        groupSaturation = saturation;
        try {
            group = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), RESOURCE_LOCATION);
            group.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
        } catch (JsonSyntaxException | IOException error) {
            logger.error("Could not load saturation shader", error);
        }
    }
    if (groupSaturation != saturation) {
        ((AccessShaderGroup) group).getListShaders().forEach((shader) -> {
            ShaderUniform saturationUniform = shader.getShaderManager().getShaderUniform("Saturation");
            if (saturationUniform != null) {
                saturationUniform.set(saturation);
            }
        });
        groupSaturation = saturation;
    }
}
Also used : AccessShaderGroup(me.mcblueparrot.client.util.access.AccessShaderGroup) ShaderGroup(net.minecraft.client.shader.ShaderGroup) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ShaderUniform(net.minecraft.client.shader.ShaderUniform)

Example 3 with ShaderGroup

use of v1_8_9.net.minecraft.client.shader.ShaderGroup in project Client by Sol-Client.

the class MenuBlurMod method update.

public void update() {
    if (group == null) {
        try {
            group = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), RESOURCE_LOCATION);
            group.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
        } catch (JsonSyntaxException | IOException error) {
            logger.error("Could not load menu blur", error);
        }
    }
    ((AccessShaderGroup) group).getListShaders().forEach((shader) -> {
        ShaderUniform radius = shader.getShaderManager().getShaderUniform("Radius");
        ShaderUniform progress = shader.getShaderManager().getShaderUniform("Progress");
        if (radius != null) {
            radius.set(blur);
        }
        if (progress != null) {
            if (fadeTime > 0) {
                progress.set(getProgress());
            } else {
                progress.set(1);
            }
        }
    });
}
Also used : ShaderGroup(net.minecraft.client.shader.ShaderGroup) AccessShaderGroup(me.mcblueparrot.client.util.access.AccessShaderGroup) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ShaderUniform(net.minecraft.client.shader.ShaderUniform)

Example 4 with ShaderGroup

use of v1_8_9.net.minecraft.client.shader.ShaderGroup in project sol-client-glassmc by danterusdev.

the class ColourSaturationMod method update.

public void update() {
    if (group == null) {
        groupSaturation = saturation;
        try {
            group = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), RESOURCE_LOCATION);
            group.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
        } catch (JsonSyntaxException | IOException error) {
            logger.error("Could not load saturation shader", error);
        }
    }
    if (groupSaturation != saturation) {
        ((AccessShaderGroup) group).getListShaders().forEach((shader) -> {
            ShaderUniform saturationUniform = shader.getShaderManager().getShaderUniform("Saturation");
            if (saturationUniform != null) {
                saturationUniform.set(saturation);
            }
        });
        groupSaturation = saturation;
    }
}
Also used : AccessShaderGroup(me.mcblueparrot.client.mixin.client.access.AccessShaderGroup) ShaderGroup(v1_8_9.net.minecraft.client.shader.ShaderGroup) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ShaderUniform(v1_8_9.net.minecraft.client.shader.ShaderUniform)

Example 5 with ShaderGroup

use of v1_8_9.net.minecraft.client.shader.ShaderGroup in project sol-client-glassmc by danterusdev.

the class MenuBlurMod method update.

public void update() {
    if (group == null) {
        try {
            group = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), RESOURCE_LOCATION);
            group.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
        } catch (JsonSyntaxException | IOException error) {
            logger.error("Could not load menu blur", error);
        }
    }
    ((AccessShaderGroup) group).getListShaders().forEach((shader) -> {
        ShaderUniform radius = shader.getShaderManager().getShaderUniform("Radius");
        ShaderUniform progress = shader.getShaderManager().getShaderUniform("Progress");
        if (radius != null) {
            radius.set(blur);
        }
        if (progress != null) {
            if (fadeTime > 0) {
                progress.set(getProgress());
            } else {
                progress.set(1);
            }
        }
    });
}
Also used : AccessShaderGroup(me.mcblueparrot.client.mixin.client.access.AccessShaderGroup) ShaderGroup(v1_8_9.net.minecraft.client.shader.ShaderGroup) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ShaderUniform(v1_8_9.net.minecraft.client.shader.ShaderUniform)

Aggregations

ShaderGroup (net.minecraft.client.shader.ShaderGroup)18 JsonSyntaxException (com.google.gson.JsonSyntaxException)16 IOException (java.io.IOException)16 ResourceLocation (net.minecraft.util.ResourceLocation)6 ShaderUniform (net.minecraft.client.shader.ShaderUniform)4 ShaderGroup (v1_8_9.net.minecraft.client.shader.ShaderGroup)4 AccessShaderGroup (me.mcblueparrot.client.mixin.client.access.AccessShaderGroup)3 AccessShaderGroup (me.mcblueparrot.client.util.access.AccessShaderGroup)3 ShaderUniform (v1_8_9.net.minecraft.client.shader.ShaderUniform)3 PostProcessingEvent (me.mcblueparrot.client.event.impl.PostProcessingEvent)2 Framebuffer (net.minecraft.client.shader.Framebuffer)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 AirshipWorld (com.eriksonn.createaeronautics.dimension.AirshipWorld)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 IRenderGlobal (cope.cosmos.asm.mixins.accessor.IRenderGlobal)1 IShaderGroup (cope.cosmos.asm.mixins.accessor.IShaderGroup)1 DotShader (cope.cosmos.client.shader.shaders.DotShader)1 OutlineShader (cope.cosmos.client.shader.shaders.OutlineShader)1 RainbowOutlineShader (cope.cosmos.client.shader.shaders.RainbowOutlineShader)1 ObjectArrayList (it.unimi.dsi.fastutil.objects.ObjectArrayList)1