Compare commits

..
Author SHA1 Message Date
Connor Colenso 2a8004b3c1 Add a particle API for mods that size or draw particles themselves
A render scale per particle for the ones the instancer batches straight from their fields, and the pack's
particle program for particles drawn outside the effect renderer. Any number of mods can add a scale source,
the factors multiply.
2026-11-23 23:06:24 +00:00
Connor Colenso ad4e5cfff8 Add shadow casters so mod geometry can draw into the shadow map
Casters run in the shadow pass with the solid shadows and again after translucent terrain, so geometry drawn
from a TESR or the world draw stage can shadow like terrain. They can also ask whether the pack shadows block
entities, so a caster drawing its own block entities can leave them out when the real ones aren't in it.
2026-11-23 23:06:24 +00:00
Connor Colenso a0a2b603e1 Add a world draw stage for mod geometry inside the world pass
RenderWorldLastEvent comes after the pack's composite passes, so anything drawn there misses its lighting,
fog and shadows. Drawers registered here run right after block entities, once per Forge pass. Hooked into
renderBlockEntitiesInPhase so it also runs when pass 1 block entities go before translucent terrain.
2026-11-23 23:06:24 +00:00
Connor Colenso 8c770cb42c Add a terrain API for mods that bake blocks outside the chunk mesher
TerrainRendering lets geometry drawn outside the chunk renderer (moving structures, previews) use the
pack's terrain programs, materials, layer overrides and AO and shading settings, and bake the same way the
mesher does. TerrainLighter runs the mesher's smooth and flat light pipelines over any block access.
Vanilla AO can be turned off per thread while baking.
2026-11-23 23:06:24 +00:00
28 changed files with 611 additions and 345 deletions

No files matched your search

+1 -3
View File
@@ -17,7 +17,7 @@
* HUD caching * HUD caching
* Custom fonts and text effects * Custom fonts and text effects
* MCPatcher - connected textures, custom item textures, custom colors, random mobs, better skies * MCPatcher - connected textures, custom item textures, custom colors, random mobs, better skies
* Bundled NotFine, zoom, FPS reducer, menu blur * Bundled NotFine, zoom, FPS reducer
## Status ## Status
* OpenGL + Celeritas terrain - Default * OpenGL + Celeritas terrain - Default
@@ -129,7 +129,5 @@ Targets GL 3.3+ core profile
* FFP vertex shader generation inspired by ffvertex_prog.c (Copyright 2007 VMware, Inc.) * FFP vertex shader generation inspired by ffvertex_prog.c (Copyright 2007 VMware, Inc.)
* FFP fragment shader generation inspired by ff_fragment_shader.c (Copyright 2007, 2009 VMware, Inc. / 2010-2011 Intel Corporation) * FFP fragment shader generation inspired by ff_fragment_shader.c (Copyright 2007, 2009 VMware, Inc. / 2010-2011 Intel Corporation)
* Fog parameter optimization inspired by st_nir_lower_fog.c (Copyright 2023 Google LLC) and prog_statevars.c (Copyright 1999-2007 Brian Paul) * Fog parameter optimization inspired by st_nir_lower_fog.c (Copyright 2023 Google LLC) and prog_statevars.c (Copyright 1999-2007 Brian Paul)
* Blur
* tterrag for [Blur](https://github.com/tterrag1098/Blur) - Menu blur based on Blur under the MIT license
* RGSS Terrain Texture Filtering * RGSS Terrain Texture Filtering
* Indiesoft for [defold-sharp-sprite](https://github.com/indiesoftby/defold-sharp-sprite), used as the reference implementation under the MIT license * Indiesoft for [defold-sharp-sprite](https://github.com/indiesoftby/defold-sharp-sprite), used as the reference implementation under the MIT license
@@ -0,0 +1,70 @@
package com.gtnewhorizons.angelica.api.particles;
import net.coderbot.iris.layer.GbufferPrograms;
import net.minecraft.client.particle.EntityFX;
import java.util.Arrays;
/** Particle size and shader hooks for mods that scale or draw their own particles */
public final class ParticleRendering {
private ParticleRendering() {}
/** Size factor for a particle, 1 for unchanged */
@FunctionalInterface
public interface RenderScale {
float of(EntityFX fx);
}
private static final RenderScale[] NO_SCALES = new RenderScale[0];
// Copy on write so the per particle read is one volatile load
private static volatile RenderScale[] renderScales = NO_SCALES;
/**
* Scales particles the instancer batches from their fields, without calling {@code renderParticle}. Particles that
* go through {@code renderParticle} need scaling there instead. Every source sees every batched particle and the
* factors multiply, so return 1 for particles that aren't yours.
*/
public static synchronized void addRenderScale(RenderScale source) {
for (RenderScale existing : renderScales) {
if (existing == source) return;
}
final RenderScale[] next = Arrays.copyOf(renderScales, renderScales.length + 1);
next[next.length - 1] = source;
renderScales = next;
}
public static synchronized void removeRenderScale(RenderScale source) {
final RenderScale[] old = renderScales;
for (int i = 0; i < old.length; i++) {
if (old[i] != source) continue;
final RenderScale[] next = new RenderScale[old.length - 1];
System.arraycopy(old, 0, next, 0, i);
System.arraycopy(old, i + 1, next, i, old.length - i - 1);
renderScales = next.length == 0 ? NO_SCALES : next;
return;
}
}
/** Product of every {@link #addRenderScale} source for this particle */
public static float renderScale(EntityFX fx) {
final RenderScale[] sources = renderScales;
if (sources.length == 0) return 1;
float scale = 1;
for (RenderScale source : sources) scale *= source.of(fx);
return scale;
}
/**
* Binds the pack's particle program for particles drawn outside the effect renderer. Nests, pass the token to
* {@link #endParticleDraw}. No-op without a shaderpack.
*/
public static int beginParticleDraw() {
return GbufferPrograms.beginParticles();
}
public static void endParticleDraw(int token) {
GbufferPrograms.endParticles(token);
}
}
@@ -0,0 +1,4 @@
@API(owner = "angelica", provides = "angelica|particles", apiVersion = "1")
package com.gtnewhorizons.angelica.api.particles;
import cpw.mods.fml.common.API;
@@ -0,0 +1,18 @@
package com.gtnewhorizons.angelica.api.shadows;
/**
* Draws extra geometry into the shaderpack shadow map. {@code RenderWorldLastEvent} geometry never reaches it, and TESRs
* only do when the pack shadows block entities. Register with {@link ShadowCasters#register}.
*/
@FunctionalInterface
public interface ShadowCaster {
/**
* Called once per shadow pass per stage, with the shadow modelview loaded and the block entity shadow program bound.
* Positions are camera relative. Restore any GL state you change.
*
* @param stage {@link ShadowStage#SOLID} with the other solid shadows, {@link ShadowStage#TRANSLUCENT} after
* translucent terrain for geometry that should tint light rather than block it
*/
void renderShadow(ShadowStage stage, double cameraX, double cameraY, double cameraZ, float partialTicks);
}
@@ -0,0 +1,57 @@
package com.gtnewhorizons.angelica.api.shadows;
import com.gtnewhorizons.angelica.AngelicaMod;
import net.coderbot.iris.pipeline.ShadowRenderer;
import java.util.concurrent.CopyOnWriteArrayList;
/** {@link ShadowCaster} registry. Render thread only. */
public final class ShadowCasters {
private static final CopyOnWriteArrayList<ShadowCaster> CASTERS = new CopyOnWriteArrayList<>();
private ShadowCasters() {}
public static void register(ShadowCaster caster) {
CASTERS.addIfAbsent(caster);
}
public static void unregister(ShadowCaster caster) {
CASTERS.remove(caster);
}
/** True while the shaderpack shadow pass is drawing */
public static boolean isRenderingShadows() {
return ShadowRenderer.ACTIVE;
}
/**
* The pack's {@code shadowBlockEntities}. A caster drawing its own block entities should skip them when this is
* false. Only valid during the shadow pass.
*/
public static boolean shadowsBlockEntities() {
return ShadowRenderer.BLOCK_ENTITIES;
}
/** True when the shadow pass draws light emitting block entities, even with {@link #shadowsBlockEntities} off */
public static boolean shadowsLightBlockEntities() {
return ShadowRenderer.LIGHT_BLOCK_ENTITIES;
}
public static boolean hasCasters() {
return !CASTERS.isEmpty();
}
/** Called by the shadow renderer. A caster that throws is removed. */
public static void renderAll(ShadowStage stage, double cameraX, double cameraY, double cameraZ,
float partialTicks) {
for (ShadowCaster caster : CASTERS) {
try {
caster.renderShadow(stage, cameraX, cameraY, cameraZ, partialTicks);
} catch (Throwable t) {
AngelicaMod.LOGGER.error("Shadow caster {} threw, removing it", caster, t);
CASTERS.remove(caster);
}
}
}
}
@@ -0,0 +1,8 @@
package com.gtnewhorizons.angelica.api.shadows;
public enum ShadowStage {
/** After the shadow pass's entities and block entities */
SOLID,
/** After translucent terrain, only when the pack draws translucent shadows */
TRANSLUCENT
}
@@ -0,0 +1,4 @@
@API(owner = "angelica", provides = "angelica|shadows", apiVersion = "1")
package com.gtnewhorizons.angelica.api.shadows;
import cpw.mods.fml.common.API;
@@ -0,0 +1,105 @@
package com.gtnewhorizons.angelica.api.terrain;
import com.gtnewhorizons.angelica.rendering.celeritas.VertexArrayQuadView;
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
import com.gtnewhorizons.angelica.rendering.celeritas.light.VanillaDiffuseProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.world.IBlockAccess;
import org.embeddedt.embeddium.impl.model.light.LightPipeline;
import org.embeddedt.embeddium.impl.model.light.data.LightDataAccess;
import org.embeddedt.embeddium.impl.model.light.data.QuadLightData;
import org.embeddedt.embeddium.impl.model.light.flat.FlatLightPipeline;
import org.embeddedt.embeddium.impl.model.light.smooth.SmoothLightPipeline;
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFlags;
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
import org.embeddedt.embeddium.impl.util.QuadUtil;
/**
* Per vertex AO and lightmap for block quads, using the chunk mesher's light pipelines over any block access.
* <p>
* Not thread safe, use one per thread. Light data is cached per 16 block region and doesn't see world changes, so call
* {@link #reset} before each bake.
*/
public final class TerrainLighter {
private final LightDataCache cache = new LightDataCache();
private final SmoothLightPipeline smooth;
private final FlatLightPipeline flat;
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
private final VertexArrayQuadView quad = new VertexArrayQuadView(vertices);
private final QuadLightData out = new QuadLightData();
private int regionX = Integer.MIN_VALUE, regionY, regionZ;
// Last fluid quad, to detect the flipped back face vanilla emits right after it
private ModelQuadFacing fluidLightFace;
private final float[] fluidXyz = new float[12];
private static final int[] REVERSED = { 0, 3, 2, 1 };
public TerrainLighter(IBlockAccess world) {
cache.setWorld(world);
smooth = new SmoothLightPipeline(cache, VanillaDiffuseProvider.INSTANCE, true);
flat = new FlatLightPipeline(cache, VanillaDiffuseProvider.INSTANCE, true);
}
/** Drops cached light data */
public void reset() {
regionX = Integer.MIN_VALUE;
fluidLightFace = null;
}
/**
* Lights one quad of the block at x, y, z.
*
* @param xyz corners as x y z in vertex order, in the block access's coordinates
* @param shade multiply in directional face shading, false for AO only
* @param fluid the block is a fluid (see {@link TerrainRendering#isFluid}). Pass its quads in emit order. The
* mesher gives fluids no AO, so only use the light
* @param brightness out, per vertex AO (times shading if requested), 0 to 1
* @param light out, per vertex lightmap, {@code sky << 16 | block}, each 0-240
*/
public void light(float[] xyz, int x, int y, int z, boolean shade, boolean fluid, float[] brightness,
int[] light) {
final int rx = x & ~15, ry = y & ~15, rz = z & ~15;
if (rx != regionX || ry != regionY || rz != regionZ) {
regionX = rx;
regionY = ry;
regionZ = rz;
cache.reset(rx, ry, rz);
}
smooth.reset();
flat.reset();
for (int i = 0; i < 4; i++) {
vertices[i].x = xyz[i * 3];
vertices[i].y = xyz[i * 3 + 1];
vertices[i].z = xyz[i * 3 + 2];
}
// The mesher lights a fluid's flipped back face from the front face's side
final boolean flippedCopy = fluid && fluidLightFace != null && isReversedFluidQuad(xyz);
quad.setup(QuadUtil.calculateNormal(vertices), x, y, z, fluid ? ModelQuadFlags.IS_VANILLA_SHADED : 0,
flippedCopy ? fluidLightFace : null);
// Same rule as the mesher: smooth lighting on and the block isn't a light source
final boolean smoothLighting = Minecraft.getMinecraft().gameSettings.ambientOcclusion != 0
&& LightDataAccess.unpackLU(cache.get(x, y, z)) == 0;
final LightPipeline pipeline = smoothLighting ? smooth : flat;
pipeline.calculate(quad, x, y, z, out, quad.getCullFace(), quad.getLightFace(), shade, true);
System.arraycopy(out.br, 0, brightness, 0, 4);
System.arraycopy(out.lm, 0, light, 0, 4);
if (fluid && !flippedCopy) {
fluidLightFace = quad.getLightFace();
System.arraycopy(xyz, 0, fluidXyz, 0, 12);
} else if (!fluid) {
fluidLightFace = null;
}
}
private boolean isReversedFluidQuad(float[] xyz) {
for (int i = 0; i < 4; i++) {
final int src = REVERSED[i] * 3;
if (xyz[i * 3] != fluidXyz[src] || xyz[i * 3 + 1] != fluidXyz[src + 1]
|| xyz[i * 3 + 2] != fluidXyz[src + 2]) {
return false;
}
}
return true;
}
}
@@ -0,0 +1,230 @@
package com.gtnewhorizons.angelica.api.terrain;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.api.shaders.ShaderPacks;
import com.gtnewhorizons.angelica.glsm.ffp.FfpExtendedAttribs;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.BlockMaterialAttribute;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
import com.prupe.mcpatcher.mal.block.RenderBlocksUtils;
import me.jellysquid.mods.sodium.client.gui.options.named.MipmapGeneration;
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.gl.shader.ProgramCreator;
import net.coderbot.iris.layer.GbufferPrograms;
import net.coderbot.iris.pipeline.WorldRenderingPhase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockDynamicLiquid;
import net.minecraft.block.BlockStaticLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.IBlockAccess;
import org.embeddedt.embeddium.impl.render.chunk.terrain.material.parameters.AlphaCutoffParameter;
import java.util.Map;
/**
* For mods that bake block geometry outside the chunk renderer and want it to match terrain, including under a
* shaderpack (terrain programs, block.properties materials, the pack's AO and directional shading).
* <p>
* Begin/end pairs nest and are render thread only. Call the end in a finally block.
*/
public final class TerrainRendering {
private static int terrainDrawDepth;
private static boolean terrainDrawPushed;
private TerrainRendering() {}
/**
* Uses the pack's terrain program until {@link #endTerrainDraw} instead of the current phase's. The outermost call
* picks the program. No-op without a shaderpack.
*
* @param translucent true for render pass 1, false for solid and cutout
*/
public static void beginTerrainDraw(boolean translucent) {
if (terrainDrawDepth++ > 0) return;
terrainDrawPushed = ShaderPacks.isInUse();
if (terrainDrawPushed) {
GbufferPrograms.pushOverridePhase(translucent ? WorldRenderingPhase.TERRAIN_TRANSLUCENT : WorldRenderingPhase.TERRAIN_CUTOUT);
}
}
public static void endTerrainDraw() {
if (terrainDrawDepth == 0) return;
if (--terrainDrawDepth > 0) return;
if (terrainDrawPushed) GbufferPrograms.popOverridePhase();
terrainDrawPushed = false;
}
/** Called at the start of each frame. Closes a terrain draw that was never ended. */
public static void resetForFrame() {
if (terrainDrawDepth == 0) return;
AngelicaMod.LOGGER.warn("A terrain draw was never ended, ending it");
if (terrainDrawPushed) GbufferPrograms.popOverridePhase();
terrainDrawPushed = false;
terrainDrawDepth = 0;
}
/** True when the pack wants AO in vertex color alpha instead of multiplied into the color */
public static boolean usesSeparateAo() {
return ShaderPacks.isInUse() && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
}
/**
* True when the chunk mesher relights terrain with the pipeline {@link TerrainLighter} uses. Only faces marked by
* {@link #isSmoothLit} (and fluids under a pack) are relit, the rest keep their baked light.
*/
public static boolean usesTerrainLighting() {
return ShaderPacks.isInUse() || BlockRenderingSettings.INSTANCE.shouldUseSeparateAo()
|| ClientProxy.options().quality.useCeleritasSmoothLighting;
}
/**
* Alpha cutoff terrain uses for a render pass without a shaderpack. Pass 0 is 0.5 (vanilla uses 0.1), pass 1
* follows the mipmap setting.
*/
public static float getAlphaCutoff(int pass) {
return pass == 0 ? AlphaCutoffParameter.HALF.cutoff() : MipmapGeneration.alphaFloorCutoff().cutoff();
}
/** True when the pack does its own directional shading, so terrain is baked without vanilla's face shading */
public static boolean disablesDirectionalShading() {
return ShaderPacks.isInUse() && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
}
/**
* Forge render pass the pack moves this block to (e.g. {@code layer.translucent}), -1 if not moved or no pack. The
* mesher only draws a moved block in that pass.
*/
public static int getRenderPassOverride(Block block) {
if (!ShaderPacks.isInUse()) return -1;
final Map<Block, BlockRenderLayer> overrides = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
if (overrides == null) return -1;
final BlockRenderLayer layer = overrides.get(block);
return layer == null ? -1 : layer.toVanillaPass();
}
/** The pack's block.properties id, -1 if unmapped or no pack */
public static int getBlockMaterialId(Block block, int metadata) {
return ShaderPacks.isInUse() ? BlockMaterialAttribute.blockMaterialId(block, metadata) : -1;
}
/**
* The block.properties id the mesher gives this block at this position. Unlike the plain lookup it falls back to a
* fluid's still or flowing twin, applies snowy entries and resolves double plant tops. -1 if unmapped or no pack.
*/
public static int getBlockMaterialId(IBlockAccess world, Block block, int metadata, int x, int y, int z) {
if (!ShaderPacks.isInUse()) return -1;
if (isFluid(block)) {
int id = BlockMaterialAttribute.blockMaterialId(block, metadata);
if (id == -1) {
Block twin = null;
if (block instanceof BlockStaticLiquid) twin = Block.getBlockById(Block.getIdFromBlock(block) - 1);
else if (block instanceof BlockDynamicLiquid) twin = Block.getBlockById(Block.getIdFromBlock(block) + 1);
if (twin != null) id = BlockMaterialAttribute.blockMaterialId(twin, metadata);
}
return id;
}
int effectiveMeta = metadata;
if (BlockRenderingSettings.INSTANCE.hasSnowyEntries()
&& BlockRenderingSettings.INSTANCE.getSnowyBlocks().contains(block)
&& RenderBlocksUtils.isSnowCovered(world, x, y, z)) {
effectiveMeta |= BlockMaterialMapping.SNOWY_META_BIT;
} else if (block instanceof BlockDoublePlant doublePlant && BlockDoublePlant.func_149887_c(metadata)) {
effectiveMeta = 0x8 | (doublePlant.func_149885_e(world, x, y, z) & 7);
}
return BlockMaterialAttribute.blockMaterialId(block, effectiveMeta);
}
/** Water or lava material, what the mesher treats as a fluid for lighting and material ids */
public static boolean isFluid(Block block) {
final Material material = block.getMaterial();
return material == Material.water || material == Material.lava;
}
/**
* Makes RenderBlocks draw into this tessellator like it does for the chunk mesher. Blocks that would take vanilla's
* smooth lighting path are drawn flat and marked (see {@link #isSmoothLit}) so they can be relit with
* {@link TerrainLighter}. Only applies when {@link #usesTerrainLighting} would. Turn it off in a finally block.
*/
public static void setMeshing(Tessellator tessellator, boolean meshing) {
((StateAwareTessellator) tessellator).angelica$setCeleritasMeshing(meshing);
}
/** True while the vertices being added are from a face the mesher would relight (see {@link #setMeshing}) */
public static boolean isSmoothLit(Tessellator tessellator) {
return ((StateAwareTessellator) tessellator).angelica$isAppliedAo();
}
/** True while the vertices being added should get no directional shading */
public static boolean hasNoDirectionalShading(Tessellator tessellator) {
return ((StateAwareTessellator) tessellator).angelica$isNoDirectionalShading();
}
/**
* Attribute location of mc_Entity. Two shorts per vertex, the material id and 0 (1 for fluids). Only bind it while a
* shaderpack is in use.
*/
public static int getMaterialAttributeLocation() {
return ProgramCreator.MC_ENTITY;
}
/**
* Attribute location of mc_midTexCoord, the centre of the vertex's sprite. Two floats per vertex. Only bind it while
* a shaderpack is in use, between {@link #beginOwnExtendedAttributes} and {@link #endOwnExtendedAttributes}.
*/
public static int getMidTexCoordAttributeLocation() {
return ProgramCreator.MC_MID_TEX_COORD;
}
/** Attribute location of at_tangent, four floats per vertex (w is handedness). Same rules as mc_midTexCoord. */
public static int getTangentAttributeLocation() {
return ProgramCreator.AT_TANGENT;
}
/**
* Stops Angelica generating mc_midTexCoord and at_tangent for draws until {@link #endOwnExtendedAttributes}, for
* draws that supply their own.
*/
public static void beginOwnExtendedAttributes() {
FfpExtendedAttribs.beginInternalDraw();
}
public static void endOwnExtendedAttributes() {
FfpExtendedAttribs.endInternalDraw();
}
/**
* Records the sprites used on this thread until closed. Angelica only animates sprites drawn this frame, so call
* {@link SpriteCapture#markUsed} each frame the baked geometry is drawn. Close on the same thread.
*/
public static SpriteCapture captureSprites() {
return new SpriteCapture(AnimationsRenderUtils.captureSprites());
}
/** See {@link #captureSprites}. */
public static final class SpriteCapture implements AutoCloseable {
private final AnimationsRenderUtils.SpriteCapture capture;
private SpriteCapture(AnimationsRenderUtils.SpriteCapture capture) {
this.capture = capture;
}
/** Marks the recorded sprites as drawn this frame */
public void markUsed() {
capture.markUsed();
}
/** Stops recording, keeping what was recorded */
@Override
public void close() {
capture.close();
}
}
}
@@ -0,0 +1,4 @@
@API(owner = "angelica", provides = "angelica|terrain", apiVersion = "1")
package com.gtnewhorizons.angelica.api.terrain;
import cpw.mods.fml.common.API;
@@ -0,0 +1,50 @@
package com.gtnewhorizons.angelica.api.world;
import com.gtnewhorizons.angelica.AngelicaMod;
import net.minecraftforge.client.MinecraftForgeClient;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* Draw hook inside the world pass for mod geometry. {@code RenderWorldLastEvent} fires after the pack's composite and
* final passes, so geometry drawn there gets none of its lighting, fog or shadows.
* <p>
* Drawers run right after block entities, once per Forge render pass, with the block entity program bound like a TESR.
* The modelview is the camera's, so draw relative to {@code TileEntityRendererDispatcher.staticPlayerX/Y/Z}. Restore any
* GL state you change. Render thread only.
*/
public final class WorldDrawStage {
@FunctionalInterface
public interface Drawer {
/** @param pass Forge render pass, 0 for solid and cutout, 1 for translucent */
void draw(int pass, float partialTicks);
}
private static final CopyOnWriteArrayList<Drawer> drawers = new CopyOnWriteArrayList<>();
private WorldDrawStage() {}
public static void register(Drawer drawer) {
drawers.addIfAbsent(drawer);
}
public static void unregister(Drawer drawer) {
drawers.remove(drawer);
}
/** Called by the world renderer after block entities. A drawer that throws is removed. */
public static void run(float partialTicks) {
if (drawers.isEmpty()) return;
final int pass = MinecraftForgeClient.getRenderPass();
for (Drawer drawer : drawers) {
try {
drawer.draw(pass, partialTicks);
} catch (Throwable t) {
drawers.remove(drawer);
AngelicaMod.LOGGER.error("World drawer {} threw, removing it", drawer, t);
}
}
}
}
@@ -0,0 +1,4 @@
@API(owner = "angelica", provides = "angelica|world", apiVersion = "1")
package com.gtnewhorizons.angelica.api.world;
import cpw.mods.fml.common.API;
@@ -1,25 +0,0 @@
The menu blur in this package is based on [Blur](https://github.com/tterrag1098/Blur), used under the following license:
```
MIT License
Copyright (c) 2017 tterrag
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
@@ -1,204 +0,0 @@
package com.gtnewhorizons.angelica.blur;
import com.gtnewhorizons.angelica.client.rendering.GlUniformFloat2v;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.GLSMAttribStack;
import com.gtnewhorizons.angelica.glsm.GLSMBlend;
import com.gtnewhorizons.angelica.glsm.GLSMDepthStencilAlpha;
import com.gtnewhorizons.angelica.glsm.GLSMDraws;
import com.gtnewhorizons.angelica.glsm.GLSMFramebuffer;
import com.gtnewhorizons.angelica.glsm.GLSMPrograms;
import com.gtnewhorizons.angelica.glsm.GLSMQueries;
import com.gtnewhorizons.angelica.glsm.GLSMRasterizer;
import com.gtnewhorizons.angelica.glsm.GLSMTextures;
import com.gtnewhorizons.angelica.glsm.GLSMVertexInput;
import com.gtnewhorizons.angelica.glsm.StateSet;
import com.gtnewhorizons.angelica.render.PanoramaRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.shader.Framebuffer;
import org.apache.commons.lang3.ArrayUtils;
import org.embeddedt.embeddium.impl.gl.shader.GlProgram;
import org.embeddedt.embeddium.impl.gl.shader.ShaderBindingContext;
import org.embeddedt.embeddium.impl.gl.shader.uniform.GlUniformFloat;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL30;
import java.nio.ByteBuffer;
/**
* Blurs the world behind open GUIs and fades in a configurable background gradient.
* Based on Blur by tterrag (https://github.com/tterrag1098/Blur) under the MIT license, see LICENSE-Blur.md.
* Reimplemented on top of Angelica's own blur shader instead of a vanilla post-processing shader.
*/
public class MenuBlur {
private static final Minecraft mc = Minecraft.getMinecraft();
private static GlProgram<BlurUniforms> blurProgram;
private static StateSet allState;
private static int emptyVao;
// The blur runs on half resolution copies of the screen, which is much cheaper and looks the same once blurred
private static int horizontalFbo, horizontalTexture, verticalFbo, verticalTexture;
private static int sourceWidth, sourceHeight, halfWidth, halfHeight;
private static boolean blurring;
private static long fadeStartMillis;
/** Called right after the world has been drawn, before the HUD and the open GUI. */
public static void renderBlur() {
final boolean shouldBlur = shouldBlur();
if (shouldBlur && !blurring) {
fadeStartMillis = System.currentTimeMillis();
}
blurring = shouldBlur;
if (!blurring) return;
// The radius grows with the fade, so the blur gets stronger over the first moments
final float radius = (float) Math.floor(AngelicaConfig.menuBlurRadius * getProgress());
if (radius < 1.0F) return;
final Framebuffer mainFramebuffer = mc.getFramebuffer();
if (blurProgram == null) init();
final int previousProgram = GLSMPrograms.getActiveProgram();
final int previousVao = GLSMQueries.glGetInteger(GL30.GL_VERTEX_ARRAY_BINDING);
final int previousFilter = mainFramebuffer.framebufferFilter;
final int stateDepth = GLSMAttribStack.pushState(allState);
try {
ensureBlurTargets(mainFramebuffer.framebufferWidth, mainFramebuffer.framebufferHeight);
GLSMBlend.disableBlend();
GLSMDepthStencilAlpha.disableDepthTest();
GLSMDepthStencilAlpha.glDepthMask(false);
GLSMBlend.glColorMask(true, true, true, true);
GLSMRasterizer.disableCull();
GLSMRasterizer.disableScissorTest();
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0);
blurProgram.bind();
GLSMVertexInput.glBindVertexArray(emptyVao);
final BlurUniforms uniforms = blurProgram.getInterface();
// Each half resolution pixel covers two screen pixels, so half the radius gives the same strength
uniforms.radius.setFloat(radius * 0.5F);
// Horizontal pass, shrinking the screen to half size. Linear filtering makes every
// half size pixel average the four screen pixels it covers instead of picking one.
mainFramebuffer.setFramebufferFilter(GL11.GL_LINEAR);
GLSMFramebuffer.glBindFramebuffer(GL30.GL_FRAMEBUFFER, horizontalFbo);
GLSMRasterizer.glViewport(0, 0, halfWidth, halfHeight);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, mainFramebuffer.framebufferTexture);
uniforms.direction.set(1.0F / halfWidth, 0.0F);
GLSMDraws.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
// Vertical pass, still at half size
GLSMFramebuffer.glBindFramebuffer(GL30.GL_FRAMEBUFFER, verticalFbo);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, horizontalTexture);
uniforms.direction.set(0.0F, 1.0F / halfHeight);
GLSMDraws.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
// Stretch the result back over the screen. A radius of 0 makes the blur shader a plain copy.
mainFramebuffer.bindFramebuffer(true);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, verticalTexture);
uniforms.radius.setFloat(0.0F);
GLSMDraws.glDrawArrays(GL11.GL_TRIANGLES, 0, 3);
} finally {
mainFramebuffer.setFramebufferFilter(previousFilter);
GLSMVertexInput.glBindVertexArray(previousVao);
GLSMPrograms.glUseProgram(previousProgram);
GLSMAttribStack.popStateTo(stateDepth);
mainFramebuffer.bindFramebuffer(true);
}
}
/** Replaces one of the two vanilla GUI background gradient colors while the blur is showing. */
public static int getBackgroundColor(int vanillaColor, String configuredColor) {
if (!blurring) return vanillaColor;
final int color;
try {
color = Integer.parseUnsignedInt(configuredColor, 16);
} catch (NumberFormatException e) {
return vanillaColor;
}
final float progress = getProgress();
final int alpha = (int) ((color >>> 24) * progress);
final int red = (int) ((color >> 16 & 0xFF) * progress);
final int green = (int) ((color >> 8 & 0xFF) * progress);
final int blue = (int) ((color & 0xFF) * progress);
return alpha << 24 | red << 16 | green << 8 | blue;
}
private static boolean shouldBlur() {
return AngelicaConfig.enableMenuBlur
&& mc.theWorld != null
&& mc.currentScreen != null
&& !ArrayUtils.contains(AngelicaConfig.menuBlurExcludedGuis, mc.currentScreen.getClass().getName());
}
private static float getProgress() {
if (AngelicaConfig.menuBlurFadeTime <= 0) return 1.0F;
return Math.min((System.currentTimeMillis() - fadeStartMillis) / (float) AngelicaConfig.menuBlurFadeTime, 1.0F);
}
private static void init() {
blurProgram = PanoramaRenderer.loadProgram("angelica:menu_blur", "angelica:panorama_blur", "angelica:panorama_blur", BlurUniforms::new);
allState = StateSet.forMask(GL11.GL_ALL_ATTRIB_BITS);
emptyVao = GLSMVertexInput.glGenVertexArrays();
}
private static void ensureBlurTargets(int width, int height) {
if (horizontalFbo != 0 && width == sourceWidth && height == sourceHeight) return;
if (horizontalFbo != 0) {
GLSMFramebuffer.glDeleteFramebuffers(horizontalFbo);
GLSMFramebuffer.glDeleteFramebuffers(verticalFbo);
GLSMTextures.glDeleteTextures(horizontalTexture);
GLSMTextures.glDeleteTextures(verticalTexture);
}
sourceWidth = width;
sourceHeight = height;
halfWidth = Math.max((width + 1) / 2, 1);
halfHeight = Math.max((height + 1) / 2, 1);
horizontalTexture = createTexture(halfWidth, halfHeight);
horizontalFbo = createFramebuffer(horizontalTexture);
verticalTexture = createTexture(halfWidth, halfHeight);
verticalFbo = createFramebuffer(verticalTexture);
}
private static int createTexture(int width, int height) {
final int texture = GLSMTextures.glGenTextures();
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, texture);
GLSMTextures.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GLSMTextures.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
GLSMTextures.glBindTexture(GL11.GL_TEXTURE_2D, 0);
return texture;
}
private static int createFramebuffer(int colorTexture) {
final int fbo = GLSMFramebuffer.glGenFramebuffers();
GLSMFramebuffer.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo);
GLSMFramebuffer.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexture, 0);
final int status = GLSMFramebuffer.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER);
if (status != GL30.GL_FRAMEBUFFER_COMPLETE) {
throw new RuntimeException("Menu blur FBO incomplete: 0x" + Integer.toHexString(status));
}
return fbo;
}
private static class BlurUniforms {
final GlUniformFloat2v direction;
final GlUniformFloat radius;
BlurUniforms(ShaderBindingContext ctx) {
direction = ctx.bindUniform("u_Direction", GlUniformFloat2v::new);
radius = ctx.bindUniform("u_Radius", GlUniformFloat::new);
}
}
}
@@ -296,32 +296,6 @@ public class AngelicaConfig {
@Config.RequiresMcRestart @Config.RequiresMcRestart
public static boolean enableZoom; public static boolean enableZoom;
@Config.Comment("Blur the world behind open GUIs.")
@Config.DefaultBoolean(false)
public static boolean enableMenuBlur;
@Config.Comment("How strong the menu blur is, in pixels.")
@Config.DefaultInt(12)
@Config.RangeInt(min = 1, max = 100)
public static int menuBlurRadius;
@Config.Comment("How long the menu blur takes to fade in, in milliseconds.")
@Config.DefaultInt(200)
@Config.RangeInt(min = 0, max = 2000)
public static int menuBlurFadeTime;
@Config.Comment("GUI classes that never get the menu blur.")
@Config.DefaultStringList({"net.minecraft.client.gui.GuiChat", "net.coderbot.iris.gui.screen.ShaderPackScreen"})
public static String[] menuBlurExcludedGuis;
@Config.Comment("Top color of the GUI background gradient while the menu blur is showing, as ARGB hex.")
@Config.DefaultString("75000000")
public static String menuBlurGradientTopColor;
@Config.Comment("Bottom color of the GUI background gradient while the menu blur is showing, as ARGB hex.")
@Config.DefaultString("75000000")
public static String menuBlurGradientBottomColor;
@Config.Comment("Optimizes in-world item rendering") @Config.Comment("Optimizes in-world item rendering")
@Config.DefaultBoolean(true) @Config.DefaultBoolean(true)
@Config.RequiresMcRestart @Config.RequiresMcRestart
@@ -676,14 +676,6 @@ public enum Mixins implements IMixins {
"angelica.zoom.MixinMouseFilter" "angelica.zoom.MixinMouseFilter"
)), )),
ANGELICA_MENU_BLUR(new MixinBuilder("Blur the world behind open GUIs")
.setPhase(Phase.EARLY)
.addExcludedMod(TargetedMod.BLUR)
.addClientMixins(
"angelica.blur.MixinEntityRenderer_MenuBlur",
"angelica.blur.MixinGuiScreen_MenuBlur"
)),
ANGELICA_FPS_REDUCER(new MixinBuilder("Reduce frame rate and volume while unfocused, minimized, or idle") ANGELICA_FPS_REDUCER(new MixinBuilder("Reduce frame rate and volume while unfocused, minimized, or idle")
.setPhase(Phase.EARLY) .setPhase(Phase.EARLY)
.addClientMixins( .addClientMixins(
@@ -9,7 +9,6 @@ public enum TargetedMod implements ITargetMod {
ARCHAICFIX("org.embeddedt.archaicfix.ArchaicCore", "archaicfix"), ARCHAICFIX("org.embeddedt.archaicfix.ArchaicCore", "archaicfix"),
BACKHAND("xonin.backhand.coremod.BackhandLoadingPlugin", "backhand"), BACKHAND("xonin.backhand.coremod.BackhandLoadingPlugin", "backhand"),
BLUR("com.tterrag.blur.BlurPlugin", "blur"),
BOTANIA(null, "Botania"), BOTANIA(null, "Botania"),
CAMPFIRE_BACKPORT(null, "campfirebackport"), CAMPFIRE_BACKPORT(null, "campfirebackport"),
CHISEL(null, "chisel"), CHISEL(null, "chisel"),
@@ -15,6 +15,15 @@ public interface StateAwareTessellator {
void angelica$setAppliedAo(boolean flag); void angelica$setAppliedAo(boolean flag);
void angelica$setNoDirectionalShading(boolean flag); void angelica$setNoDirectionalShading(boolean flag);
/// The state the next vertex gets. False for tessellators that don't track it.
default boolean angelica$isAppliedAo() {
return false;
}
default boolean angelica$isNoDirectionalShading() {
return false;
}
/// Sets whether we're doing terrain meshing as part of celeritas -- collects additional information. /// Sets whether we're doing terrain meshing as part of celeritas -- collects additional information.
/// ///
/// Enables per-vertex AO state collection into [#angelica$getVertexStates()]. /// Enables per-vertex AO state collection into [#angelica$getVertexStates()].
@@ -3,6 +3,7 @@ package com.gtnewhorizons.angelica.rendering.celeritas;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import com.gtnewhorizons.angelica.api.world.WorldDrawStage;
import com.gtnewhorizons.angelica.compat.bop.FogBiomeCache; import com.gtnewhorizons.angelica.compat.bop.FogBiomeCache;
import com.gtnewhorizons.angelica.render.CloudRenderer; import com.gtnewhorizons.angelica.render.CloudRenderer;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -540,6 +541,8 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
try { try {
final int rendered = renderBlockEntities(partialTicks); final int rendered = renderBlockEntities(partialTicks);
if (Tracy.ENABLED) Tracy.plotInt(P_BLOCK_ENTITIES_RENDERED, rendered); if (Tracy.ENABLED) Tracy.plotInt(P_BLOCK_ENTITIES_RENDERED, rendered);
// Inside the block entity phase so the pack lights mod geometry
WorldDrawStage.run(partialTicks);
} finally { } finally {
if (Iris.enabled) GbufferPrograms.endBlockEntities(); if (Iris.enabled) GbufferPrograms.endBlockEntities();
} }
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.rendering.particles; package com.gtnewhorizons.angelica.rendering.particles;
import com.gtnewhorizons.angelica.api.particles.ParticleRendering;
import com.gtnewhorizons.angelica.rendering.RenderFailures; import com.gtnewhorizons.angelica.rendering.RenderFailures;
import com.gtnewhorizons.angelica.client.rendering.DeferredDrawBatcher; import com.gtnewhorizons.angelica.client.rendering.DeferredDrawBatcher;
import com.gtnewhorizons.angelica.glsm.GLSMAttribStack; import com.gtnewhorizons.angelica.glsm.GLSMAttribStack;
@@ -138,6 +139,8 @@ public final class ParticleInstancer {
STATE.sample(); STATE.sample();
SCRATCH.brightness = runTessellator.brightness; SCRATCH.brightness = runTessellator.brightness;
if (!descriptor.describe(fx, partialTicks, SCRATCH, STATE)) return; if (!descriptor.describe(fx, partialTicks, SCRATCH, STATE)) return;
// Mod size factor, the capture path below gets it through renderParticle
SCRATCH.half *= ParticleRendering.renderScale(fx);
runTessellator.color = SCRATCH.colorABGR; runTessellator.color = SCRATCH.colorABGR;
runTessellator.hasColor = true; runTessellator.hasColor = true;
@@ -861,29 +861,6 @@ public class SodiumGameOptionPages {
.build()); .build());
} }
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
.setName(I18n.format("options.angelica.menuBlur"))
.setTooltip(I18n.format("options.angelica.menuBlur.tooltip"))
.setControl(TickBoxControl::new)
.setImpact(OptionImpact.LOW)
.setBinding((opts, value) -> AngelicaConfig.enableMenuBlur = value, opts -> AngelicaConfig.enableMenuBlur)
.build())
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
.setName(I18n.format("options.angelica.menuBlurRadius"))
.setTooltip(I18n.format("options.angelica.menuBlurRadius.tooltip"))
.setControl(option -> new SliderControl(option, 1, 100, 1, ControlValueFormatter.number()))
.setImpact(OptionImpact.LOW)
.setBinding((opts, value) -> AngelicaConfig.menuBlurRadius = value, opts -> AngelicaConfig.menuBlurRadius)
.build())
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
.setName(I18n.format("options.angelica.menuBlurFadeTime"))
.setTooltip(I18n.format("options.angelica.menuBlurFadeTime.tooltip"))
.setControl(option -> new SliderControl(option, 0, 2000, 50, ControlValueFormatter.milliseconds()))
.setBinding((opts, value) -> AngelicaConfig.menuBlurFadeTime = value, opts -> AngelicaConfig.menuBlurFadeTime)
.build())
.build());
return new OptionPage(I18n.format("sodium.options.pages.appearance"), ImmutableList.copyOf(groups)); return new OptionPage(I18n.format("sodium.options.pages.appearance"), ImmutableList.copyOf(groups));
} }
@@ -43,10 +43,6 @@ public interface ControlValueFormatter {
return (v) -> v + "s"; return (v) -> v + "s";
} }
static ControlValueFormatter milliseconds() {
return (v) -> v + "ms";
}
static ControlValueFormatter quantity(String name) { static ControlValueFormatter quantity(String name) {
return (v) -> I18n.format(name, v); return (v) -> I18n.format(name, v);
} }
@@ -1,6 +1,8 @@
package net.coderbot.iris.pipeline; package net.coderbot.iris.pipeline;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.gtnewhorizons.angelica.api.shadows.ShadowCasters;
import com.gtnewhorizons.angelica.api.shadows.ShadowStage;
import com.gtnewhorizons.angelica.compat.mojang.Camera; import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil; import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack; import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
@@ -99,6 +101,8 @@ public class ShadowRenderer {
public static final List<List<TileEntity>> visibleTileEntities = new ArrayList<>(); public static final List<List<TileEntity>> visibleTileEntities = new ArrayList<>();
public static final List<List<TileEntity>> globalTileEntities = new ArrayList<>(); public static final List<List<TileEntity>> globalTileEntities = new ArrayList<>();
public static boolean ACTIVE = false; public static boolean ACTIVE = false;
// Pack's block entity shadow settings for the current pass, read by ShadowCasters
public static boolean BLOCK_ENTITIES = true, LIGHT_BLOCK_ENTITIES = true;
public static Frustrum FRUSTUM; public static Frustrum FRUSTUM;
@@ -869,6 +873,24 @@ public class ShadowRenderer {
profiler.endSection(); profiler.endSection();
} }
private void renderShadowCasters(ShadowStage stage, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float partialTicks) {
if (!ShadowCasters.hasCasters()) return;
try (GLDebug.Scope s = GLDebug.scope("shadow:casters")) {
GLSMMatrices.glPushMatrix();
MODELVIEW_BUFFER.clear().rewind();
modelView.peek().getModel().get(MODELVIEW_BUFFER);
GLSMMatrices.glLoadMatrix(MODELVIEW_BUFFER);
GbufferPrograms.beginBlockEntities();
GbufferPrograms.setBlockEntityDefaults();
try {
ShadowCasters.renderAll(stage, cameraX, cameraY, cameraZ, partialTicks);
} finally {
GbufferPrograms.endBlockEntities();
GLSMMatrices.glPopMatrix();
}
}
}
public void renderShadows(EntityRenderer levelRenderer, Camera playerCamera) { public void renderShadows(EntityRenderer levelRenderer, Camera playerCamera) {
final Minecraft mc = Minecraft.getMinecraft(); final Minecraft mc = Minecraft.getMinecraft();
final RenderGlobal rg = mc.renderGlobal; final RenderGlobal rg = mc.renderGlobal;
@@ -889,6 +911,8 @@ public class ShadowRenderer {
} }
ACTIVE = true; ACTIVE = true;
BLOCK_ENTITIES = shouldRenderBlockEntities;
LIGHT_BLOCK_ENTITIES = shouldRenderLightBlockEntities;
CURRENT_TARGETS = this.targets; CURRENT_TARGETS = this.targets;
// ACTIVE routes clipRenderersByFrustum into the shadow path; a leak would send every main pass there. // ACTIVE routes clipRenderersByFrustum into the shadow path; a leak would send every main pass there.
try { try {
@@ -1027,6 +1051,9 @@ public class ShadowRenderer {
} }
} }
// Not gated on shadowBlockEntities, casters can stand in for terrain
renderShadowCasters(ShadowStage.SOLID, modelView, entityX, entityY, entityZ, tickDelta);
profiler.endStartSection("iris_shadow_draw_entities"); profiler.endStartSection("iris_shadow_draw_entities");
// NB: Don't try to draw the translucent parts of entities afterwards. It'll cause problems since some // NB: Don't try to draw the translucent parts of entities afterwards. It'll cause problems since some
@@ -1044,6 +1071,7 @@ public class ShadowRenderer {
try (GLDebug.Scope s = GLDebug.scope("shadow:translucent")) { try (GLDebug.Scope s = GLDebug.scope("shadow:translucent")) {
rg.sortAndRender(mc.renderViewEntity, 1, playerCamera.getPartialTicks()); rg.sortAndRender(mc.renderViewEntity, 1, playerCamera.getPartialTicks());
} }
renderShadowCasters(ShadowStage.TRANSLUCENT, modelView, entityX, entityY, entityZ, tickDelta);
} }
// Note: Apparently tripwire isn't rendered in the shadow pass. // Note: Apparently tripwire isn't rendered in the shadow pass.
@@ -402,16 +402,6 @@ sodium.options.use_render_pass_optimization.tooltip=Analyzes sprite transparency
options.angelica.aggressiveChunkLoading=Aggressive Chunk Loading options.angelica.aggressiveChunkLoading=Aggressive Chunk Loading
options.angelica.aggressiveChunkLoading.tooltip=Renders chunks immediately when loaded, even if neighbors aren't ready yet. Improves perceived loading speed at render distance edges. Chunks rebuild automatically when neighbors load. Useful for low render distance servers. options.angelica.aggressiveChunkLoading.tooltip=Renders chunks immediately when loaded, even if neighbors aren't ready yet. Improves perceived loading speed at render distance edges. Chunks rebuild automatically when neighbors load. Useful for low render distance servers.
options.angelica.disablef3=Disable F3 Additions
options.angelica.disablef3.tooltip=Disables Angelica's additions to the F3 debug screen.
options.angelica.verbosef3=Verbose F3
options.angelica.verbosef3.tooltip=Shows developer counters (fixed-function shaders, streaming, TESR batching, GPU transfer) on the F3 screen. Toggle in game with F3+V.
options.angelica.menuBlur=Menu Blur
options.angelica.menuBlur.tooltip=Blurs the world behind open menus like the inventory or the pause menu. Chat is never blurred. Excluded menus and background colors can be changed in the Angelica config.
options.angelica.menuBlurRadius=Menu Blur Strength
options.angelica.menuBlurRadius.tooltip=How strong the menu blur is. Higher values blur more.
options.angelica.menuBlurFadeTime=Menu Blur Fade Time
options.angelica.menuBlurFadeTime.tooltip=How long the menu blur takes to fade in after a menu opens. 0 shows it instantly.
angelica.debug.verbose.on=Verbose F3: shown angelica.debug.verbose.on=Verbose F3: shown
angelica.debug.verbose.off=Verbose F3: hidden angelica.debug.verbose.off=Verbose F3: hidden
angelica.debug.group.rendering=Rendering angelica.debug.group.rendering=Rendering
@@ -1,19 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.blur;
import com.gtnewhorizons.angelica.blur.MenuBlur;
import net.minecraft.client.renderer.EntityRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EntityRenderer.class)
public class MixinEntityRenderer_MenuBlur {
@Inject(
method = "updateCameraAndRender",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/EntityRenderer;renderWorld(FJ)V", shift = At.Shift.AFTER))
private void angelica$blurWorldBehindGui(float partialTicks, CallbackInfo ci) {
MenuBlur.renderBlur();
}
}
@@ -1,22 +0,0 @@
package com.gtnewhorizons.angelica.mixins.early.angelica.blur;
import com.gtnewhorizons.angelica.blur.MenuBlur;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import net.minecraft.client.gui.GuiScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(GuiScreen.class)
public class MixinGuiScreen_MenuBlur {
@ModifyConstant(method = "drawWorldBackground", constant = @Constant(intValue = 0xC0101010))
private int angelica$blurGradientTop(int original) {
return MenuBlur.getBackgroundColor(original, AngelicaConfig.menuBlurGradientTopColor);
}
@ModifyConstant(method = "drawWorldBackground", constant = @Constant(intValue = 0xD0101010))
private int angelica$blurGradientBottom(int original) {
return MenuBlur.getBackgroundColor(original, AngelicaConfig.menuBlurGradientBottomColor);
}
}
@@ -103,6 +103,16 @@ public class MixinTessellator implements StateAwareTessellator, BiomeBlendTessel
this.angelica$noDirectionalShading = flag; this.angelica$noDirectionalShading = flag;
} }
@Override
public boolean angelica$isAppliedAo() {
return this.appliedAo;
}
@Override
public boolean angelica$isNoDirectionalShading() {
return this.angelica$noDirectionalShading;
}
@Override @Override
public int[] angelica$getVertexStates() { public int[] angelica$getVertexStates() {
return this.vertexStates.elements(); return this.vertexStates.elements();
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.shaders; package com.gtnewhorizons.angelica.mixins.early.shaders;
import com.gtnewhorizons.angelica.api.terrain.TerrainRendering;
import com.gtnewhorizons.angelica.compat.mojang.Camera; import com.gtnewhorizons.angelica.compat.mojang.Camera;
import com.gtnewhorizons.angelica.config.AngelicaConfig; import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.experimental.surround.Surround; import com.gtnewhorizons.angelica.experimental.surround.Surround;
@@ -55,6 +56,8 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
SystemTimeUniforms.TIMER.beginFrame(System.nanoTime()); SystemTimeUniforms.TIMER.beginFrame(System.nanoTime());
Program.unbind(); Program.unbind();
// Close any terrain draw a mod left open last frame
TerrainRendering.resetForFrame();
mc.mcProfiler.startSection("iris_prepare_pipeline"); mc.mcProfiler.startSection("iris_prepare_pipeline");
final WorldRenderingPipeline pipeline = Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimensionName()); final WorldRenderingPipeline pipeline = Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimensionName());