mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 23:47:09 +01:00
Merge remote-tracking branch 'origin/1.18/dev' into 1.18/fabric/dev
Conflicts: README.md gradle.properties src/main/java/com/jozufozu/flywheel/FlywheelClient.java src/main/java/com/jozufozu/flywheel/mixin/RenderHooksMixin.java src/main/resources/pack.mcmeta
This commit is contained in:
commit
d144403d70
52 changed files with 236 additions and 255 deletions
8
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
8
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
@ -47,11 +47,19 @@ body:
|
|||
placeholder: Windows 11
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: What is your GPU?
|
||||
description: Enter the vendor and model of the GPU you were using when the bug occured
|
||||
placeholder: Nvidia GeForce RTX 3060
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Mod Version
|
||||
description: The version of the mod you were using when the bug occured
|
||||
options:
|
||||
- "0.4.2-rc"
|
||||
- "0.4.1"
|
||||
- "0.3.0"
|
||||
validations:
|
||||
|
|
|
@ -136,7 +136,6 @@ curseforge {
|
|||
changelog = file('changelog.txt')
|
||||
releaseType = project.curse_type
|
||||
mainArtifact jar
|
||||
addGameVersion '1.18'
|
||||
addGameVersion '1.18.1'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
0.4.1a:
|
||||
Fixes
|
||||
- Partially fix crash on intel and mesa drivers (needs Create to update)
|
||||
- Fix garbage rendering on AMD GPUs
|
||||
|
||||
0.4.1:
|
||||
Update to 1.18.1
|
||||
Changes
|
||||
|
@ -6,6 +11,7 @@ Fixes
|
|||
- Fix crash affecting systems that don't support persistent mapping
|
||||
- Fix crash when Create contraptions extend below Y=0
|
||||
- Fix Create contraptions having misaligned light when launched after world load
|
||||
- Fix minecarts disappearing on chunk reload
|
||||
|
||||
0.4.0:
|
||||
Update to 1.18
|
||||
|
|
|
@ -2,10 +2,10 @@ org.gradle.jvmargs = -Xmx3G
|
|||
org.gradle.daemon = false
|
||||
|
||||
# mod version info
|
||||
mod_version = 0.4.1
|
||||
mod_version = 0.4.2-rc
|
||||
mc_update_version = 1.18
|
||||
minecraft_version = 1.18.1
|
||||
loader_version = 0.12.11
|
||||
loader_version = 0.12.12
|
||||
fabric_version = 0.44.0+1.18
|
||||
|
||||
# build dependency versions
|
||||
|
@ -15,7 +15,7 @@ parchment_version = 2021.10.31
|
|||
|
||||
# curseforge info
|
||||
projectId = 486392
|
||||
curse_type = beta
|
||||
curse_type = release
|
||||
|
||||
# github info
|
||||
github_project = Jozufozu/Flywheel
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.jozufozu.flywheel.core.crumbling.CrumblingRenderer;
|
|||
import com.jozufozu.flywheel.event.EntityWorldHandler;
|
||||
import com.jozufozu.flywheel.event.ForgeEvents;
|
||||
import com.jozufozu.flywheel.fabric.event.FlywheelEvents;
|
||||
import com.jozufozu.flywheel.mixin.PausedPartialTickAccessor;
|
||||
import com.jozufozu.flywheel.vanilla.VanillaInstances;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
@ -51,5 +52,12 @@ public class FlywheelClient implements ClientModInitializer {
|
|||
ClientTickEvents.END_CLIENT_TICK.register(ForgeEvents::tickLight);
|
||||
|
||||
FlwConfig.init();
|
||||
|
||||
// https://github.com/Jozufozu/Flywheel/issues/69
|
||||
// Weird issue with accessor loading.
|
||||
// Only thing I've seen that's close to a fix is to force the class to load before trying to use it.
|
||||
// From the SpongePowered discord:
|
||||
// https://discord.com/channels/142425412096491520/626802111455297538/675007581168599041
|
||||
Flywheel.log.info("Successfully loaded {}", PausedPartialTickAccessor.class.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.jozufozu.flywheel.api.instance;
|
||||
|
||||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,9 @@ import org.lwjgl.opengl.GL;
|
|||
import org.lwjgl.opengl.GLCapabilities;
|
||||
|
||||
import com.jozufozu.flywheel.api.FlywheelWorld;
|
||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||
import com.jozufozu.flywheel.config.FlwConfig;
|
||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.gl;
|
||||
|
||||
public enum GLSLVersion {
|
||||
@Deprecated
|
||||
V110(110),
|
||||
@Deprecated
|
||||
V120(120),
|
||||
V150(150),
|
||||
V330(330),
|
||||
;
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.lwjgl.opengl.GL30;
|
|||
|
||||
import com.jozufozu.flywheel.backend.gl.error.GlError;
|
||||
import com.jozufozu.flywheel.backend.gl.error.GlException;
|
||||
import com.jozufozu.flywheel.util.StringUtil;
|
||||
|
||||
public class MappedGlBuffer extends GlBuffer implements Mappable {
|
||||
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class VecBuffer {
|
||||
|
||||
protected ByteBuffer internal;
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.lwjgl.opengl.GLCapabilities;
|
|||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
||||
/**
|
||||
* An instance of this class stores information about what OpenGL features are available.
|
||||
* <br>
|
||||
|
@ -19,13 +21,27 @@ public class GlCompat {
|
|||
|
||||
public final InstancedArrays instancedArrays;
|
||||
public final BufferStorage bufferStorage;
|
||||
public final boolean amd;
|
||||
|
||||
public GlCompat(GLCapabilities caps) {
|
||||
instancedArrays = getLatest(InstancedArrays.class, caps);
|
||||
bufferStorage = getLatest(BufferStorage.class, caps);
|
||||
|
||||
|
||||
if (Util.getPlatform() == Util.OS.WINDOWS) {
|
||||
String vendor = GL20C.glGetString(GL20C.GL_VENDOR);
|
||||
// vendor string I got was "ATI Technologies Inc."
|
||||
amd = vendor.contains("ATI") || vendor.contains("AMD");
|
||||
} else {
|
||||
amd = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean instancedArraysSupported() {
|
||||
public boolean onAMDWindows() {
|
||||
return amd;
|
||||
}
|
||||
|
||||
public boolean instancedArraysSupported() {
|
||||
return instancedArrays != InstancedArrays.UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.api.instance.IInstance;
|
||||
import com.jozufozu.flywheel.api.instance.ITickableInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.core.materials.FlatLit;
|
||||
import com.jozufozu.flywheel.light.LightListener;
|
||||
import com.jozufozu.flywheel.light.ImmutableBox;
|
||||
import com.jozufozu.flywheel.light.LightListener;
|
||||
import com.jozufozu.flywheel.light.LightProvider;
|
||||
import com.jozufozu.flywheel.light.ListenerStatus;
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ import java.util.Set;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.api.instance.ITickableInstance;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
||||
import com.jozufozu.flywheel.light.LightUpdater;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
|
|
@ -2,16 +2,17 @@ package com.jozufozu.flywheel.backend.instancing;
|
|||
|
||||
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
|
||||
import com.jozufozu.flywheel.api.instance.ITickableInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstanceManager;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
||||
import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine;
|
||||
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstanceManager;
|
||||
import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
|
||||
import com.jozufozu.flywheel.core.Contexts;
|
||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
|
@ -100,4 +101,14 @@ public class InstanceWorld {
|
|||
public void renderLayer(RenderLayerEvent event) {
|
||||
engine.render(event, event.buffers.bufferSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate all the necessary instances to render the given world.
|
||||
*/
|
||||
public void loadEntities(ClientLevel world) {
|
||||
// Block entities are loaded while chunks are baked.
|
||||
// Entities are loaded with the world, so when chunks are reloaded they need to be re-added.
|
||||
world.entitiesForRendering()
|
||||
.forEach(entityInstanceManager::add);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ public class InstancedRenderDispatcher {
|
|||
}
|
||||
|
||||
public static void resetInstanceWorld(ClientLevel world) {
|
||||
instanceWorlds.replace(world, InstanceWorld::delete);
|
||||
instanceWorlds.replace(world, InstanceWorld::delete)
|
||||
.loadEntities(world);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jozufozu.flywheel.api.FlywheelRendered;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
|
||||
import com.jozufozu.flywheel.backend.instancing.entity.IEntityInstanceFactory;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory;
|
||||
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||
|
@ -58,24 +58,6 @@ public class InstancedRenderRegistry {
|
|||
return new EntityConfig<>(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in 0.3.0, use {@link #tile}
|
||||
*/
|
||||
@Deprecated
|
||||
public <T extends BlockEntity> void register(BlockEntityType<? extends T> type, ITileInstanceFactory<? super T> rendererFactory) {
|
||||
this.tile(type)
|
||||
.factory(rendererFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated will be removed in 0.3.0, use {@link #entity}
|
||||
*/
|
||||
@Deprecated
|
||||
public <T extends Entity> void register(EntityType<? extends T> type, IEntityInstanceFactory<? super T> rendererFactory) {
|
||||
this.entity(type)
|
||||
.factory(rendererFactory);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends BlockEntity> TileEntityInstance<? super T> create(MaterialManager manager, T tile) {
|
||||
|
@ -110,7 +92,6 @@ public class InstancedRenderRegistry {
|
|||
|
||||
public class TileConfig<T extends BlockEntity> implements Config<TileConfig<T>, ITileInstanceFactory<? super T>> {
|
||||
|
||||
|
||||
private final BlockEntityType<T> type;
|
||||
|
||||
public TileConfig(BlockEntityType<T> type) {
|
||||
|
@ -121,14 +102,15 @@ public class InstancedRenderRegistry {
|
|||
tiles.put(type, rendererFactory);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TileConfig<T> setSkipRender(boolean skipRender) {
|
||||
InstancedRenderRegistry.this.skipRender.put(type, skipRender);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
public class EntityConfig<T extends Entity> implements Config<EntityConfig<T>, IEntityInstanceFactory<? super T>> {
|
||||
|
||||
public class EntityConfig<T extends Entity> implements Config<EntityConfig<T>, IEntityInstanceFactory<? super T>> {
|
||||
|
||||
private final EntityType<T> type;
|
||||
|
||||
|
@ -140,6 +122,7 @@ public class InstancedRenderRegistry {
|
|||
entities.put(type, rendererFactory);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EntityConfig<T> setSkipRender(boolean skipRender) {
|
||||
InstancedRenderRegistry.this.skipRender.put(type, skipRender);
|
||||
|
||||
|
|
|
@ -22,12 +22,6 @@ public class BatchedMaterialGroup implements MaterialGroup {
|
|||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material as defined by the given {@link StructType type}.
|
||||
* @param spec The material you want to create instances with.
|
||||
* @param <D> The type representing the per instance data.
|
||||
* @return A
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <D extends InstanceData> BatchedMaterial<D> material(StructType<D> spec) {
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.EnumMap;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.Engine;
|
||||
import com.jozufozu.flywheel.api.MaterialGroup;
|
||||
import com.jozufozu.flywheel.backend.RenderLayer;
|
||||
import com.jozufozu.flywheel.backend.instancing.Engine;
|
||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||
|
||||
import net.minecraft.client.Camera;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.batching;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.api.struct.BatchingTransformer;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.entity;
|
||||
|
||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstance;
|
||||
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.backend.instancing.tile.TileInstanceManager;
|
||||
import com.jozufozu.flywheel.api.MaterialManager;
|
||||
import com.jozufozu.flywheel.light.GridAlignedBB;
|
||||
import com.jozufozu.flywheel.light.LightListener;
|
||||
import com.jozufozu.flywheel.light.MovingListener;
|
||||
import com.jozufozu.flywheel.light.LightProvider;
|
||||
import com.jozufozu.flywheel.light.MovingListener;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.jozufozu.flywheel.backend.instancing.entity;
|
||||
|
||||
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.entity.Entity;
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.jozufozu.flywheel.backend.instancing.instancing;
|
|||
import java.util.BitSet;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||
|
@ -11,11 +14,8 @@ import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType;
|
|||
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||
import com.jozufozu.flywheel.backend.gl.error.GlError;
|
||||
import com.jozufozu.flywheel.backend.instancing.AbstractInstancer;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.backend.model.IBufferedModel;
|
||||
import com.jozufozu.flywheel.backend.model.ModelAllocator;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.api.struct.StructWriter;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
import com.jozufozu.flywheel.util.AttribUtil;
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class GPUInstancer<D extends InstanceData> extends AbstractInstancer<D> {
|
|||
model = modelAllocator.alloc(modelData, arenaModel -> {
|
||||
vao.bind();
|
||||
|
||||
model.setupState();
|
||||
arenaModel.setupState();
|
||||
});
|
||||
|
||||
vao.bind();
|
||||
|
|
|
@ -5,12 +5,15 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.jozufozu.flywheel.backend.RenderWork;
|
||||
import com.jozufozu.flywheel.api.InstanceData;
|
||||
import com.jozufozu.flywheel.api.Instancer;
|
||||
import com.jozufozu.flywheel.api.Material;
|
||||
import com.jozufozu.flywheel.backend.model.ModelPool;
|
||||
import com.jozufozu.flywheel.api.struct.StructType;
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.backend.RenderWork;
|
||||
import com.jozufozu.flywheel.backend.model.ImmediateAllocator;
|
||||
import com.jozufozu.flywheel.backend.model.ModelAllocator;
|
||||
import com.jozufozu.flywheel.backend.model.ModelPool;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
|
||||
|
@ -20,14 +23,18 @@ import com.jozufozu.flywheel.core.model.Model;
|
|||
*/
|
||||
public class InstancedMaterial<D extends InstanceData> implements Material<D> {
|
||||
|
||||
final ModelPool modelPool;
|
||||
final ModelAllocator allocator;
|
||||
protected final Cache<Object, GPUInstancer<D>> models;
|
||||
protected final StructType<D> type;
|
||||
|
||||
public InstancedMaterial(StructType<D> spec) {
|
||||
this.type = spec;
|
||||
|
||||
modelPool = new ModelPool(Formats.UNLIT_MODEL, 64);
|
||||
if (Backend.getInstance().compat.onAMDWindows()) {
|
||||
allocator = ImmediateAllocator.INSTANCE;
|
||||
} else {
|
||||
allocator = new ModelPool(Formats.UNLIT_MODEL, 64);
|
||||
}
|
||||
this.models = CacheBuilder.newBuilder()
|
||||
.removalListener(notification -> {
|
||||
GPUInstancer<?> instancer = (GPUInstancer<?>) notification.getValue();
|
||||
|
@ -46,7 +53,7 @@ public class InstancedMaterial<D extends InstanceData> implements Material<D> {
|
|||
@Override
|
||||
public Instancer<D> model(Object key, Supplier<Model> modelSupplier) {
|
||||
try {
|
||||
return models.get(key, () -> new GPUInstancer<>(type, modelSupplier.get(), modelPool));
|
||||
return models.get(key, () -> new GPUInstancer<>(type, modelSupplier.get(), allocator));
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException("error creating instancer", e);
|
||||
}
|
||||
|
@ -61,7 +68,7 @@ public class InstancedMaterial<D extends InstanceData> implements Material<D> {
|
|||
|
||||
public void delete() {
|
||||
models.invalidateAll();
|
||||
modelPool.delete();
|
||||
if (allocator instanceof ModelPool pool) pool.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<P extends WorldProgram> implements MaterialG
|
|||
protected final InstancingEngine<P> owner;
|
||||
protected final RenderType type;
|
||||
|
||||
protected final ArrayList<InstancedMaterialRenderer<P>> renderers = new ArrayList<>();
|
||||
|
||||
private final Map<StructType<? extends InstanceData>, InstancedMaterial<?>> materials = new HashMap<>();
|
||||
|
||||
public InstancedMaterialGroup(InstancingEngine<P> owner, RenderType type) {
|
||||
|
@ -33,27 +32,48 @@ public class InstancedMaterialGroup<P extends WorldProgram> 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 <D> The type representing the per instance data.
|
||||
* @return A
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <D extends InstanceData> InstancedMaterial<D> material(StructType<D> spec) {
|
||||
return (InstancedMaterial<D>) materials.computeIfAbsent(spec, this::createInstanceMaterial);
|
||||
return (InstancedMaterial<D>) materials.computeIfAbsent(spec, InstancedMaterial::new);
|
||||
}
|
||||
|
||||
public void render(Matrix4f viewProjection, double camX, double camY, double camZ) {
|
||||
type.setupRenderState();
|
||||
TextureBinder.bindActiveTextures();
|
||||
for (InstancedMaterialRenderer<P> 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<StructType<? extends InstanceData>, 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<P extends WorldProgram> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<P extends WorldProgram> {
|
||||
|
||||
protected final Supplier<P> program;
|
||||
protected final InstancedMaterial<?> material;
|
||||
|
||||
protected final Consumer<P> setupFunc;
|
||||
|
||||
public InstancedMaterialRenderer(Supplier<P> programSupplier, InstancedMaterial<?> material, Consumer<P> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<P extends CrumblingProgram> extends InstancedMateria
|
|||
RenderSystem.setShaderTexture(4, breakingTex);
|
||||
|
||||
TextureBinder.bindActiveTextures();
|
||||
for (InstancedMaterialRenderer<P> renderer : renderers) {
|
||||
renderer.render(viewProjection, camX, camY, camZ);
|
||||
}
|
||||
renderAll(viewProjection, camX, camY, camZ);
|
||||
|
||||
CrumblingRenderer._currentLayer.clearRenderState();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,5 +9,5 @@ import net.minecraft.client.Minecraft;
|
|||
public interface PausedPartialTickAccessor {
|
||||
|
||||
@Accessor("pausePartialTick")
|
||||
float getPausePartialTick();
|
||||
float flywheel$getPartialTicksPaused();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<T extends BlockEntity & LidBlockEntity> 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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -8,21 +8,21 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
/**
|
||||
* TODO:
|
||||
* <table>
|
||||
* <tr><td>{@link TileEntityType#SIGN}</td><td> {@link net.minecraft.client.renderer.tileentity.SignTileEntityRenderer SignTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#PISTON}</td><td> {@link net.minecraft.client.renderer.tileentity.PistonTileEntityRenderer PistonTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#CONDUIT}</td><td> {@link net.minecraft.client.renderer.tileentity.ConduitTileEntityRenderer ConduitTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#ENCHANTING_TABLE}</td><td> {@link net.minecraft.client.renderer.tileentity.EnchantmentTableTileEntityRenderer EnchantmentTableTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#LECTERN}</td><td> {@link net.minecraft.client.renderer.tileentity.LecternTileEntityRenderer LecternTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#MOB_SPAWNER}</td><td> {@link net.minecraft.client.renderer.tileentity.MobSpawnerTileEntityRenderer MobSpawnerTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BED}</td><td> {@link net.minecraft.client.renderer.tileentity.BedTileEntityRenderer BedTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#SIGN}</td><td> {@link net.minecraft.client.renderer.blockentity.SignRenderer SignRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#PISTON}</td><td> {@link net.minecraft.client.renderer.blockentity.PistonHeadRenderer PistonHeadRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#CONDUIT}</td><td> {@link net.minecraft.client.renderer.blockentity.ConduitRenderer ConduitRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#ENCHANTING_TABLE}</td><td> {@link net.minecraft.client.renderer.blockentity.EnchantTableRenderer EnchantTableRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#LECTERN}</td><td> {@link net.minecraft.client.renderer.blockentity.LecternRenderer LecternRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#MOB_SPAWNER}</td><td> {@link net.minecraft.client.renderer.blockentity.SpawnerRenderer SpawnerRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#BED}</td><td> {@link net.minecraft.client.renderer.blockentity.BedRenderer BedRenderer}</td></tr>
|
||||
* <tr><td>^^ Interesting - Major vv</td></tr>
|
||||
* <tr><td>{@link TileEntityType#END_PORTAL}</td><td> {@link net.minecraft.client.renderer.tileentity.EndPortalTileEntityRenderer EndPortalTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#END_GATEWAY}</td><td> {@link net.minecraft.client.renderer.tileentity.EndGatewayTileEntityRenderer EndGatewayTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BEACON}</td><td> {@link net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer BeaconTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#SKULL}</td><td> {@link net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer SkullTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#BANNER}</td><td> {@link net.minecraft.client.renderer.tileentity.BannerTileEntityRenderer BannerTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#STRUCTURE_BLOCK}</td><td> {@link net.minecraft.client.renderer.tileentity.StructureTileEntityRenderer StructureTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link TileEntityType#CAMPFIRE}</td><td> {@link net.minecraft.client.renderer.tileentity.CampfireTileEntityRenderer CampfireTileEntityRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#END_PORTAL}</td><td> {@link net.minecraft.client.renderer.blockentity.TheEndPortalRenderer TheEndPortalRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#END_GATEWAY}</td><td> {@link net.minecraft.client.renderer.blockentity.TheEndGatewayRenderer TheEndGatewayRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#BEACON}</td><td> {@link net.minecraft.client.renderer.blockentity.BeaconRenderer BeaconRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#SKULL}</td><td> {@link net.minecraft.client.renderer.blockentity.SkullBlockRenderer SkullBlockRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#BANNER}</td><td> {@link net.minecraft.client.renderer.blockentity.BannerRenderer BannerRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#STRUCTURE_BLOCK}</td><td> {@link net.minecraft.client.renderer.debug.StructureRenderer StructureRenderer}</td></tr>
|
||||
* <tr><td>{@link BlockEntityType#CAMPFIRE}</td><td> {@link net.minecraft.client.renderer.blockentity.CampfireRenderer CampfireRenderer}</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
public class VanillaInstances {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue