{
public void delete() {
models.invalidateAll();
- modelPool.delete();
+ if (allocator instanceof ModelPool pool) pool.delete();
}
/**
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialGroup.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialGroup.java
index ac7f9b36f..466c82e15 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialGroup.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialGroup.java
@@ -1,12 +1,13 @@
package com.jozufozu.flywheel.backend.instancing.instancing;
-import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.MaterialGroup;
import com.jozufozu.flywheel.api.struct.StructType;
+import com.jozufozu.flywheel.backend.model.ModelPool;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.util.TextureBinder;
import com.mojang.math.Matrix4f;
@@ -24,8 +25,6 @@ public class InstancedMaterialGroup implements MaterialG
protected final InstancingEngine
owner;
protected final RenderType type;
- protected final ArrayList> renderers = new ArrayList<>();
-
private final Map, InstancedMaterial>> materials = new HashMap<>();
public InstancedMaterialGroup(InstancingEngine owner, RenderType type) {
@@ -33,27 +32,48 @@ public class InstancedMaterialGroup
implements MaterialG
this.type = type;
}
- /**
- * Get the material as defined by the given {@link MaterialSpec spec}.
- * @param spec The material you want to create instances with.
- * @param The type representing the per instance data.
- * @return A
- */
@SuppressWarnings("unchecked")
@Override
public InstancedMaterial material(StructType spec) {
- return (InstancedMaterial) materials.computeIfAbsent(spec, this::createInstanceMaterial);
+ return (InstancedMaterial) materials.computeIfAbsent(spec, InstancedMaterial::new);
}
public void render(Matrix4f viewProjection, double camX, double camY, double camZ) {
type.setupRenderState();
TextureBinder.bindActiveTextures();
- for (InstancedMaterialRenderer renderer : renderers) {
- renderer.render(viewProjection, camX, camY, camZ);
- }
+ renderAll(viewProjection, camX, camY, camZ);
type.clearRenderState();
}
+ protected void renderAll(Matrix4f viewProjection, double camX, double camY, double camZ) {
+ for (Map.Entry, InstancedMaterial>> entry : materials.entrySet()) {
+ InstancedMaterial> material = entry.getValue();
+ if (material.nothingToRender()) continue;
+
+ Collection extends GPUInstancer>> instancers = material.models.asMap()
+ .values();
+
+ // initialize all uninitialized instancers...
+ instancers.forEach(GPUInstancer::init);
+ if (material.allocator instanceof ModelPool pool) {
+ // ...and then flush the model arena in case anything was marked for upload
+ pool.flush();
+ }
+
+ P program = owner.getProgram(entry.getKey()
+ .asInstanced()
+ .getProgramSpec()).get();
+
+ program.bind();
+ program.uploadViewProjection(viewProjection);
+ program.uploadCameraPos(camX, camY, camZ);
+
+ setup(program);
+
+ instancers.forEach(GPUInstancer::render);
+ }
+ }
+
public void setup(P program) {
}
@@ -67,15 +87,5 @@ public class InstancedMaterialGroup implements MaterialG
.forEach(InstancedMaterial::delete);
materials.clear();
- renderers.clear();
- }
-
- private InstancedMaterial> createInstanceMaterial(StructType extends InstanceData> type) {
- InstancedMaterial> material = new InstancedMaterial<>(type);
-
- this.renderers.add(new InstancedMaterialRenderer<>(owner.getProgram(type.asInstanced()
- .getProgramSpec()), material, this::setup));
-
- return material;
}
}
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialRenderer.java
deleted file mode 100644
index 9d52ea695..000000000
--- a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancedMaterialRenderer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.jozufozu.flywheel.backend.instancing.instancing;
-
-import java.util.Collection;
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-import com.jozufozu.flywheel.core.shader.WorldProgram;
-import com.mojang.math.Matrix4f;
-
-public class InstancedMaterialRenderer
{
-
- protected final Supplier
program;
- protected final InstancedMaterial> material;
-
- protected final Consumer
setupFunc;
-
- public InstancedMaterialRenderer(Supplier
programSupplier, InstancedMaterial> material, Consumer
setupFunc) {
- this.program = programSupplier;
- this.material = material;
- this.setupFunc = setupFunc;
- }
-
- public void render(Matrix4f viewProjection, double camX, double camY, double camZ) {
- if (material.nothingToRender()) return;
-
- Collection extends GPUInstancer>> instancers = material.models.asMap()
- .values();
-
- // initialize all uninitialized instancers...
- instancers.forEach(GPUInstancer::init);
- // ...and then flush the model arena in case anything was marked for upload
- material.modelPool.flush();
-
- P program = this.program.get();
-
- program.bind();
- program.uploadViewProjection(viewProjection);
- program.uploadCameraPos(camX, camY, camZ);
-
- setupFunc.accept(program);
-
- instancers.forEach(GPUInstancer::render);
- }
-
-}
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java
index 08118ecfc..95b650784 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/instancing/InstancingEngine.java
@@ -8,11 +8,11 @@ import java.util.stream.Stream;
import javax.annotation.Nullable;
+import com.jozufozu.flywheel.api.MaterialGroup;
+import com.jozufozu.flywheel.backend.RenderLayer;
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
import com.jozufozu.flywheel.backend.instancing.Engine;
-import com.jozufozu.flywheel.api.MaterialGroup;
-import com.jozufozu.flywheel.backend.RenderLayer;
import com.jozufozu.flywheel.core.WorldContext;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.event.RenderLayerEvent;
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java
index 506b220a4..b064d214f 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java
@@ -1,10 +1,10 @@
package com.jozufozu.flywheel.backend.instancing.tile;
-import com.jozufozu.flywheel.backend.instancing.AbstractInstance;
-import com.jozufozu.flywheel.api.instance.IDynamicInstance;
-import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
+import com.jozufozu.flywheel.api.instance.IDynamicInstance;
+import com.jozufozu.flywheel.api.instance.ITickableInstance;
+import com.jozufozu.flywheel.backend.instancing.AbstractInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java
index 57eb8c8e9..aa4e6c274 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceManager.java
@@ -1,10 +1,10 @@
package com.jozufozu.flywheel.backend.instancing.tile;
+import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.instancing.AbstractInstance;
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
-import com.jozufozu.flywheel.api.MaterialManager;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java b/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java
index f22818d32..02ab9606b 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java
@@ -43,6 +43,8 @@ public class IndexedModel extends BufferedModel {
public void drawInstances(int instanceCount) {
if (!valid()) return;
+ ebo.bind();
+
GL31.glDrawElementsInstanced(primitiveMode.glEnum, ebo.elementCount, ebo.eboIndexType.getGlEnum(), 0, instanceCount);
}
}
diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java b/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java
index 5a1d033f6..72f7973e2 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java
@@ -120,9 +120,12 @@ public class ModelPool implements ModelAllocator {
VecBufferWriter consumer = new VecBufferWriter(buffer);
+ int vertices = 0;
for (PooledModel model : models) {
+ model.first = vertices;
model.model.buffer(consumer);
if (model.callback != null) model.callback.onAlloc(model);
+ vertices += model.getVertexCount();
}
} catch (Exception e) {
diff --git a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShader.java b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShader.java
index 2cb7defbb..cffa9142b 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShader.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShader.java
@@ -56,6 +56,7 @@ public class WorldShader {
finalSource.append("#version ")
.append(template.getVersion())
.append('\n')
+ .append("#extension GL_ARB_conservative_depth : enable\n")
.append("#define ")
.append(type.define) // special case shader type declaration
.append('\n')
diff --git a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java
index 985a60ad7..9129cb514 100644
--- a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java
+++ b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java
@@ -7,9 +7,9 @@ import javax.annotation.Nullable;
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
import com.jozufozu.flywheel.backend.source.FileResolution;
import com.jozufozu.flywheel.backend.source.SourceFile;
+import com.jozufozu.flywheel.core.shader.ContextAwareProgram;
import com.jozufozu.flywheel.core.shader.ExtensibleGlProgram;
import com.jozufozu.flywheel.core.shader.GameStateProgram;
-import com.jozufozu.flywheel.core.shader.ContextAwareProgram;
import com.jozufozu.flywheel.core.shader.WorldProgram;
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
import com.jozufozu.flywheel.core.shader.spec.ProgramState;
diff --git a/src/main/java/com/jozufozu/flywheel/core/Contexts.java b/src/main/java/com/jozufozu/flywheel/core/Contexts.java
index 2d065b414..b237deb5e 100644
--- a/src/main/java/com/jozufozu/flywheel/core/Contexts.java
+++ b/src/main/java/com/jozufozu/flywheel/core/Contexts.java
@@ -3,8 +3,8 @@ package com.jozufozu.flywheel.core;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.GameStateRegistry;
-import com.jozufozu.flywheel.backend.pipeline.ShaderPipeline;
import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate;
+import com.jozufozu.flywheel.backend.pipeline.ShaderPipeline;
import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline;
import com.jozufozu.flywheel.backend.source.FileResolution;
import com.jozufozu.flywheel.backend.source.Resolver;
diff --git a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
index a1269b613..1436dab6c 100644
--- a/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
+++ b/src/main/java/com/jozufozu/flywheel/core/FullscreenQuad.java
@@ -1,8 +1,9 @@
package com.jozufozu.flywheel.core;
-import static org.lwjgl.opengl.GL20.*;
-
-import org.lwjgl.opengl.GL20;
+import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
+import static org.lwjgl.opengl.GL11.glDrawArrays;
+import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
+import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.gl.GlNumericType;
diff --git a/src/main/java/com/jozufozu/flywheel/core/Materials.java b/src/main/java/com/jozufozu/flywheel/core/Materials.java
index 8c3ac946b..d16683b38 100644
--- a/src/main/java/com/jozufozu/flywheel/core/Materials.java
+++ b/src/main/java/com/jozufozu/flywheel/core/Materials.java
@@ -1,7 +1,7 @@
package com.jozufozu.flywheel.core;
-import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.api.struct.StructType;
+import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.materials.model.ModelType;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
diff --git a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
index a5093fbe5..c0eff27ae 100644
--- a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
+++ b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingGroup.java
@@ -2,7 +2,6 @@ package com.jozufozu.flywheel.core.crumbling;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup;
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
-import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialRenderer;
import com.jozufozu.flywheel.core.atlas.AtlasInfo;
import com.jozufozu.flywheel.core.atlas.SheetData;
import com.jozufozu.flywheel.util.RenderTextures;
@@ -39,9 +38,7 @@ public class CrumblingGroup
extends InstancedMateria
RenderSystem.setShaderTexture(4, breakingTex);
TextureBinder.bindActiveTextures();
- for (InstancedMaterialRenderer
renderer : renderers) {
- renderer.render(viewProjection, camX, camY, camZ);
- }
+ renderAll(viewProjection, camX, camY, camZ);
CrumblingRenderer._currentLayer.clearRenderState();
}
diff --git a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingInstanceManager.java b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingInstanceManager.java
index 63ee63425..30e427f6b 100644
--- a/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingInstanceManager.java
+++ b/src/main/java/com/jozufozu/flywheel/core/crumbling/CrumblingInstanceManager.java
@@ -1,7 +1,7 @@
package com.jozufozu.flywheel.core.crumbling;
-import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.jozufozu.flywheel.api.MaterialManager;
+import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import net.minecraft.core.BlockPos;
diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/model/ModelType.java b/src/main/java/com/jozufozu/flywheel/core/materials/model/ModelType.java
index 6b824890f..c815df2f9 100644
--- a/src/main/java/com/jozufozu/flywheel/core/materials/model/ModelType.java
+++ b/src/main/java/com/jozufozu/flywheel/core/materials/model/ModelType.java
@@ -1,11 +1,11 @@
package com.jozufozu.flywheel.core.materials.model;
-import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
-import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
-import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.api.struct.Instanced;
+import com.jozufozu.flywheel.api.struct.StructWriter;
+import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
+import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.Programs;
import com.jozufozu.flywheel.core.materials.model.writer.UnsafeModelWriter;
diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java b/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java
index f7dba06ad..9b04a8534 100644
--- a/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java
+++ b/src/main/java/com/jozufozu/flywheel/core/materials/model/writer/UnsafeModelWriter.java
@@ -2,8 +2,8 @@ package com.jozufozu.flywheel.core.materials.model.writer;
import org.lwjgl.system.MemoryUtil;
-import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.api.struct.StructType;
+import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.WriteUnsafe;
diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedType.java b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedType.java
index f5203d69c..55f0097f4 100644
--- a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedType.java
+++ b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/OrientedType.java
@@ -1,11 +1,11 @@
package com.jozufozu.flywheel.core.materials.oriented;
-import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
-import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.api.struct.Batched;
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
-import com.jozufozu.flywheel.api.struct.StructWriter;
import com.jozufozu.flywheel.api.struct.Instanced;
+import com.jozufozu.flywheel.api.struct.StructWriter;
+import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
+import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.core.Formats;
import com.jozufozu.flywheel.core.Programs;
import com.jozufozu.flywheel.core.materials.oriented.writer.UnsafeOrientedWriter;
diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java
index b33cefa58..3818985e0 100644
--- a/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java
+++ b/src/main/java/com/jozufozu/flywheel/core/materials/oriented/writer/UnsafeOrientedWriter.java
@@ -2,8 +2,8 @@ package com.jozufozu.flywheel.core.materials.oriented.writer;
import org.lwjgl.system.MemoryUtil;
-import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.api.struct.StructType;
+import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.jozufozu.flywheel.backend.struct.UnsafeBufferWriter;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
diff --git a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java
index 9edb6e721..0fb6f2383 100644
--- a/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java
+++ b/src/main/java/com/jozufozu/flywheel/core/model/PartBuilder.java
@@ -1,13 +1,10 @@
package com.jozufozu.flywheel.core.model;
-import static com.jozufozu.flywheel.util.RenderMath.nb;
-
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
-import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Quaternion;
diff --git a/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java b/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java
index cb7d3727e..68985220b 100644
--- a/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java
+++ b/src/main/java/com/jozufozu/flywheel/light/GPULightVolume.java
@@ -11,16 +11,12 @@ import static org.lwjgl.opengl.GL11.GL_UNPACK_SKIP_PIXELS;
import static org.lwjgl.opengl.GL11.GL_UNPACK_SKIP_ROWS;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE;
import static org.lwjgl.opengl.GL11.glPixelStorei;
-import static org.lwjgl.opengl.GL11.glTexParameteri;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_3D;
import static org.lwjgl.opengl.GL12.GL_TEXTURE_WRAP_R;
import static org.lwjgl.opengl.GL12.GL_UNPACK_IMAGE_HEIGHT;
import static org.lwjgl.opengl.GL12.GL_UNPACK_SKIP_IMAGES;
import static org.lwjgl.opengl.GL12.glTexImage3D;
import static org.lwjgl.opengl.GL12.glTexSubImage3D;
-import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
-import static org.lwjgl.opengl.GL13.GL_TEXTURE4;
-import static org.lwjgl.opengl.GL13.glActiveTexture;
import static org.lwjgl.opengl.GL14.GL_MIRRORED_REPEAT;
import org.lwjgl.opengl.GL30;
diff --git a/src/main/java/com/jozufozu/flywheel/mixin/PausedPartialTickAccessor.java b/src/main/java/com/jozufozu/flywheel/mixin/PausedPartialTickAccessor.java
index 550f6d4ab..ab5e5aa18 100644
--- a/src/main/java/com/jozufozu/flywheel/mixin/PausedPartialTickAccessor.java
+++ b/src/main/java/com/jozufozu/flywheel/mixin/PausedPartialTickAccessor.java
@@ -9,5 +9,5 @@ import net.minecraft.client.Minecraft;
public interface PausedPartialTickAccessor {
@Accessor("pausePartialTick")
- float getPausePartialTick();
+ float flywheel$getPartialTicksPaused();
}
diff --git a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java
index cd8d226a1..8c72ff121 100644
--- a/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java
+++ b/src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java
@@ -16,8 +16,6 @@ import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import com.jozufozu.flywheel.fabric.event.FlywheelEvents;
-import com.jozufozu.flywheel.fabric.helper.Matrix4fHelper;
-import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
diff --git a/src/main/java/com/jozufozu/flywheel/util/AnimationTickHolder.java b/src/main/java/com/jozufozu/flywheel/util/AnimationTickHolder.java
index 0a8374f42..c16da14d8 100644
--- a/src/main/java/com/jozufozu/flywheel/util/AnimationTickHolder.java
+++ b/src/main/java/com/jozufozu/flywheel/util/AnimationTickHolder.java
@@ -37,6 +37,6 @@ public class AnimationTickHolder {
public static float getPartialTicks() {
Minecraft mc = Minecraft.getInstance();
- return (mc.isPaused() ? ((PausedPartialTickAccessor) mc).getPausePartialTick() : mc.getFrameTime());
+ return (mc.isPaused() ? ((PausedPartialTickAccessor) mc).flywheel$getPartialTicksPaused() : mc.getFrameTime());
}
}
diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java
index 1574a5fb4..5cfd8eb60 100644
--- a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java
+++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java
@@ -1,8 +1,8 @@
package com.jozufozu.flywheel.vanilla;
+import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
-import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.jozufozu.flywheel.core.model.ModelPart;
diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java
index 674f48255..0dddeefb7 100644
--- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java
+++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java
@@ -4,9 +4,9 @@ import java.util.Calendar;
import javax.annotation.Nonnull;
+import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
-import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
@@ -125,80 +125,76 @@ public class ChestInstance extends TileE
private ModelPart getBaseModel() {
- switch (chestType) {
- case LEFT:
- return ModelPart.builder("chest_base_left", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 19)
- .start(0, 0, 1)
- .size(15, 10, 14)
- .endCuboid()
- .build();
- case RIGHT:
- return ModelPart.builder("chest_base_right", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 19)
- .start(1, 0, 1)
- .size(15, 10, 14)
- .endCuboid()
- .build();
- }
+ return switch (chestType) {
+ case LEFT -> ModelPart.builder("chest_base_left", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 19)
+ .start(0, 0, 1)
+ .size(15, 10, 14)
+ .endCuboid()
+ .build();
+ case RIGHT -> ModelPart.builder("chest_base_right", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 19)
+ .start(1, 0, 1)
+ .size(15, 10, 14)
+ .endCuboid()
+ .build();
+ default -> ModelPart.builder("chest_base", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 19)
+ .start(1, 0, 1)
+ .end(15, 10, 15)
+ .endCuboid()
+ .build();
+ };
- return ModelPart.builder("chest_base", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 19)
- .start(1, 0, 1)
- .end(15, 10, 15)
- .endCuboid()
- .build();
}
private ModelPart getLidModel() {
- switch (chestType) {
- case LEFT:
- return ModelPart.builder("chest_lid_left", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 0)
- .start(0, 0, 1)
- .size(15, 5, 14)
- .endCuboid()
- .cuboid()
- .start(0, -2, 15)
- .size(1, 4, 1)
- .endCuboid()
- .build();
- case RIGHT:
- return ModelPart.builder("chest_lid_right", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 0)
- .start(1, 0, 1)
- .size(15, 5, 14)
- .endCuboid()
- .cuboid()
- .start(15, -2, 15)
- .size(1, 4, 1)
- .endCuboid()
- .build();
- }
+ return switch (chestType) {
+ case LEFT -> ModelPart.builder("chest_lid_left", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 0)
+ .start(0, 0, 1)
+ .size(15, 5, 14)
+ .endCuboid()
+ .cuboid()
+ .start(0, -2, 15)
+ .size(1, 4, 1)
+ .endCuboid()
+ .build();
+ case RIGHT -> ModelPart.builder("chest_lid_right", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 0)
+ .start(1, 0, 1)
+ .size(15, 5, 14)
+ .endCuboid()
+ .cuboid()
+ .start(15, -2, 15)
+ .size(1, 4, 1)
+ .endCuboid()
+ .build();
+ default -> ModelPart.builder("chest_lid", 64, 64)
+ .sprite(renderMaterial.sprite())
+ .cuboid()
+ .textureOffset(0, 0)
+ .start(1, 0, 1)
+ .size(14, 5, 14)
+ .endCuboid()
+ .cuboid()
+ .start(7, -2, 15)
+ .size(2, 4, 1)
+ .endCuboid()
+ .build();
+ };
- return ModelPart.builder("chest_lid", 64, 64)
- .sprite(renderMaterial.sprite())
- .cuboid()
- .textureOffset(0, 0)
- .start(1, 0, 1)
- .size(14, 5, 14)
- .endCuboid()
- .cuboid()
- .start(7, -2, 15)
- .size(2, 4, 1)
- .endCuboid()
- .build();
}
public static boolean isChristmas() {
diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java
index f14e7dfde..bf53ae248 100644
--- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java
+++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java
@@ -1,9 +1,9 @@
package com.jozufozu.flywheel.vanilla;
+import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
-import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.model.Model;
diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java
index f96710d8e..1f3ecbfe1 100644
--- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java
+++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java
@@ -1,8 +1,8 @@
package com.jozufozu.flywheel.vanilla;
+import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
-import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.core.model.ModelPart;
diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java b/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java
index c14a6ed04..2e759d1ea 100644
--- a/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java
+++ b/src/main/java/com/jozufozu/flywheel/vanilla/VanillaInstances.java
@@ -8,21 +8,21 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
/**
* TODO:
*
- * {@link TileEntityType#SIGN} | {@link net.minecraft.client.renderer.tileentity.SignTileEntityRenderer SignTileEntityRenderer} |
- * {@link TileEntityType#PISTON} | {@link net.minecraft.client.renderer.tileentity.PistonTileEntityRenderer PistonTileEntityRenderer} |
- * {@link TileEntityType#CONDUIT} | {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer} |
- * {@link TileEntityType#ENCHANTING_TABLE} | {@link net.minecraft.client.renderer.tileentity.EnchantmentTableTileEntityRenderer EnchantmentTableTileEntityRenderer} |
- * {@link TileEntityType#LECTERN} | {@link net.minecraft.client.renderer.tileentity.LecternTileEntityRenderer LecternTileEntityRenderer} |
- * {@link TileEntityType#MOB_SPAWNER} | {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer} |
- * {@link TileEntityType#BED} | {@link net.minecraft.client.renderer.tileentity.BedTileEntityRenderer BedTileEntityRenderer} |
+ * {@link BlockEntityType#SIGN} | {@link net.minecraft.client.renderer.blockentity.SignRenderer SignRenderer} |
+ * {@link BlockEntityType#PISTON} | {@link net.minecraft.client.renderer.blockentity.PistonHeadRenderer PistonHeadRenderer} |
+ * {@link BlockEntityType#CONDUIT} | {@link net.minecraft.client.renderer.blockentity.ConduitRenderer ConduitRenderer} |
+ * {@link BlockEntityType#ENCHANTING_TABLE} | {@link net.minecraft.client.renderer.blockentity.EnchantTableRenderer EnchantTableRenderer} |
+ * {@link BlockEntityType#LECTERN} | {@link net.minecraft.client.renderer.blockentity.LecternRenderer LecternRenderer} |
+ * {@link BlockEntityType#MOB_SPAWNER} | {@link net.minecraft.client.renderer.blockentity.SpawnerRenderer SpawnerRenderer} |
+ * {@link BlockEntityType#BED} | {@link net.minecraft.client.renderer.blockentity.BedRenderer BedRenderer} |
* ^^ Interesting - Major vv |
- * {@link TileEntityType#END_PORTAL} | {@link net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer EndPortalTileEntityRenderer} |
- * {@link TileEntityType#END_GATEWAY} | {@link net.minecraft.client.renderer.tileentity.EndGatewayTileEntityRenderer EndGatewayTileEntityRenderer} |
- * {@link TileEntityType#BEACON} | {@link net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer BeaconTileEntityRenderer} |
- * {@link TileEntityType#SKULL} | {@link net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer SkullTileEntityRenderer} |
- * {@link TileEntityType#BANNER} | {@link net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer BannerTileEntityRenderer} |
- * {@link TileEntityType#STRUCTURE_BLOCK} | {@link net.minecraft.client.renderer.tileentity.StructureTileEntityRenderer StructureTileEntityRenderer} |
- * {@link TileEntityType#CAMPFIRE} | {@link net.minecraft.client.renderer.tileentity.CampfireTileEntityRenderer CampfireTileEntityRenderer} |
+ * {@link BlockEntityType#END_PORTAL} | {@link net.minecraft.client.renderer.blockentity.TheEndPortalRenderer TheEndPortalRenderer} |
+ * {@link BlockEntityType#END_GATEWAY} | {@link net.minecraft.client.renderer.blockentity.TheEndGatewayRenderer TheEndGatewayRenderer} |
+ * {@link BlockEntityType#BEACON} | {@link net.minecraft.client.renderer.blockentity.BeaconRenderer BeaconRenderer} |
+ * {@link BlockEntityType#SKULL} | {@link net.minecraft.client.renderer.blockentity.SkullBlockRenderer SkullBlockRenderer} |
+ * {@link BlockEntityType#BANNER} | {@link net.minecraft.client.renderer.blockentity.BannerRenderer BannerRenderer} |
+ * {@link BlockEntityType#STRUCTURE_BLOCK} | {@link net.minecraft.client.renderer.debug.StructureRenderer StructureRenderer} |
+ * {@link BlockEntityType#CAMPFIRE} | {@link net.minecraft.client.renderer.blockentity.CampfireRenderer CampfireRenderer} |
*
*/
public class VanillaInstances {
diff --git a/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl b/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl
index 51afad2eb..1503ed993 100644
--- a/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl
+++ b/src/main/resources/assets/flywheel/flywheel/shaders/context/world.glsl
@@ -28,7 +28,6 @@ void FLWFinalizeWorldPos(inout vec4 worldPos) {
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
-#extension GL_ARB_conservative_depth : enable
layout (depth_greater) out float gl_FragDepth;
#endif
#endif