[vintage] Add biome blend option, small changes to .lang file #19
No files matched your search
@@ -73,3 +73,13 @@ Please reach out to @embeddedt on Discord if you have concerns regarding the lic
|
|||||||
* CelestialAbyss, for developing the Embeddium logo (which is reused here aside from recoloring), and input-Here for some very good visual touchups
|
* CelestialAbyss, for developing the Embeddium logo (which is reused here aside from recoloring), and input-Here for some very good visual touchups
|
||||||
* Ven ([@basdxz](https://github.com/basdxz)), for help with translucency sorting, suggesting the general approach for async occlusion culling, and other suggestions during development
|
* Ven ([@basdxz](https://github.com/basdxz)), for help with translucency sorting, suggesting the general approach for async occlusion culling, and other suggestions during development
|
||||||
* XFactHD, Pepper, and anyone else I've forgotten to mention, for providing valuable code insights
|
* XFactHD, Pepper, and anyone else I've forgotten to mention, for providing valuable code insights
|
||||||
|
|
||||||
|
[](https://www.yourkit.com/)
|
||||||
|
|
||||||
|
YourKit supports open source projects with innovative and intelligent tools
|
||||||
|
for monitoring and profiling Java and .NET applications.
|
||||||
|
YourKit is the creator of <a href="https://www.yourkit.com/java/profiler/">YourKit Java Profiler</a>,
|
||||||
|
<a href="https://www.yourkit.com/.net/profiler/">YourKit .NET Profiler</a>,
|
||||||
|
and <a href="https://www.yourkit.com/youmonitor/">YourKit YouMonitor</a>.
|
||||||
|
|
||||||
|
Special thanks to YourKit for providing a free license for my various open-source Minecraft projects.
|
||||||
@@ -52,7 +52,7 @@ public abstract class WorldRendererMixin implements RenderGlobalExtension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "m_6748042", at = @At(opcode = Opcodes.PUTFIELD, value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;chunkGridSizeZ:I", shift = At.Shift.AFTER))
|
@Inject(method = { "reload", "m_6748042" }, at = @At(opcode = Opcodes.PUTFIELD, value = "FIELD", target = "Lnet/minecraft/client/render/world/WorldRenderer;chunkGridSizeZ:I", shift = At.Shift.AFTER))
|
||||||
private void nullifyBuiltChunkStorage(CallbackInfo ci) {
|
private void nullifyBuiltChunkStorage(CallbackInfo ci) {
|
||||||
this.chunkGridSizeX = 0;
|
this.chunkGridSizeX = 0;
|
||||||
this.chunkGridSizeY = 0;
|
this.chunkGridSizeY = 0;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "celeritas",
|
"id": "celeritas",
|
||||||
"name": "Celeritas",
|
"name": "Celeritas",
|
||||||
"version": "${version}",
|
"version": "${mod_version}",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"description": "An open-source client performance mod for Minecraft",
|
"description": "An open-source client performance mod for Minecraft",
|
||||||
"authors": ["embeddedt"],
|
"authors": ["embeddedt"],
|
||||||
|
|||||||
+5
-2
@@ -22,11 +22,14 @@ public final class Material {
|
|||||||
/**
|
/**
|
||||||
* Constructs a new Material.
|
* Constructs a new Material.
|
||||||
* @param pass the {@link TerrainRenderPass} to use for the base configuration
|
* @param pass the {@link TerrainRenderPass} to use for the base configuration
|
||||||
* @param alphaCutoff the alpha level below which fragments should be discarded (only respected if
|
* @param alphaCutoff the alpha level below which fragments should be discarded
|
||||||
* {@link TerrainRenderPass#supportsFragmentDiscard()} is true for the given pass)
|
|
||||||
* @param mipped whether mipmapping should be enabled on geometry rendered with this material
|
* @param mipped whether mipmapping should be enabled on geometry rendered with this material
|
||||||
*/
|
*/
|
||||||
public Material(TerrainRenderPass pass, AlphaCutoffParameter alphaCutoff, boolean mipped) {
|
public Material(TerrainRenderPass pass, AlphaCutoffParameter alphaCutoff, boolean mipped) {
|
||||||
|
if (alphaCutoff != AlphaCutoffParameter.ZERO && !pass.supportsFragmentDiscard()) {
|
||||||
|
throw new IllegalArgumentException("Pass does not support fragment discard");
|
||||||
|
}
|
||||||
|
|
||||||
this.pass = pass;
|
this.pass = pass;
|
||||||
this.packed = MaterialParameters.pack(alphaCutoff, mipped);
|
this.packed = MaterialParameters.pack(alphaCutoff, mipped);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class ModernRenderSectionManager extends RenderSectionManager {
|
|||||||
//? if <1.21.5 {
|
//? if <1.21.5 {
|
||||||
var renderPassConfiguration = org.embeddedt.embeddium.impl.modern.render.chunk.config.ModernRenderPassConfigurationBuilder.build(vertexType);
|
var renderPassConfiguration = org.embeddedt.embeddium.impl.modern.render.chunk.config.ModernRenderPassConfigurationBuilder.build(vertexType);
|
||||||
//?} else
|
//?} else
|
||||||
/*var renderPassConfiguration = org.embeddedt.embeddium.impl.modern.render.chunk.config.PostmodernRenderPassConfigurationBuilder.build(vertexType);*/
|
/*var renderPassConfiguration = new org.embeddedt.embeddium.impl.modern.render.chunk.config.PostmodernRenderPassConfigurationBuilder(vertexType).build();*/
|
||||||
return new ModernRenderSectionManager(renderPassConfiguration, world, renderDistance, commandList);
|
return new ModernRenderSectionManager(renderPassConfiguration, world, renderDistance, commandList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -1,12 +1,14 @@
|
|||||||
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.tasks;
|
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.tasks;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||||
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
//? if >=1.21.5
|
//? if >=1.21.5 {
|
||||||
/*import net.minecraft.client.renderer.block.model.BlockModelPart;*/
|
/*import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import net.minecraft.client.renderer.block.model.BlockModelPart;
|
||||||
|
*///?}
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
import net.minecraft.world.level.block.AirBlock;
|
||||||
import org.embeddedt.embeddium.api.render.chunk.SectionInfoBuilder;
|
import org.embeddedt.embeddium.api.render.chunk.SectionInfoBuilder;
|
||||||
import org.embeddedt.embeddium.api.render.texture.SpriteUtil;
|
import org.embeddedt.embeddium.api.render.texture.SpriteUtil;
|
||||||
import org.embeddedt.embeddium.impl.modern.render.chunk.compile.ModernChunkBuildContext;
|
import org.embeddedt.embeddium.impl.modern.render.chunk.compile.ModernChunkBuildContext;
|
||||||
@@ -121,7 +123,7 @@ public class ChunkBuilderMeshingTask extends ChunkBuilderTask<ChunkBuildOutput>
|
|||||||
BlockState blockState = slice.getBlockState(x, y, z);
|
BlockState blockState = slice.getBlockState(x, y, z);
|
||||||
|
|
||||||
// Fast path - skip blocks that are air and don't have any custom logic
|
// Fast path - skip blocks that are air and don't have any custom logic
|
||||||
if (blockState.isAir() && blockState.getRenderShape() == RenderShape.INVISIBLE && !WorldUtil.hasBlockEntity(blockState)) {
|
if (blockState.getBlock().getClass() == AirBlock.class) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+44
-24
@@ -10,6 +10,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.textures.GpuTextureView;
|
import com.mojang.blaze3d.textures.GpuTextureView;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
import net.minecraft.client.renderer.chunk.ChunkSectionLayer;
|
||||||
|
import org.embeddedt.embeddium.impl.Celeritas;
|
||||||
import org.embeddedt.embeddium.impl.mixin.core.render.blaze.GlCommandEncoderAccessor;
|
import org.embeddedt.embeddium.impl.mixin.core.render.blaze.GlCommandEncoderAccessor;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||||
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
||||||
@@ -22,8 +23,51 @@ import org.lwjgl.opengl.GL32C;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class PostmodernRenderPassConfigurationBuilder {
|
public class PostmodernRenderPassConfigurationBuilder {
|
||||||
|
private static final Map<ChunkSectionLayer, ChunkSectionLayer> CONSOLIDATION_MAPPINGS = Map.of(
|
||||||
|
ChunkSectionLayer.CUTOUT, ChunkSectionLayer.CUTOUT_MIPPED
|
||||||
|
);
|
||||||
private static RenderPass currentChunkRenderPass;
|
private static RenderPass currentChunkRenderPass;
|
||||||
|
|
||||||
|
private final Map<ChunkSectionLayer, Material> layerToMaterial = new EnumMap<>(ChunkSectionLayer.class);
|
||||||
|
private final Map<ChunkSectionLayer, TerrainRenderPass> passForLayer = new EnumMap<>(ChunkSectionLayer.class);
|
||||||
|
private final Map<ChunkSectionLayer, Collection<TerrainRenderPass>> renderStages = new EnumMap<>(ChunkSectionLayer.class);
|
||||||
|
private final Map<ChunkSectionLayer, ChunkSectionLayer> consolidationMap = Celeritas.options().performance.useRenderPassConsolidation ? CONSOLIDATION_MAPPINGS : Map.of();
|
||||||
|
private final ChunkVertexType vertexType;
|
||||||
|
|
||||||
|
public PostmodernRenderPassConfigurationBuilder(ChunkVertexType vertexType) {
|
||||||
|
this.vertexType = vertexType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TerrainRenderPass buildTerrainRenderPassForLayer(ChunkSectionLayer l) {
|
||||||
|
return this.passForLayer.computeIfAbsent(l, layer -> {
|
||||||
|
var pipeline = layer.pipeline();
|
||||||
|
return TerrainRenderPass.builder().name(layer.name().toLowerCase(Locale.ROOT))
|
||||||
|
.pipelineState(new PostmodernPipelineState(layer, pipeline))
|
||||||
|
.vertexType(vertexType)
|
||||||
|
.primitiveType(QuadPrimitiveType.TRIANGULATED)
|
||||||
|
.fragmentDiscard(pipeline.getShaderDefines().values().containsKey("ALPHA_CUTOUT"))
|
||||||
|
.useReverseOrder(layer.sortOnUpload())
|
||||||
|
.useTranslucencySorting(layer.sortOnUpload())
|
||||||
|
.build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderPassConfiguration<ChunkSectionLayer> build() {
|
||||||
|
for (var layer : ChunkSectionLayer.values()) {
|
||||||
|
var pipeline = layer.pipeline();
|
||||||
|
var alphaCutoff = Optional.ofNullable(pipeline.getShaderDefines().values().get("ALPHA_CUTOUT")).map(Float::parseFloat);
|
||||||
|
TerrainRenderPass terrainPass = this.buildTerrainRenderPassForLayer(consolidationMap.getOrDefault(layer, layer));
|
||||||
|
var material = new Material(terrainPass, alphaCutoff.map(AlphaCutoffParameter::valueOf).orElse(AlphaCutoffParameter.ZERO), layer.useMipmaps);
|
||||||
|
layerToMaterial.put(layer, material);
|
||||||
|
renderStages.put(layer, List.of(terrainPass));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new RenderPassConfiguration<>(layerToMaterial, renderStages,
|
||||||
|
layerToMaterial.get(ChunkSectionLayer.SOLID),
|
||||||
|
layerToMaterial.get(ChunkSectionLayer.CUTOUT_MIPPED),
|
||||||
|
layerToMaterial.get(ChunkSectionLayer.TRANSLUCENT));
|
||||||
|
}
|
||||||
|
|
||||||
private record PostmodernPipelineState(ChunkSectionLayer layer, RenderPipeline vanillaPipeline) implements TerrainRenderPass.PipelineState {
|
private record PostmodernPipelineState(ChunkSectionLayer layer, RenderPipeline vanillaPipeline) implements TerrainRenderPass.PipelineState {
|
||||||
@Override
|
@Override
|
||||||
public void setup() {
|
public void setup() {
|
||||||
@@ -76,29 +120,5 @@ public class PostmodernRenderPassConfigurationBuilder {
|
|||||||
currentChunkRenderPass = null;
|
currentChunkRenderPass = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RenderPassConfiguration<ChunkSectionLayer> build(ChunkVertexType vertexType) {
|
|
||||||
Map<ChunkSectionLayer, Material> layerToMaterial = new EnumMap<>(ChunkSectionLayer.class);
|
|
||||||
Map<ChunkSectionLayer, Collection<TerrainRenderPass>> renderStages = new EnumMap<>(ChunkSectionLayer.class);
|
|
||||||
for (var layer : ChunkSectionLayer.values()) {
|
|
||||||
var pipeline = layer.pipeline();
|
|
||||||
var alphaCutoff = Optional.ofNullable(pipeline.getShaderDefines().values().get("ALPHA_CUTOUT")).map(Float::parseFloat);
|
|
||||||
var terrainPass = TerrainRenderPass.builder().name(layer.name().toLowerCase(Locale.ROOT))
|
|
||||||
.pipelineState(new PostmodernPipelineState(layer, pipeline))
|
|
||||||
.vertexType(vertexType)
|
|
||||||
.primitiveType(QuadPrimitiveType.TRIANGULATED)
|
|
||||||
.fragmentDiscard(alphaCutoff.isPresent())
|
|
||||||
.useReverseOrder(layer.sortOnUpload())
|
|
||||||
.useTranslucencySorting(layer.sortOnUpload())
|
|
||||||
.build();
|
|
||||||
var material = new Material(terrainPass, alphaCutoff.map(AlphaCutoffParameter::valueOf).orElse(AlphaCutoffParameter.ZERO), layer.useMipmaps);
|
|
||||||
layerToMaterial.put(layer, material);
|
|
||||||
renderStages.put(layer, List.of(terrainPass));
|
|
||||||
}
|
|
||||||
return new RenderPassConfiguration<>(layerToMaterial, renderStages,
|
|
||||||
layerToMaterial.get(ChunkSectionLayer.SOLID),
|
|
||||||
layerToMaterial.get(ChunkSectionLayer.CUTOUT_MIPPED),
|
|
||||||
layerToMaterial.get(ChunkSectionLayer.TRANSLUCENT));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*///?}
|
*///?}
|
||||||
+12
-1
@@ -3,6 +3,8 @@ package org.embeddedt.embeddium.impl.world.cloned;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ReferenceMap;
|
import it.unimi.dsi.fastutil.ints.Int2ReferenceMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
@@ -220,6 +222,15 @@ public class ClonedChunkSection {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Iterable<Map.Entry<BlockPos, BlockEntity>> fastIterable(Map<BlockPos, BlockEntity> blockEntityMap) {
|
||||||
|
if (blockEntityMap instanceof Object2ObjectMap<BlockPos, BlockEntity> fastutilMap) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (Iterable<Map.Entry<BlockPos, BlockEntity>>)(Iterable<?>)Object2ObjectMaps.fastIterable(fastutilMap);
|
||||||
|
} else {
|
||||||
|
return blockEntityMap.entrySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Int2ReferenceMap<BlockEntity> copyBlockEntities(LevelChunk chunk, SectionPos chunkCoord) {
|
private static Int2ReferenceMap<BlockEntity> copyBlockEntities(LevelChunk chunk, SectionPos chunkCoord) {
|
||||||
var chunkBlockEntityMap = chunk.getBlockEntities();
|
var chunkBlockEntityMap = chunk.getBlockEntities();
|
||||||
@@ -234,7 +245,7 @@ public class ClonedChunkSection {
|
|||||||
Int2ReferenceOpenHashMap<BlockEntity> blockEntities = null;
|
Int2ReferenceOpenHashMap<BlockEntity> blockEntities = null;
|
||||||
|
|
||||||
// Copy the block entities from the chunk into our cloned section
|
// Copy the block entities from the chunk into our cloned section
|
||||||
for (Map.Entry<BlockPos, BlockEntity> entry : chunkBlockEntityMap.entrySet()) {
|
for (Map.Entry<BlockPos, BlockEntity> entry : fastIterable(chunkBlockEntityMap)) {
|
||||||
BlockPos pos = entry.getKey();
|
BlockPos pos = entry.getKey();
|
||||||
BlockEntity entity = entry.getValue();
|
BlockEntity entity = entry.getValue();
|
||||||
|
|
||||||
|
|||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package org.embeddedt.embeddium.impl.modern.render.chunk.compile.pipeline;
|
|
||||||
|
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
public class FluidOcclusionCacheTest {
|
|
||||||
private final FluidOcclusionCache cache = new FluidOcclusionCache();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testFullBlockHidesFluidFace() {
|
|
||||||
assertFalse(cache.isTopFluidFacePotentiallyVisible(Shapes.block()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testSlabHidesFluidFace() {
|
|
||||||
assertFalse(cache.isTopFluidFacePotentiallyVisible(FluidOcclusionCache.UPPER_HALF_SLAB));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testThinSlabDoesNotHideFluidFace() {
|
|
||||||
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(0.0, 0.7, 0.0, 1.0, 1.0, 1.0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testInsetBlockDoesNotHideFluidFace() {
|
|
||||||
double inset = 0.1;
|
|
||||||
assertTrue(cache.isTopFluidFacePotentiallyVisible(Shapes.box(inset, 0.5, inset, 1.0 - inset, 1.0, 1.0 - inset)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user