mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-25 14:44:28 +00:00
Let block entities opt out of the glow depth replay
This commit is contained in:
5 files changed
+65
-2
No files matched your search
@@ -0,0 +1,15 @@
|
||||
package com.gtnewhorizons.angelica.api.tesr;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.GlowReplayExclusions;
|
||||
|
||||
/// Under Fancy translucency, block entities drawing glows (blended draws without depth writes) in the translucent
|
||||
/// pass are rendered a second time. Renderers that advance state per call opt out here.
|
||||
public final class TesrGlowDepth {
|
||||
|
||||
private TesrGlowDepth() {}
|
||||
|
||||
/// Excludes block entities of `type`, or rendered by a renderer of `type`, including subclasses.
|
||||
public static void excludeFromReplay(Class<?> type) {
|
||||
GlowReplayExclusions.exclude(type);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/** TESR mesh cache/batch API (Render thread only) */
|
||||
@API(owner = "angelica", provides = "angelica|tesr", apiVersion = "3")
|
||||
@API(owner = "angelica", provides = "angelica|tesr", apiVersion = "4")
|
||||
package com.gtnewhorizons.angelica.api.tesr;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -177,6 +177,11 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static String[] entityShadowReplayExcludedClasses;
|
||||
|
||||
@Config.Comment("Tile entity or renderer classes whose glows Fancy translucency records as they draw instead of rendering the tile entity a second time. For renderers that advance an animation or other state on each render.")
|
||||
@Config.DefaultStringList({})
|
||||
@Config.RequiresMcRestart
|
||||
public static String[] glowDepthReplayExcludedClasses;
|
||||
|
||||
@Config.Comment("Skip the end-of-frame shader buffer copy by ping-ponging buffers. Disable if a shader pack misrenders.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
|
||||
+2
-1
@@ -65,6 +65,7 @@ import com.gtnewhorizons.angelica.rendering.culling.GpuCulling;
|
||||
import com.gtnewhorizons.angelica.render.WeatherRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.culling.GpuTerrainCuller;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.AngelicaTesrMeshCache;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.GlowReplayExclusions;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.ModelPartBatcher;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.PendingTesrDraws;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.SectionBuiltBlockEntity;
|
||||
@@ -754,7 +755,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
final boolean attribute = Tracy.ENABLED && TesrAttribution.currentRenderable == null;
|
||||
if (attribute) TesrAttribution.currentRenderable = tileEntity.getClass();
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_RENDER_TE);
|
||||
DepthEcho.beginTracking();
|
||||
if (DepthEcho.armed() && !GlowReplayExclusions.excludes(tileEntity)) DepthEcho.beginTracking();
|
||||
try {
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks);
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gtnewhorizons.angelica.rendering.tesr;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public final class GlowReplayExclusions {
|
||||
|
||||
private static final ReferenceOpenHashSet<Class<?>> registered = new ReferenceOpenHashSet<>();
|
||||
private static final Reference2ObjectOpenHashMap<Class<?>, Boolean> excluded = new Reference2ObjectOpenHashMap<>();
|
||||
|
||||
private GlowReplayExclusions() {}
|
||||
|
||||
public static void exclude(Class<?> type) {
|
||||
if (registered.add(type)) excluded.clear();
|
||||
}
|
||||
|
||||
public static boolean excludes(TileEntity tileEntity) {
|
||||
final Class<? extends TileEntity> type = tileEntity.getClass();
|
||||
Boolean result = excluded.get(type);
|
||||
if (result == null) {
|
||||
final TileEntitySpecialRenderer renderer = TileEntityRendererDispatcher.instance.getSpecialRendererByClass(type);
|
||||
result = matches(type) || renderer != null && matches(renderer.getClass());
|
||||
excluded.put(type, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean matches(Class<?> type) {
|
||||
final String[] names = AngelicaConfig.glowDepthReplayExcludedClasses;
|
||||
for (Class<?> c = type; c != null && c != Object.class; c = c.getSuperclass()) {
|
||||
if (registered.contains(c)) return true;
|
||||
if (names != null) for (String name : names) {
|
||||
if (c.getName().equals(name)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user