mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 12:52:19 +00:00
More AO Fixes (#578)
* Only use sodium AO for standard blocks and disable flat pipeline optimization * Option for sodium smooth lighting. Currently default to true * Remove tessellator ignore from renderQuadList * Add back cull and sodium lighting check in renderQuadList * Disable sodium AO by default * fix culling --------- Co-authored-by: Caedis <[email protected]>
This commit is contained in:
1 parent
e33f2ff7e3
commit
1315d8971a
5 files changed
+45
-8
No files matched your search
+27
-1
@@ -1,14 +1,40 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(RenderBlocks.class)
|
||||
public abstract class MixinRenderBlocks {
|
||||
|
||||
@Unique
|
||||
private boolean isRenderingByType = false;
|
||||
|
||||
@Inject(method = "renderBlockByRenderType", at = @At("HEAD"))
|
||||
private void renderingByTypeEnable(CallbackInfoReturnable<Boolean> ci) {
|
||||
this.isRenderingByType = true;
|
||||
}
|
||||
|
||||
@Inject(method = "renderBlockByRenderType", at = @At("TAIL"))
|
||||
private void renderingByTypeDisable(CallbackInfoReturnable<Boolean> ci) {
|
||||
this.isRenderingByType = false;
|
||||
}
|
||||
|
||||
@Redirect(method = "renderStandardBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isAmbientOcclusionEnabled()Z"))
|
||||
private boolean checkAOEnabled() {
|
||||
return false;
|
||||
if ((this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && SodiumClientMod.options().quality.useSodiumAO) ||
|
||||
(AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo())) {
|
||||
return false; // Force sodium pipeline with Iris or for standard blocks rendered from renderBlockByRenderType when using AO
|
||||
}
|
||||
|
||||
return Minecraft.isAmbientOcclusionEnabled();
|
||||
}
|
||||
}
|
||||
@@ -204,6 +204,14 @@ public class SodiumGameOptionPages {
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.sodium_smooth_lighting.name"))
|
||||
.setTooltip(I18n.format("sodium.options.sodium_smooth_lighting.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.quality.useSodiumAO = value, opts -> opts.quality.useSodiumAO)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
// TODO
|
||||
/*.add(OptionImpl.createBuilder(int.class, vanillaOpts)
|
||||
.setName(new TranslatableText("options.biomeBlendRadius"))
|
||||
|
||||
@@ -56,6 +56,7 @@ public class SodiumGameOptions {
|
||||
}
|
||||
public static class QualitySettings {
|
||||
public GraphicsQuality grassQuality = GraphicsQuality.DEFAULT;
|
||||
public boolean useSodiumAO = false;
|
||||
}
|
||||
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BlockRenderer {
|
||||
private final QuadLightData cachedQuadLightData = new QuadLightData();
|
||||
|
||||
private final boolean useAmbientOcclusion;
|
||||
private final boolean useSodiumAO;
|
||||
private boolean useSeparateAo;
|
||||
|
||||
private final LightPipelineProvider lighters;
|
||||
@@ -55,11 +56,12 @@ public class BlockRenderer {
|
||||
this.lighters = lighters;
|
||||
// TODO: Sodium - AO Setting
|
||||
this.useAmbientOcclusion = Minecraft.getMinecraft().gameSettings.ambientOcclusion > 0;
|
||||
this.useSodiumAO = SodiumClientMod.options().quality.useSodiumAO;
|
||||
this.occlusionCache = new BlockOcclusionCache();
|
||||
}
|
||||
|
||||
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPosImpl pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
final LightMode mode = this.getLightingMode(block);
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
@@ -102,7 +104,7 @@ public class BlockRenderer {
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, block.getRenderType() == 0);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
@@ -127,13 +129,11 @@ public class BlockRenderer {
|
||||
for (int i = 0, quadsSize = quads.size(); i < quadsSize; i++) {
|
||||
final QuadView quad = quads.get(i);
|
||||
|
||||
// If we aren't using sodium light (i.e. it's the CapturingTesselator)
|
||||
// manually filter quads by side
|
||||
if (!useSodiumLight && quad.getFace() != cullFace)
|
||||
continue;
|
||||
|
||||
final QuadLightData light = this.cachedQuadLightData;
|
||||
|
||||
if (quad.getFace() != cullFace)
|
||||
continue;
|
||||
|
||||
if (useSodiumLight || this.useSeparateAo)
|
||||
lighter.calculate(quad, pos, light, cullFace, quad.getLightFace(), quad.isShade());
|
||||
|
||||
|
||||
Reference in new issue
Block a user