Skip to content

Commit

Permalink
Fix many visual issues with the shader list
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Oct 22, 2024
1 parent 243d3b4 commit 761fcc6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
private OptionMenuContainer container;

public ShaderPackOptionList(ShaderPackScreen screen, NavigationController navigation, ShaderPack pack, Minecraft client, int width, int height, int top, int bottom, int left, int right) {
super(client, width, bottom, top, bottom, left, right, 24);
super(client, width, bottom, top + 4, bottom, left, right, 24);
this.navigation = navigation;
this.screen = screen;

Expand Down Expand Up @@ -78,31 +78,29 @@ public int getRowWidth() {

@Override
protected void renderListBackground(GuiGraphics pAbstractSelectionList0) {
if (screen.listTransition.getAsFloat() < 0.02f) return;
float transition = screen.listTransition.getAsFloat();
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, screen.listTransition.getAsFloat());
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, Math.max(screen.listTransition.getAsFloat(), 0.01f));
pAbstractSelectionList0.blit(RenderType::guiTextured,
MENU_LIST_BACKGROUND,
this.getX(),
this.getY() + 3,
(float) this.getRight(),
(float) (this.getBottom() + (int) this.getScrollAmount()),
this.getWidth(),
this.getHeight(),
32,
32
this.getX(), this.getY(), (float)this.getRight(), (float)(this.getBottom() + (int)this.getScrollAmount()), this.getWidth(), this.getHeight(), 32, 32
);
if (transition < 0.99f) pAbstractSelectionList0.flush();

RenderSystem.disableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
}

@Override
protected void renderListSeparators(GuiGraphics pAbstractSelectionList0) {
float transition = screen.listTransition.getAsFloat();
if (transition < 0.02f) return;
if (transition < 0.99f) pAbstractSelectionList0.flush();
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, screen.listTransition.getAsFloat());
pAbstractSelectionList0.blit(RenderType::guiTextured, CreateWorldScreen.HEADER_SEPARATOR, this.getX(), this.getY() + 2, 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, Math.max(screen.listTransition.getAsFloat(), 0.01f));
pAbstractSelectionList0.blit(RenderType::guiTextured, CreateWorldScreen.HEADER_SEPARATOR, this.getX(), this.getY() - 2, 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
pAbstractSelectionList0.blit(RenderType::guiTextured, CreateWorldScreen.FOOTER_SEPARATOR, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
if (transition < 0.99f) pAbstractSelectionList0.flush();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.disableBlend();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,32 @@ public void close() throws IOException {

@Override
protected void renderListBackground(GuiGraphics pAbstractSelectionList0) {
if (screen.listTransition.getAsFloat() < 0.02f) return;
float transition = screen.listTransition.getAsFloat();
if (transition < 0.02f) return;
if (transition < 0.99f) pAbstractSelectionList0.flush();
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, screen.listTransition.getAsFloat());
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, Math.max(screen.listTransition.getAsFloat(), 0.01f));
pAbstractSelectionList0.blit(RenderType::guiTextured,
MENU_LIST_BACKGROUND,
this.getX(),
this.getY() - 2,
(float) this.getRight(),
(float) (this.getBottom() + (int) this.getScrollAmount()),
this.getWidth(),
this.getHeight(),
32,
32
this.getX(), this.getY(), (float)this.getRight(), (float)(this.getBottom() + (int)this.getScrollAmount()), this.getWidth(), this.getHeight(), 32, 32
);
if (transition < 0.99f) pAbstractSelectionList0.flush();

RenderSystem.disableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
}

@Override
protected void renderListSeparators(GuiGraphics pAbstractSelectionList0) {
float transition = screen.listTransition.getAsFloat();
if (transition < 0.02f) return;
if (transition < 0.99f) pAbstractSelectionList0.flush();
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, screen.listTransition.getAsFloat());
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, Math.max(screen.listTransition.getAsFloat(), 0.01f));
pAbstractSelectionList0.blit(RenderType::guiTextured, CreateWorldScreen.HEADER_SEPARATOR, this.getX(), this.getY() - 2, 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
pAbstractSelectionList0.blit(RenderType::guiTextured, CreateWorldScreen.FOOTER_SEPARATOR, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2);
if (transition < 0.99f) pAbstractSelectionList0.flush();

RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.disableBlend();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelTargetBundle;
import net.minecraft.client.renderer.PostChain;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
Expand Down Expand Up @@ -150,7 +153,6 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
this.shaderPackList.render(guiGraphics, mouseX, mouseY, delta);
}
} else {
this.renderBlurredBackground(delta);
this.showHideButton.render(guiGraphics, mouseX, mouseY, delta);
}

Expand Down Expand Up @@ -229,12 +231,12 @@ protected void init() {
this.removeWidget(this.shaderPackList);
this.removeWidget(this.shaderOptionList);

this.shaderPackList = new ShaderPackSelectionList(this, this.minecraft, this.width, this.height, 32, this.height - 58 - 32, 0, this.width);
this.shaderPackList = new ShaderPackSelectionList(this, this.minecraft, this.width, this.height, 32, this.height - 58 - 36, 0, this.width);

if (Iris.getCurrentPack().isPresent() && this.navigation != null) {
ShaderPack currentPack = Iris.getCurrentPack().get();

this.shaderOptionList = new ShaderPackOptionList(this, this.navigation, currentPack, this.minecraft, this.width, this.height, 32, this.height - 58 - 32, 0, this.width);
this.shaderOptionList = new ShaderPackOptionList(this, this.navigation, currentPack, this.minecraft, this.width, this.height, 32, this.height - 58 - 36, 0, this.width);
this.navigation.setActiveOptionList(this.shaderOptionList);

this.shaderOptionList.rebuild();
Expand Down Expand Up @@ -351,13 +353,23 @@ public void refreshScreenSwitchButton() {
this.screenSwitchButton.active = optionMenuOpen || shaderPackList.getTopButtonRow().shadersEnabled;
}
}
private static final ResourceLocation BLUR_POST_CHAIN_ID = ResourceLocation.withDefaultNamespace("blur");

private void processFixedBlur() {
float f = Math.min(this.minecraft.options.getMenuBackgroundBlurriness(), this.blurTransition.getAsFloat());
if (!(f < 1.0F)) {
PostChain postChain = this.minecraft.getShaderManager().getPostChain(BLUR_POST_CHAIN_ID, LevelTargetBundle.MAIN_TARGETS);
if (postChain != null) {
postChain.setUniform("Radius", f);
postChain.process(this.minecraft.getMainRenderTarget(), ((GameRendererAccessor) this.minecraft.gameRenderer).getResourcePool());
}

private void processFixedBlur(float tick) {
// TODO IMS 24w35a
}
}

protected void renderBlurredBackground(float pScreen0) {
processFixedBlur(pScreen0);
@Override
protected void renderBlurredBackground() {
processFixedBlur();
this.minecraft.getMainRenderTarget().bindWrite(false);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.irisshaders.iris.mixin;

import com.mojang.blaze3d.resource.CrossFrameResourcePool;
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.GameRenderer;
Expand Down Expand Up @@ -27,4 +29,7 @@ public interface GameRendererAccessor {

@Invoker("shouldRenderBlockOutline")
boolean shouldRenderBlockOutlineA();

@Accessor("resourcePool")
CrossFrameResourcePool getResourcePool();
}

0 comments on commit 761fcc6

Please sign in to comment.