Skip applying the saturation shader if it's not required and remove unneccessary GL actions. Maybe Fixes #445

This commit is contained in:
Sollace 2024-09-25 20:47:23 +01:00
parent 4f4ac3f809
commit 2b979d4fe4
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -9,7 +9,6 @@ import com.google.common.collect.*;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.logging.LogUtils; import com.mojang.logging.LogUtils;
import it.unimi.dsi.fastutil.objects.Object2FloatMap; import it.unimi.dsi.fastutil.objects.Object2FloatMap;
@ -52,11 +51,7 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
} }
} }
if (shaderId == null) { if (shaderId == null || Unicopia.getConfig().disableShaders.get()) {
return;
}
if (Unicopia.getConfig().disableShaders.get()) {
return; return;
} }
@ -81,13 +76,10 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
} }
if (shader != null && client.player != null) { if (shader != null && client.player != null) {
RenderSystem.disableBlend();
RenderSystem.disableDepthTest();
RenderSystem.resetTextureMatrix();
Pony pony = Pony.of(client.player); Pony pony = Pony.of(client.player);
float corruption = pony.getCorruption().getScaled(0.9F); float corruption = pony.getCorruption().getScaled(0.9F);
if (!MathHelper.approximatelyEquals(corruption, 0)) {
corruption = pony.getInterpolator().interpolate("corruption", corruption, 10); corruption = pony.getInterpolator().interpolate("corruption", corruption, 10);
corruption = 1 - corruption + 0.05F; corruption = 1 - corruption + 0.05F;
@ -96,14 +88,11 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
shader.render(tickDelta); shader.render(tickDelta);
} }
} }
}
@Override @Override
public void reload(ResourceManager var1) { public void reload(ResourceManager var1) {
if (shader != null) { loadShader(shader != null ? shader.id : DESATURATION_SHADER);
loadShader(shader.id);
} else {
loadShader(DESATURATION_SHADER);
}
} }
static class LoadedShader extends PostEffectProcessor { static class LoadedShader extends PostEffectProcessor {