mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-16 16:11:37 +01:00
Move away from a static backend class, add a registration event
This commit is contained in:
parent
457fff78f3
commit
d47f898c76
89 changed files with 487 additions and 340 deletions
|
@ -11,18 +11,13 @@ import org.apache.logging.log4j.Logger;
|
||||||
import org.lwjgl.opengl.GL;
|
import org.lwjgl.opengl.GL;
|
||||||
import org.lwjgl.opengl.GLCapabilities;
|
import org.lwjgl.opengl.GLCapabilities;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.IReloadableResourceManager;
|
|
||||||
import net.minecraft.resources.IResourceManager;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
@ -31,33 +26,47 @@ import net.minecraft.world.World;
|
||||||
public class Backend {
|
public class Backend {
|
||||||
public static final Logger log = LogManager.getLogger(Backend.class);
|
public static final Logger log = LogManager.getLogger(Backend.class);
|
||||||
|
|
||||||
public static final ShaderSources SHADER_SOURCES = new ShaderSources();
|
private static final Backend INSTANCE = new Backend();
|
||||||
|
|
||||||
public static GLCapabilities capabilities;
|
public static Backend getInstance() {
|
||||||
public static GlCompat compat;
|
return INSTANCE;
|
||||||
|
|
||||||
private static Matrix4f projectionMatrix = new Matrix4f();
|
|
||||||
private static boolean instancedArrays;
|
|
||||||
private static boolean enabled;
|
|
||||||
|
|
||||||
static final Map<ResourceLocation, MaterialSpec<?>> materialRegistry = new HashMap<>();
|
|
||||||
static final List<ShaderContext<?>> contexts = new ArrayList<>();
|
|
||||||
static final Map<ResourceLocation, ProgramSpec> programSpecRegistry = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
register(WorldContext.INSTANCE);
|
|
||||||
register(InstancedRenderDispatcher.CRUMBLING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final Minecraft minecraft;
|
||||||
|
public ShaderSources sources;
|
||||||
|
|
||||||
|
public GLCapabilities capabilities;
|
||||||
|
public GlCompat compat;
|
||||||
|
|
||||||
|
private Matrix4f projectionMatrix = new Matrix4f();
|
||||||
|
private boolean instancedArrays;
|
||||||
|
private boolean enabled;
|
||||||
|
|
||||||
|
private final List<IShaderContext<?>> contexts = new ArrayList<>();
|
||||||
|
private final Map<ResourceLocation, MaterialSpec<?>> materialRegistry = new HashMap<>();
|
||||||
|
private final Map<ResourceLocation, ProgramSpec> programSpecRegistry = new HashMap<>();
|
||||||
|
|
||||||
public Backend() {
|
public Backend() {
|
||||||
throw new IllegalStateException();
|
// Can be null when running datagenerators due to the unfortunate time we call this
|
||||||
|
minecraft = Minecraft.getInstance();
|
||||||
|
if (minecraft == null) return;
|
||||||
|
|
||||||
|
sources = new ShaderSources(this);
|
||||||
|
|
||||||
|
OptifineHandler.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearContexts() {
|
||||||
|
SpecMetaRegistry.clear();
|
||||||
|
contexts.forEach(IShaderContext::delete);
|
||||||
|
materialRegistry.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string describing the Flywheel backend. When there are eventually multiple backends
|
* Get a string describing the Flywheel backend. When there are eventually multiple backends
|
||||||
* (Meshlet, MDI, GL31 Draw Instanced are planned), this will name which one is in use.
|
* (Meshlet, MDI, GL31 Draw Instanced are planned), this will name which one is in use.
|
||||||
*/
|
*/
|
||||||
public static String getBackendDescriptor() {
|
public String getBackendDescriptor() {
|
||||||
if (canUseInstancing()) {
|
if (canUseInstancing()) {
|
||||||
return "GL33 Instanced Arrays";
|
return "GL33 Instanced Arrays";
|
||||||
}
|
}
|
||||||
|
@ -72,7 +81,7 @@ public class Backend {
|
||||||
/**
|
/**
|
||||||
* Register a shader program.
|
* Register a shader program.
|
||||||
*/
|
*/
|
||||||
public static ProgramSpec register(ProgramSpec spec) {
|
public ProgramSpec register(ProgramSpec spec) {
|
||||||
ResourceLocation name = spec.name;
|
ResourceLocation name = spec.name;
|
||||||
if (programSpecRegistry.containsKey(name)) {
|
if (programSpecRegistry.containsKey(name)) {
|
||||||
throw new IllegalStateException("Program spec '" + name + "' already registered.");
|
throw new IllegalStateException("Program spec '" + name + "' already registered.");
|
||||||
|
@ -84,7 +93,7 @@ public class Backend {
|
||||||
/**
|
/**
|
||||||
* Register a shader context.
|
* Register a shader context.
|
||||||
*/
|
*/
|
||||||
public static <P extends GlProgram> ShaderContext<P> register(ShaderContext<P> spec) {
|
public <C extends ShaderContext<?>> C register(C spec) {
|
||||||
contexts.add(spec);
|
contexts.add(spec);
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +101,7 @@ public class Backend {
|
||||||
/**
|
/**
|
||||||
* Register an instancing material.
|
* Register an instancing material.
|
||||||
*/
|
*/
|
||||||
public static <D extends InstanceData> MaterialSpec<D> register(MaterialSpec<D> spec) {
|
public <D extends InstanceData> MaterialSpec<D> register(MaterialSpec<D> spec) {
|
||||||
ResourceLocation name = spec.name;
|
ResourceLocation name = spec.name;
|
||||||
if (materialRegistry.containsKey(name)) {
|
if (materialRegistry.containsKey(name)) {
|
||||||
throw new IllegalStateException("Material spec '" + name + "' already registered.");
|
throw new IllegalStateException("Material spec '" + name + "' already registered.");
|
||||||
|
@ -101,52 +110,32 @@ public class Backend {
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProgramSpec getSpec(ResourceLocation name) {
|
public ProgramSpec getSpec(ResourceLocation name) {
|
||||||
return programSpecRegistry.get(name);
|
return programSpecRegistry.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean available() {
|
||||||
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
|
||||||
*/
|
|
||||||
public static boolean isFlywheelWorld(IWorld world) {
|
|
||||||
return (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) || world == Minecraft.getInstance().world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean available() {
|
|
||||||
return canUseVBOs();
|
return canUseVBOs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUseInstancing() {
|
public boolean canUseInstancing() {
|
||||||
return enabled && instancedArrays;
|
return enabled && instancedArrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUseVBOs() {
|
public boolean canUseVBOs() {
|
||||||
return enabled && gl20();
|
return enabled && gl20();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean gl33() {
|
public boolean gl33() {
|
||||||
return capabilities.OpenGL33;
|
return capabilities.OpenGL33;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean gl20() {
|
public boolean gl20() {
|
||||||
return capabilities.OpenGL20;
|
return capabilities.OpenGL20;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public void refresh() {
|
||||||
// Can be null when running datagenerators due to the unfortunate time we call this
|
OptifineHandler.refresh();
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
if (mc == null) return;
|
|
||||||
|
|
||||||
IResourceManager manager = mc.getResourceManager();
|
|
||||||
|
|
||||||
if (manager instanceof IReloadableResourceManager) {
|
|
||||||
((IReloadableResourceManager) manager).addReloadListener(SHADER_SOURCES);
|
|
||||||
}
|
|
||||||
|
|
||||||
OptifineHandler.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void refresh() {
|
|
||||||
capabilities = GL.createCapabilities();
|
capabilities = GL.createCapabilities();
|
||||||
|
|
||||||
compat = new GlCompat(capabilities);
|
compat = new GlCompat(capabilities);
|
||||||
|
@ -158,27 +147,38 @@ public class Backend {
|
||||||
enabled = AllConfigs.CLIENT.experimentalRendering.get() && !OptifineHandler.usingShaders();
|
enabled = AllConfigs.CLIENT.experimentalRendering.get() && !OptifineHandler.usingShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadWorldRenderers() {
|
public boolean canUseInstancing(World world) {
|
||||||
RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canUseInstancing(World world) {
|
|
||||||
return canUseInstancing() && isFlywheelWorld(world);
|
return canUseInstancing() && isFlywheelWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<MaterialSpec<?>> allMaterials() {
|
public Collection<MaterialSpec<?>> allMaterials() {
|
||||||
return materialRegistry.values();
|
return materialRegistry.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<ProgramSpec> allPrograms() {
|
public Collection<ProgramSpec> allPrograms() {
|
||||||
return programSpecRegistry.values();
|
return programSpecRegistry.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Matrix4f getProjectionMatrix() {
|
public Collection<IShaderContext<?>> allContexts() {
|
||||||
|
return contexts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Matrix4f getProjectionMatrix() {
|
||||||
return projectionMatrix;
|
return projectionMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProjectionMatrix(Matrix4f projectionMatrix) {
|
public void setProjectionMatrix(Matrix4f projectionMatrix) {
|
||||||
Backend.projectionMatrix = projectionMatrix;
|
this.projectionMatrix = projectionMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to avoid calling Flywheel functions on (fake) worlds that don't specifically support it.
|
||||||
|
*/
|
||||||
|
public static boolean isFlywheelWorld(IWorld world) {
|
||||||
|
return (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) || world == Minecraft.getInstance().world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reloadWorldRenderers() {
|
||||||
|
RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.jozufozu.flywheel.backend;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public interface IShaderContext<P extends GlProgram> {
|
||||||
|
|
||||||
|
P getProgram(ResourceLocation loc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all programs associated with this context. This might be just one, if the context is very specialized.
|
||||||
|
*/
|
||||||
|
void load();
|
||||||
|
|
||||||
|
void delete();
|
||||||
|
}
|
|
@ -1,14 +1,12 @@
|
||||||
package com.jozufozu.flywheel.backend;
|
package com.jozufozu.flywheel.backend;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.GlObject;
|
import com.jozufozu.flywheel.backend.gl.GlObject;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlShader;
|
import com.jozufozu.flywheel.backend.gl.shader.GlShader;
|
||||||
|
@ -21,21 +19,20 @@ import com.jozufozu.flywheel.core.shader.spec.ProgramState;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public abstract class ShaderContext<P extends GlProgram> {
|
public abstract class ShaderContext<P extends GlProgram> implements IShaderContext<P> {
|
||||||
|
|
||||||
protected final Map<ResourceLocation, IMultiProgram<P>> programs = new HashMap<>();
|
protected final Map<ResourceLocation, IMultiProgram<P>> programs = new HashMap<>();
|
||||||
|
|
||||||
protected ShaderSources sourceRepo;
|
public final Backend backend;
|
||||||
|
|
||||||
/**
|
public ShaderContext(Backend backend) {
|
||||||
* Load all programs associated with this context. This might be just one, if the context is very specialized.
|
this.backend = backend;
|
||||||
*/
|
|
||||||
public final void load(ShaderSources loader) {
|
|
||||||
this.sourceRepo = loader;
|
|
||||||
load();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void load();
|
@Override
|
||||||
|
public P getProgram(ResourceLocation spec) {
|
||||||
|
return programs.get(spec).get();
|
||||||
|
}
|
||||||
|
|
||||||
public Program loadAndLink(ProgramSpec spec, @Nullable ProgramState state) {
|
public Program loadAndLink(ProgramSpec spec, @Nullable ProgramState state) {
|
||||||
Shader vertexFile = getSource(ShaderType.VERTEX, spec.vert);
|
Shader vertexFile = getSource(ShaderType.VERTEX, spec.vert);
|
||||||
|
@ -46,23 +43,20 @@ public abstract class ShaderContext<P extends GlProgram> {
|
||||||
fragmentFile.defineAll(state.getDefines());
|
fragmentFile.defineAll(state.getDefines());
|
||||||
}
|
}
|
||||||
|
|
||||||
return link(loadProgram(spec.name, vertexFile, fragmentFile));
|
return link(buildProgram(spec.name, vertexFile, fragmentFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Shader getSource(ShaderType type, ResourceLocation name) {
|
protected Shader getSource(ShaderType type, ResourceLocation name) {
|
||||||
return sourceRepo.source(name, type);
|
return backend.sources.source(name, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Program link(Program program) {
|
protected Program link(Program program) {
|
||||||
return program.link();
|
return program.link();
|
||||||
}
|
}
|
||||||
|
|
||||||
public P getProgram(ResourceLocation spec) {
|
@Override
|
||||||
return programs.get(spec).get();
|
public void delete() {
|
||||||
}
|
programs.values().forEach(IMultiProgram::delete);
|
||||||
|
|
||||||
protected Program loadProgram(ResourceLocation name, Shader... shaders) {
|
|
||||||
return loadProgram(name, Lists.newArrayList(shaders));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,8 +66,8 @@ public abstract class ShaderContext<P extends GlProgram> {
|
||||||
* @param shaders What are the different shader stages that should be linked together?
|
* @param shaders What are the different shader stages that should be linked together?
|
||||||
* @return A program with all provided shaders attached
|
* @return A program with all provided shaders attached
|
||||||
*/
|
*/
|
||||||
protected Program loadProgram(ResourceLocation name, Collection<Shader> shaders) {
|
protected static Program buildProgram(ResourceLocation name, Shader... shaders) {
|
||||||
List<GlShader> compiled = new ArrayList<>(shaders.size());
|
List<GlShader> compiled = new ArrayList<>(shaders.length);
|
||||||
try {
|
try {
|
||||||
Program builder = new Program(name);
|
Program builder = new Program(name);
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,17 @@ import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||||
import com.jozufozu.flywheel.backend.loading.Shader;
|
import com.jozufozu.flywheel.backend.loading.Shader;
|
||||||
import com.jozufozu.flywheel.backend.loading.ShaderLoadingException;
|
import com.jozufozu.flywheel.backend.loading.ShaderLoadingException;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.mojang.datafixers.util.Pair;
|
import com.mojang.datafixers.util.Pair;
|
||||||
import com.mojang.serialization.DataResult;
|
import com.mojang.serialization.DataResult;
|
||||||
import com.mojang.serialization.JsonOps;
|
import com.mojang.serialization.JsonOps;
|
||||||
|
|
||||||
|
import net.minecraft.resources.IReloadableResourceManager;
|
||||||
import net.minecraft.resources.IResource;
|
import net.minecraft.resources.IResource;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.resources.IResourceManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fml.ModLoader;
|
||||||
import net.minecraftforge.resource.IResourceType;
|
import net.minecraftforge.resource.IResourceType;
|
||||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||||
import net.minecraftforge.resource.VanillaResourceType;
|
import net.minecraftforge.resource.VanillaResourceType;
|
||||||
|
@ -47,31 +49,39 @@ public class ShaderSources implements ISelectiveResourceReloadListener {
|
||||||
public static final String SHADER_DIR = "flywheel/shaders/";
|
public static final String SHADER_DIR = "flywheel/shaders/";
|
||||||
public static final String PROGRAM_DIR = "flywheel/programs/";
|
public static final String PROGRAM_DIR = "flywheel/programs/";
|
||||||
public static final ArrayList<String> EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl");
|
public static final ArrayList<String> EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl");
|
||||||
|
private static final Gson GSON = new GsonBuilder().create();
|
||||||
|
|
||||||
private final Map<ResourceLocation, String> shaderSource = new HashMap<>();
|
private final Map<ResourceLocation, String> shaderSource = new HashMap<>();
|
||||||
|
|
||||||
private boolean shouldCrash;
|
private boolean shouldCrash;
|
||||||
private final Gson gson = new GsonBuilder().create();
|
private final Backend backend;
|
||||||
|
|
||||||
|
public ShaderSources(Backend backend) {
|
||||||
|
this.backend = backend;
|
||||||
|
IResourceManager manager = backend.minecraft.getResourceManager();
|
||||||
|
if (manager instanceof IReloadableResourceManager) {
|
||||||
|
((IReloadableResourceManager) manager).addReloadListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
||||||
if (predicate.test(VanillaResourceType.SHADERS)) {
|
if (predicate.test(VanillaResourceType.SHADERS)) {
|
||||||
OptifineHandler.refresh();
|
backend.refresh();
|
||||||
Backend.refresh();
|
|
||||||
|
|
||||||
if (Backend.gl20()) {
|
if (backend.gl20()) {
|
||||||
shaderSource.clear();
|
shaderSource.clear();
|
||||||
|
|
||||||
shouldCrash = false;
|
shouldCrash = false;
|
||||||
|
|
||||||
SpecMetaRegistry.init();
|
backend.clearContexts();
|
||||||
|
ModLoader.get().postEvent(new GatherContextEvent(backend));
|
||||||
|
|
||||||
loadProgramSpecs(manager);
|
loadProgramSpecs(manager);
|
||||||
|
|
||||||
loadShaderSources(manager);
|
loadShaderSources(manager);
|
||||||
|
|
||||||
for (ShaderContext<?> context : Backend.contexts) {
|
for (IShaderContext<?> context : backend.allContexts()) {
|
||||||
context.load(this);
|
context.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldCrash) {
|
if (shouldCrash) {
|
||||||
|
@ -97,13 +107,13 @@ public class ShaderSources implements ISelectiveResourceReloadListener {
|
||||||
|
|
||||||
ResourceLocation specName = ResourceUtil.trim(location, PROGRAM_DIR, ".json");
|
ResourceLocation specName = ResourceUtil.trim(location, PROGRAM_DIR, ".json");
|
||||||
|
|
||||||
DataResult<Pair<ProgramSpec, JsonElement>> result = ProgramSpec.CODEC.decode(JsonOps.INSTANCE, gson.fromJson(s, JsonElement.class));
|
DataResult<Pair<ProgramSpec, JsonElement>> result = ProgramSpec.CODEC.decode(JsonOps.INSTANCE, GSON.fromJson(s, JsonElement.class));
|
||||||
|
|
||||||
ProgramSpec spec = result.get().orThrow().getFirst();
|
ProgramSpec spec = result.get().orThrow().getFirst();
|
||||||
|
|
||||||
spec.setName(specName);
|
spec.setName(specName);
|
||||||
|
|
||||||
Backend.register(spec);
|
backend.register(spec);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Backend.log.error(e);
|
Backend.log.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
package com.jozufozu.flywheel.core.shader.spec;
|
package com.jozufozu.flywheel.backend;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldFog;
|
|
||||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.FogStateProvider;
|
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
import com.jozufozu.flywheel.core.shader.gamestate.IGameStateProvider;
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.NormalDebugStateProvider;
|
|
||||||
import com.jozufozu.flywheel.core.shader.gamestate.RainbowDebugStateProvider;
|
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
@ -17,18 +13,9 @@ public class SpecMetaRegistry {
|
||||||
private static final Map<ResourceLocation, IProgramExtension> registeredExtensions = new HashMap<>();
|
private static final Map<ResourceLocation, IProgramExtension> registeredExtensions = new HashMap<>();
|
||||||
private static final Map<ResourceLocation, IGameStateProvider> registeredStateProviders = new HashMap<>();
|
private static final Map<ResourceLocation, IGameStateProvider> registeredStateProviders = new HashMap<>();
|
||||||
|
|
||||||
// TODO: proper registration, don't call this from ShaderLoader
|
static void clear() {
|
||||||
private static boolean initialized = false;
|
registeredExtensions.clear();
|
||||||
public static void init() {
|
registeredStateProviders.clear();
|
||||||
if (initialized) return;
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
register(FogStateProvider.INSTANCE);
|
|
||||||
register(RainbowDebugStateProvider.INSTANCE);
|
|
||||||
register(NormalDebugStateProvider.INSTANCE);
|
|
||||||
|
|
||||||
register(WorldFog.LINEAR);
|
|
||||||
register(WorldFog.EXP2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IGameStateProvider getStateProvider(ResourceLocation location) {
|
public static IGameStateProvider getStateProvider(ResourceLocation location) {
|
|
@ -4,18 +4,18 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
|
||||||
public class GlVertexArray extends GlObject {
|
public class GlVertexArray extends GlObject {
|
||||||
public GlVertexArray() {
|
public GlVertexArray() {
|
||||||
setHandle(Backend.compat.vao.genVertexArrays());
|
setHandle(Backend.getInstance().compat.vao.genVertexArrays());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
Backend.compat.vao.bindVertexArray(handle());
|
Backend.getInstance().compat.vao.bindVertexArray(handle());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
Backend.compat.vao.bindVertexArray(0);
|
Backend.getInstance().compat.vao.bindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteInternal(int handle) {
|
protected void deleteInternal(int handle) {
|
||||||
Backend.compat.vao.deleteVertexArrays(handle);
|
Backend.getInstance().compat.vao.deleteVertexArrays(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class GlBuffer extends GlObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappedBuffer getBuffer(int offset, int length) {
|
public MappedBuffer getBuffer(int offset, int length) {
|
||||||
if (Backend.compat.mapBufferRange != MapBufferRange.UNSUPPORTED) {
|
if (Backend.getInstance().compat.mapBufferRange != MapBufferRange.UNSUPPORTED) {
|
||||||
return new MappedBufferRange(this, offset, length, GL30.GL_MAP_WRITE_BIT);
|
return new MappedBufferRange(this, offset, length, GL30.GL_MAP_WRITE_BIT);
|
||||||
} else {
|
} else {
|
||||||
MappedFullBuffer fullBuffer = new MappedFullBuffer(this, MappedBufferUsage.WRITE_ONLY);
|
MappedFullBuffer fullBuffer = new MappedFullBuffer(this, MappedBufferUsage.WRITE_ONLY);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class MappedBufferRange extends MappedBuffer {
|
||||||
@Override
|
@Override
|
||||||
protected void checkAndMap() {
|
protected void checkAndMap() {
|
||||||
if (!mapped) {
|
if (!mapped) {
|
||||||
setInternal(Backend.compat.mapBufferRange.mapBuffer(owner.type, offset, length, access));
|
setInternal(Backend.getInstance().compat.mapBufferRange.mapBuffer(owner.type, offset, length, access));
|
||||||
mapped = true;
|
mapped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,10 @@ import com.jozufozu.flywheel.backend.gl.versioned.instancing.InstancedArrays;
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.instancing.VertexArrayObject;
|
import com.jozufozu.flywheel.backend.gl.versioned.instancing.VertexArrayObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An instance of this class stores information
|
* An instance of this class stores information about what OpenGL features are available.
|
||||||
* about what OpenGL features are available.
|
* <br>
|
||||||
* <p>
|
* Each field stores an enum variant that provides access to the most appropriate version of a feature for the current
|
||||||
* Each field stores an enum variant that provides access to the
|
* system.
|
||||||
* most appropriate version of a feature for the current system.
|
|
||||||
*/
|
*/
|
||||||
public class GlCompat {
|
public class GlCompat {
|
||||||
public final MapBufferRange mapBufferRange;
|
public final MapBufferRange mapBufferRange;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface giving {@link TileEntityInstance}s a hook to have a function called at
|
* An interface giving {@link TileEntityInstance}s a hook to have a function called at
|
||||||
* the start of a frame. By implementing {@link IDynamicInstance}, a {@link TileEntityInstance}
|
* the start of a frame. By implementing {@link IDynamicInstance}, a {@link TileEntityInstance}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface giving {@link TileEntityInstance}s a hook to have a function called at
|
* An interface giving {@link TileEntityInstance}s a hook to have a function called at
|
||||||
* the end of every tick. By implementing {@link ITickableInstance}, a {@link TileEntityInstance}
|
* the end of every tick. By implementing {@link ITickableInstance}, a {@link TileEntityInstance}
|
||||||
|
|
|
@ -12,12 +12,9 @@ import java.util.Vector;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
import com.jozufozu.flywheel.core.Contexts;
|
||||||
import com.jozufozu.flywheel.core.CrumblingInstanceManager;
|
import com.jozufozu.flywheel.core.CrumblingInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.CrumblingProgram;
|
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||||
|
@ -38,7 +35,6 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
import net.minecraft.inventory.container.PlayerContainer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.LazyValue;
|
import net.minecraft.util.LazyValue;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
@ -48,15 +44,9 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class InstancedRenderDispatcher {
|
public class InstancedRenderDispatcher {
|
||||||
|
|
||||||
public static final ResourceLocation CRUMBLING_CONTEXT = new ResourceLocation(Flywheel.ID, "context/crumbling");
|
|
||||||
public static final WorldContext<CrumblingProgram> CRUMBLING = new WorldContext<>(CrumblingProgram::new)
|
|
||||||
.withName(CRUMBLING_CONTEXT)
|
|
||||||
.withBuiltin(ShaderType.FRAGMENT, CRUMBLING_CONTEXT, "/builtin.frag")
|
|
||||||
.withBuiltin(ShaderType.VERTEX, CRUMBLING_CONTEXT, "/builtin.vert");
|
|
||||||
|
|
||||||
private static final RenderType crumblingLayer = ModelBakery.BLOCK_DESTRUCTION_RENDER_LAYERS.get(0);
|
private static final RenderType crumblingLayer = ModelBakery.BLOCK_DESTRUCTION_RENDER_LAYERS.get(0);
|
||||||
|
|
||||||
private static final WorldAttached<TileInstanceManager> tileInstanceManager = new WorldAttached<>(world -> new TileInstanceManager(WorldContext.INSTANCE.getMaterialManager(world)));
|
private static final WorldAttached<TileInstanceManager> tileInstanceManager = new WorldAttached<>(world -> new TileInstanceManager(Contexts.WORLD.getMaterialManager(world)));
|
||||||
private static final LazyValue<Vector<CrumblingInstanceManager>> blockBreaking = new LazyValue<>(() -> {
|
private static final LazyValue<Vector<CrumblingInstanceManager>> blockBreaking = new LazyValue<>(() -> {
|
||||||
Vector<CrumblingInstanceManager> renderers = new Vector<>(10);
|
Vector<CrumblingInstanceManager> renderers = new Vector<>(10);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
@ -86,7 +76,7 @@ public class InstancedRenderDispatcher {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onBeginFrame(BeginFrameEvent event) {
|
public static void onBeginFrame(BeginFrameEvent event) {
|
||||||
WorldContext.INSTANCE.getMaterialManager(event.getWorld())
|
Contexts.WORLD.getMaterialManager(event.getWorld())
|
||||||
.checkAndShiftOrigin(event.getInfo());
|
.checkAndShiftOrigin(event.getInfo());
|
||||||
get(event.getWorld())
|
get(event.getWorld())
|
||||||
.beginFrame(event.getInfo());
|
.beginFrame(event.getInfo());
|
||||||
|
@ -95,8 +85,8 @@ public class InstancedRenderDispatcher {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void renderLayer(RenderLayerEvent event) {
|
public static void renderLayer(RenderLayerEvent event) {
|
||||||
ClientWorld world = event.getWorld();
|
ClientWorld world = event.getWorld();
|
||||||
if (!Backend.canUseInstancing(world)) return;
|
if (!Backend.getInstance().canUseInstancing(world)) return;
|
||||||
MaterialManager<WorldProgram> materialManager = WorldContext.INSTANCE.getMaterialManager(world);
|
MaterialManager<WorldProgram> materialManager = Contexts.WORLD.getMaterialManager(world);
|
||||||
|
|
||||||
event.type.startDrawing();
|
event.type.startDrawing();
|
||||||
|
|
||||||
|
@ -108,8 +98,8 @@ public class InstancedRenderDispatcher {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
public static void onReloadRenderers(ReloadRenderersEvent event) {
|
||||||
ClientWorld world = event.getWorld();
|
ClientWorld world = event.getWorld();
|
||||||
if (Backend.canUseInstancing() && world != null) {
|
if (Backend.getInstance().canUseInstancing() && world != null) {
|
||||||
WorldContext.INSTANCE.getMaterialManager(world).delete();
|
Contexts.WORLD.getMaterialManager(world).delete();
|
||||||
|
|
||||||
TileInstanceManager tileRenderer = get(world);
|
TileInstanceManager tileRenderer = get(world);
|
||||||
tileRenderer.invalidate();
|
tileRenderer.invalidate();
|
||||||
|
@ -118,7 +108,7 @@ public class InstancedRenderDispatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
public static void renderBreaking(ClientWorld world, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
||||||
if (!Backend.canUseInstancing(world)) return;
|
if (!Backend.getInstance().canUseInstancing(world)) return;
|
||||||
|
|
||||||
WorldRenderer worldRenderer = Minecraft.getInstance().worldRenderer;
|
WorldRenderer worldRenderer = Minecraft.getInstance().worldRenderer;
|
||||||
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = worldRenderer.blockBreakingProgressions;
|
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = worldRenderer.blockBreakingProgressions;
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.Map;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class Instancer<D extends InstanceData> {
|
||||||
instanceFormat.vertexAttribPointers(staticAttributes);
|
instanceFormat.vertexAttribPointers(staticAttributes);
|
||||||
|
|
||||||
for (int i = 0; i < instanceFormat.getAttributeCount(); i++) {
|
for (int i = 0; i < instanceFormat.getAttributeCount(); i++) {
|
||||||
Backend.compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1);
|
Backend.getInstance().compat.instancedArrays.vertexAttribDivisor(i + staticAttributes, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.core.Materials;
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
import com.jozufozu.flywheel.core.WorldContext;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.util.WeakHashSet;
|
import com.jozufozu.flywheel.util.WeakHashSet;
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
@ -34,10 +34,10 @@ public class MaterialManager<P extends WorldProgram> {
|
||||||
|
|
||||||
public MaterialManager(WorldContext<P> context) {
|
public MaterialManager(WorldContext<P> context) {
|
||||||
this.materials = new HashMap<>();
|
this.materials = new HashMap<>();
|
||||||
this.renderers = new ArrayList<>(Backend.allMaterials().size());
|
this.renderers = new ArrayList<>(Backend.getInstance().allMaterials().size());
|
||||||
this.listeners = new WeakHashSet<>();
|
this.listeners = new WeakHashSet<>();
|
||||||
|
|
||||||
for (MaterialSpec<?> spec : Backend.allMaterials()) {
|
for (MaterialSpec<?> spec : Backend.getInstance().allMaterials()) {
|
||||||
InstanceMaterial<?> material = new InstanceMaterial<>(this::getOriginCoordinate, spec);
|
InstanceMaterial<?> material = new InstanceMaterial<>(this::getOriginCoordinate, spec);
|
||||||
materials.put(spec.name, material);
|
materials.put(spec.name, material);
|
||||||
MaterialRenderer<P> renderer = new MaterialRenderer<>(context.getProgram(spec.getProgramName()), material);
|
MaterialRenderer<P> renderer = new MaterialRenderer<>(context.getProgram(spec.getProgramName()), material);
|
||||||
|
@ -89,11 +89,11 @@ public class MaterialManager<P extends WorldProgram> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceMaterial<ModelData> getTransformMaterial() {
|
public InstanceMaterial<ModelData> getTransformMaterial() {
|
||||||
return getMaterial(AllMaterialSpecs.TRANSFORMED);
|
return getMaterial(Materials.TRANSFORMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceMaterial<OrientedData> getOrientedMaterial() {
|
public InstanceMaterial<OrientedData> getOrientedMaterial() {
|
||||||
return getMaterial(AllMaterialSpecs.ORIENTED);
|
return getMaterial(Materials.ORIENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3i getOriginCoordinate() {
|
public Vector3i getOriginCoordinate() {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
|
@ -109,7 +110,7 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends TileEntity> TileEntityInstance<? super T> getInstance(T tile, boolean create) {
|
public <T extends TileEntity> TileEntityInstance<? super T> getInstance(T tile, boolean create) {
|
||||||
if (!Backend.canUseInstancing()) return null;
|
if (!Backend.getInstance().canUseInstancing()) return null;
|
||||||
|
|
||||||
TileEntityInstance<?> instance = instances.get(tile);
|
TileEntityInstance<?> instance = instances.get(tile);
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> void onLightUpdate(T tile) {
|
public <T extends TileEntity> void onLightUpdate(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
if (tile instanceof IInstanceRendered) {
|
if (tile instanceof IInstanceRendered) {
|
||||||
TileEntityInstance<? super T> instance = getInstance(tile, false);
|
TileEntityInstance<? super T> instance = getInstance(tile, false);
|
||||||
|
@ -134,7 +135,7 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> void add(T tile) {
|
public <T extends TileEntity> void add(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
if (tile instanceof IInstanceRendered) {
|
if (tile instanceof IInstanceRendered) {
|
||||||
addInternal(tile);
|
addInternal(tile);
|
||||||
|
@ -142,7 +143,7 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> void update(T tile) {
|
public <T extends TileEntity> void update(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
if (tile instanceof IInstanceRendered) {
|
if (tile instanceof IInstanceRendered) {
|
||||||
TileEntityInstance<? super T> instance = getInstance(tile, false);
|
TileEntityInstance<? super T> instance = getInstance(tile, false);
|
||||||
|
@ -161,7 +162,7 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends TileEntity> void remove(T tile) {
|
public <T extends TileEntity> void remove(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
if (tile instanceof IInstanceRendered) {
|
if (tile instanceof IInstanceRendered) {
|
||||||
removeInternal(tile);
|
removeInternal(tile);
|
||||||
|
@ -169,13 +170,13 @@ public class TileInstanceManager implements MaterialManager.OriginShiftListener
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized <T extends TileEntity> void queueAdd(T tile) {
|
public synchronized <T extends TileEntity> void queueAdd(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
queuedAdditions.add(tile);
|
queuedAdditions.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized <T extends TileEntity> void queueUpdate(T tile) {
|
public synchronized <T extends TileEntity> void queueUpdate(T tile) {
|
||||||
if (!Backend.canUseInstancing()) return;
|
if (!Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
queuedUpdates.add(tile);
|
queuedUpdates.add(tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing.tile;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing.tile;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.materials.IFlatLight;
|
import com.jozufozu.flywheel.core.materials.IFlatLight;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
|
@ -75,7 +75,7 @@ public class BufferedModel {
|
||||||
public void drawInstances(int instanceCount) {
|
public void drawInstances(int instanceCount) {
|
||||||
if (!valid()) return;
|
if (!valid()) return;
|
||||||
|
|
||||||
Backend.compat.drawInstanced.drawArraysInstanced(primitiveMode, 0, vertexCount, instanceCount);
|
Backend.getInstance().compat.drawInstanced.drawArraysInstanced(primitiveMode, 0, vertexCount, instanceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class IndexedModel extends BufferedModel {
|
||||||
public void drawInstances(int instanceCount) {
|
public void drawInstances(int instanceCount) {
|
||||||
if (vertexCount <= 0 || deleted) return;
|
if (vertexCount <= 0 || deleted) return;
|
||||||
|
|
||||||
Backend.compat.drawInstanced.drawElementsInstanced(primitiveMode, ebo.elementCount, ebo.eboIndexType, 0, instanceCount);
|
Backend.getInstance().compat.drawInstanced.drawElementsInstanced(primitiveMode, ebo.elementCount, ebo.eboIndexType, 0, instanceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
48
src/main/java/com/jozufozu/flywheel/core/Contexts.java
Normal file
48
src/main/java/com/jozufozu/flywheel/core/Contexts.java
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||||
|
import com.jozufozu.flywheel.core.shader.WorldFog;
|
||||||
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
|
import com.jozufozu.flywheel.core.shader.gamestate.FogStateProvider;
|
||||||
|
import com.jozufozu.flywheel.core.shader.gamestate.NormalDebugStateProvider;
|
||||||
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class Contexts {
|
||||||
|
|
||||||
|
public static WorldContext<WorldProgram> WORLD;
|
||||||
|
public static WorldContext<CrumblingProgram> CRUMBLING;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void flwInit(GatherContextEvent event) {
|
||||||
|
Backend backend = event.getBackend();
|
||||||
|
|
||||||
|
SpecMetaRegistry.register(FogStateProvider.INSTANCE);
|
||||||
|
SpecMetaRegistry.register(NormalDebugStateProvider.INSTANCE);
|
||||||
|
|
||||||
|
SpecMetaRegistry.register(WorldFog.LINEAR);
|
||||||
|
SpecMetaRegistry.register(WorldFog.EXP2);
|
||||||
|
|
||||||
|
CRUMBLING = backend.register(new WorldContext<>(backend, CrumblingProgram::new)
|
||||||
|
.withName(Names.CRUMBLING)
|
||||||
|
.withBuiltin(ShaderType.FRAGMENT, Names.CRUMBLING, "/builtin.frag")
|
||||||
|
.withBuiltin(ShaderType.VERTEX, Names.CRUMBLING, "/builtin.vert"));
|
||||||
|
|
||||||
|
WORLD = backend.register(new WorldContext<>(backend, WorldProgram::new)
|
||||||
|
.withName(Names.WORLD)
|
||||||
|
.withBuiltin(ShaderType.FRAGMENT, Names.WORLD, "/builtin.frag")
|
||||||
|
.withBuiltin(ShaderType.VERTEX, Names.WORLD, "/builtin.vert"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Names {
|
||||||
|
public static final ResourceLocation CRUMBLING = new ResourceLocation(Flywheel.ID, "context/crumbling");
|
||||||
|
public static final ResourceLocation WORLD = new ResourceLocation(Flywheel.ID, "context/world");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package com.jozufozu.flywheel.core;
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
|
|
||||||
|
@ -8,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class CrumblingInstanceManager extends TileInstanceManager {
|
public class CrumblingInstanceManager extends TileInstanceManager {
|
||||||
public CrumblingInstanceManager() {
|
public CrumblingInstanceManager() {
|
||||||
super(new MaterialManager<>(InstancedRenderDispatcher.CRUMBLING));
|
super(new MaterialManager<>(Contexts.CRUMBLING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
24
src/main/java/com/jozufozu/flywheel/core/Formats.java
Normal file
24
src/main/java/com/jozufozu/flywheel/core/Formats.java
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.attrib.MatrixAttributes;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||||
|
|
||||||
|
public class Formats {
|
||||||
|
public static final VertexFormat UNLIT_MODEL = VertexFormat.builder()
|
||||||
|
.addAttributes(CommonAttributes.VEC3, CommonAttributes.NORMAL, CommonAttributes.UV)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static final VertexFormat TRANSFORMED = litInstance()
|
||||||
|
.addAttributes(MatrixAttributes.MAT4,
|
||||||
|
MatrixAttributes.MAT3)
|
||||||
|
.build();
|
||||||
|
public static final VertexFormat ORIENTED = litInstance()
|
||||||
|
.addAttributes(CommonAttributes.VEC3, CommonAttributes.VEC3, CommonAttributes.QUATERNION)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
public static VertexFormat.Builder litInstance() {
|
||||||
|
return VertexFormat.builder()
|
||||||
|
.addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA);
|
||||||
|
}
|
||||||
|
}
|
34
src/main/java/com/jozufozu/flywheel/core/Materials.java
Normal file
34
src/main/java/com/jozufozu/flywheel/core/Materials.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||||
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class Materials {
|
||||||
|
public static final MaterialSpec<OrientedData> ORIENTED = AllMaterialSpecs.register(new MaterialSpec<>(Locations.ORIENTED, Programs.ORIENTED, Formats.UNLIT_MODEL, Formats.ORIENTED, OrientedData::new));
|
||||||
|
public static final MaterialSpec<ModelData> TRANSFORMED = AllMaterialSpecs.register(new MaterialSpec<>(Locations.MODEL, Programs.TRANSFORMED, Formats.UNLIT_MODEL, Formats.TRANSFORMED, ModelData::new));
|
||||||
|
|
||||||
|
public static <D extends InstanceData> MaterialSpec<D> register(MaterialSpec<D> spec) {
|
||||||
|
return Backend.getInstance().register(spec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void flwInit(GatherContextEvent event) {
|
||||||
|
register(ORIENTED);
|
||||||
|
register(TRANSFORMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Locations {
|
||||||
|
public static final ResourceLocation MODEL = new ResourceLocation("create", "model");
|
||||||
|
public static final ResourceLocation ORIENTED = new ResourceLocation("create", "oriented");
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/com/jozufozu/flywheel/core/Programs.java
Normal file
10
src/main/java/com/jozufozu/flywheel/core/Programs.java
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.Flywheel;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class Programs {
|
||||||
|
public static final ResourceLocation TRANSFORMED = new ResourceLocation(Flywheel.ID, "model");
|
||||||
|
public static final ResourceLocation ORIENTED = new ResourceLocation(Flywheel.ID, "oriented");
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.ResourceUtil;
|
import com.jozufozu.flywheel.backend.ResourceUtil;
|
||||||
import com.jozufozu.flywheel.backend.ShaderContext;
|
import com.jozufozu.flywheel.backend.ShaderContext;
|
||||||
|
@ -35,13 +34,6 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
private static final String declaration = "#flwbuiltins";
|
private static final String declaration = "#flwbuiltins";
|
||||||
private static final Pattern builtinPattern = Pattern.compile(declaration);
|
private static final Pattern builtinPattern = Pattern.compile(declaration);
|
||||||
|
|
||||||
public static final ResourceLocation WORLD_CONTEXT = new ResourceLocation(Flywheel.ID, "context/world");
|
|
||||||
|
|
||||||
public static final WorldContext<WorldProgram> INSTANCE = new WorldContext<>(WorldProgram::new)
|
|
||||||
.withName(WORLD_CONTEXT)
|
|
||||||
.withBuiltin(ShaderType.FRAGMENT, WORLD_CONTEXT, "/builtin.frag")
|
|
||||||
.withBuiltin(ShaderType.VERTEX, WORLD_CONTEXT, "/builtin.vert");
|
|
||||||
|
|
||||||
protected ResourceLocation name;
|
protected ResourceLocation name;
|
||||||
protected Supplier<Stream<ResourceLocation>> specStream;
|
protected Supplier<Stream<ResourceLocation>> specStream;
|
||||||
protected TemplateFactory templateFactory;
|
protected TemplateFactory templateFactory;
|
||||||
|
@ -53,10 +45,11 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
|
|
||||||
private final ExtensibleGlProgram.Factory<P> factory;
|
private final ExtensibleGlProgram.Factory<P> factory;
|
||||||
|
|
||||||
public WorldContext(ExtensibleGlProgram.Factory<P> factory) {
|
public WorldContext(Backend backend, ExtensibleGlProgram.Factory<P> factory) {
|
||||||
|
super(backend);
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
|
|
||||||
specStream = () -> Backend.allMaterials()
|
specStream = () -> backend.allMaterials()
|
||||||
.stream()
|
.stream()
|
||||||
.map(MaterialSpec::getProgramName);
|
.map(MaterialSpec::getProgramName);
|
||||||
|
|
||||||
|
@ -102,16 +95,16 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
Backend.log.info("Loading context '{}'", name);
|
Backend.log.info("Loading context '{}'", name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
builtins.forEach((type, resourceLocation) -> builtinSources.put(type, sourceRepo.getShaderSource(resourceLocation)));
|
builtins.forEach((type, resourceLocation) -> builtinSources.put(type, backend.sources.getShaderSource(resourceLocation)));
|
||||||
} catch (ShaderLoadingException e) {
|
} catch (ShaderLoadingException e) {
|
||||||
sourceRepo.notifyError();
|
backend.sources.notifyError();
|
||||||
|
|
||||||
Backend.log.error(String.format("Could not find builtin: %s", e.getMessage()));
|
Backend.log.error(String.format("Could not find builtin: %s", e.getMessage()));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
template = templateFactory.create(sourceRepo);
|
template = templateFactory.create(backend.sources);
|
||||||
transformer = new ShaderTransformer()
|
transformer = new ShaderTransformer()
|
||||||
.pushStage(this::injectBuiltins)
|
.pushStage(this::injectBuiltins)
|
||||||
.pushStage(Shader::processIncludes)
|
.pushStage(Shader::processIncludes)
|
||||||
|
@ -119,7 +112,7 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
.pushStage(Shader::processIncludes);
|
.pushStage(Shader::processIncludes);
|
||||||
|
|
||||||
specStream.get()
|
specStream.get()
|
||||||
.map(Backend::getSpec)
|
.map(backend::getSpec)
|
||||||
.forEach(spec -> {
|
.forEach(spec -> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -128,11 +121,18 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
Backend.log.debug("Loaded program {}", spec.name);
|
Backend.log.debug("Loaded program {}", spec.name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Backend.log.error("Program '{}': {}", spec.name, e);
|
Backend.log.error("Program '{}': {}", spec.name, e);
|
||||||
sourceRepo.notifyError();
|
backend.sources.notifyError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete() {
|
||||||
|
super.delete();
|
||||||
|
|
||||||
|
materialManager.forEach(MaterialManager::delete);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Shader getSource(ShaderType type, ResourceLocation name) {
|
protected Shader getSource(ShaderType type, ResourceLocation name) {
|
||||||
Shader source = super.getSource(type, name);
|
Shader source = super.getSource(type, name);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.jozufozu.flywheel.core.shader.extension;
|
package com.jozufozu.flywheel.core.shader.extension;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.jozufozu.flywheel.core.shader.gamestate;
|
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.core.shader.spec.SpecMetaRegistry;
|
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class ForgeEvents {
|
||||||
|
|
||||||
ArrayList<String> right = event.getRight();
|
ArrayList<String> right = event.getRight();
|
||||||
|
|
||||||
String text = "Flywheel: " + Backend.getBackendDescriptor();
|
String text = "Flywheel: " + Backend.getInstance().getBackendDescriptor();
|
||||||
if (right.size() < 10) {
|
if (right.size() < 10) {
|
||||||
right.add("");
|
right.add("");
|
||||||
right.add(text);
|
right.add(text);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.jozufozu.flywheel.event;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
|
||||||
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.IModBusEvent;
|
||||||
|
|
||||||
|
public class GatherContextEvent extends Event implements IModBusEvent {
|
||||||
|
|
||||||
|
private final Backend backend;
|
||||||
|
|
||||||
|
public GatherContextEvent(Backend backend) {
|
||||||
|
this.backend = backend;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Backend getBackend() {
|
||||||
|
return backend;
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ public class LightVolume {
|
||||||
public LightVolume(GridAlignedBB sampleVolume) {
|
public LightVolume(GridAlignedBB sampleVolume) {
|
||||||
setSampleVolume(sampleVolume);
|
setSampleVolume(sampleVolume);
|
||||||
|
|
||||||
pixelFormat = Backend.compat.pixelFormat;
|
pixelFormat = Backend.getInstance().compat.pixelFormat;
|
||||||
|
|
||||||
this.glTexture = new GlTexture(GL_TEXTURE_3D);
|
this.glTexture = new GlTexture(GL_TEXTURE_3D);
|
||||||
this.lightData = MemoryUtil.memAlloc(this.textureVolume.volume() * pixelFormat.byteCount());
|
this.lightData = MemoryUtil.memAlloc(this.textureVolume.volume() * pixelFormat.byteCount());
|
||||||
|
|
|
@ -24,8 +24,6 @@ import com.simibubi.create.foundation.item.CustomItemModels;
|
||||||
import com.simibubi.create.foundation.item.CustomRenderedItems;
|
import com.simibubi.create.foundation.item.CustomRenderedItems;
|
||||||
import com.simibubi.create.foundation.ponder.content.PonderIndex;
|
import com.simibubi.create.foundation.ponder.content.PonderIndex;
|
||||||
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
|
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
||||||
import com.simibubi.create.foundation.render.CreateFlywheelHandler;
|
|
||||||
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
||||||
import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
|
import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
|
||||||
import com.simibubi.create.foundation.utility.outliner.Outliner;
|
import com.simibubi.create.foundation.utility.outliner.Outliner;
|
||||||
|
@ -79,13 +77,10 @@ public class CreateClient {
|
||||||
modEventBus.addListener(AllParticleTypes::registerFactories);
|
modEventBus.addListener(AllParticleTypes::registerFactories);
|
||||||
modEventBus.addListener(ClientEvents::loadCompleted);
|
modEventBus.addListener(ClientEvents::loadCompleted);
|
||||||
|
|
||||||
Backend.init();
|
Backend.getInstance();
|
||||||
CreateFlywheelHandler.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clientInit(FMLClientSetupEvent event) {
|
public static void clientInit(FMLClientSetupEvent event) {
|
||||||
AllMaterialSpecs.init();
|
|
||||||
|
|
||||||
BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
|
BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
|
||||||
BUFFER_CACHE.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20);
|
BUFFER_CACHE.registerCompartment(ContraptionRenderDispatcher.CONTRAPTION, 20);
|
||||||
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
for (RenderType type : RenderType.getBlockLayers())
|
for (RenderType type : RenderType.getBlockLayers())
|
||||||
if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type))
|
if (RenderTypeLookup.canRenderInLayer(te.getBlockState(), type))
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
||||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
@OnlyIn(value = Dist.CLIENT)
|
@OnlyIn(value = Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
|
||||||
if (!Backend.canUseInstancing())
|
if (!Backend.getInstance().canUseInstancing())
|
||||||
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
DrillRenderer.renderInContraption(context, renderWorld, matrices, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
||||||
if (!Backend.canUseInstancing())
|
if (!Backend.getInstance().canUseInstancing())
|
||||||
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
HarvesterRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
|
|
||||||
if (!Backend.canUseInstancing(te.getWorld())) {
|
if (!Backend.getInstance().canUseInstancing(te.getWorld())) {
|
||||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||||
standardKineticRotationTransform(superBuffer, te, light);
|
standardKineticRotationTransform(superBuffer, te, light);
|
||||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState state = te.getBlockState();
|
BlockState state = te.getBlockState();
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
|
@ -257,7 +257,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
|
||||||
@Override
|
@Override
|
||||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
||||||
if (!Backend.canUseInstancing())
|
if (!Backend.getInstance().canUseInstancing())
|
||||||
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
DeployerRenderer.renderInContraption(context, renderWorld, matrices, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
||||||
renderItem(te, partialTicks, ms, buffer, light, overlay);
|
renderItem(te, partialTicks, ms, buffer, light, overlay);
|
||||||
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
renderComponents(te, partialTicks, ms, buffer, light, overlay);
|
renderComponents(te, partialTicks, ms, buffer, light, overlay);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
||||||
protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderComponents(DeployerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
if (!Backend.canUseInstancing(te.getWorld())) {
|
if (!Backend.getInstance().canUseInstancing(te.getWorld())) {
|
||||||
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
|
KineticTileEntityRenderer.renderRotatingKineticBlock(te, getRenderedBlockState(te), ms, vb, light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
Direction direction = te.getBlockState()
|
Direction direction = te.getBlockState()
|
||||||
.get(FACING);
|
.get(FACING);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
FlywheelTileEntity wte = (FlywheelTileEntity) te;
|
FlywheelTileEntity wte = (FlywheelTileEntity) te;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
|
||||||
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||||
int overlay) {
|
int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
Block block = te.getBlockState()
|
Block block = te.getBlockState()
|
||||||
.getBlock();
|
.getBlock();
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
|
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockPos pos = te.getPos();
|
BlockPos pos = te.getPos();
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||||
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
renderItems(te, partialTicks, ms, buffer, light, overlay);
|
||||||
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
FilteringRenderer.renderOnTileEntity(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
renderShaft(te, ms, buffer, light, overlay);
|
renderShaft(te, ms, buffer, light, overlay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
public void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
|
||||||
if (Backend.canUseInstancing()) return;
|
if (Backend.getInstance().canUseInstancing()) return;
|
||||||
|
|
||||||
Direction facing = context.state.get(BlockStateProperties.FACING);
|
Direction facing = context.state.get(BlockStateProperties.FACING);
|
||||||
PartialModel top = AllBlockPartials.BEARING_TOP;
|
PartialModel top = AllBlockPartials.BEARING_TOP;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
|
||||||
protected void renderSafe(StickerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(StickerTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState state = te.getBlockState();
|
BlockState state = te.getBlockState();
|
||||||
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state);
|
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState state = te.getBlockState();
|
BlockState state = te.getBlockState();
|
||||||
Direction facing = state.get(GantryCarriageBlock.FACING);
|
Direction facing = state.get(GantryCarriageBlock.FACING);
|
||||||
|
|
|
@ -8,10 +8,11 @@ import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
|
||||||
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
||||||
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
||||||
|
import com.jozufozu.flywheel.core.Formats;
|
||||||
|
import com.jozufozu.flywheel.core.Materials;
|
||||||
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
|
||||||
public GlueInstance(MaterialManager<?> renderer, SuperGlueEntity entity) {
|
public GlueInstance(MaterialManager<?> renderer, SuperGlueEntity entity) {
|
||||||
super(renderer, entity);
|
super(renderer, entity);
|
||||||
|
|
||||||
Instancer<OrientedData> instancer = renderer.getMaterial(AllMaterialSpecs.ORIENTED)
|
Instancer<OrientedData> instancer = renderer.getMaterial(Materials.ORIENTED)
|
||||||
.get(entity.getType(), GlueInstance::supplyModel);
|
.get(entity.getType(), GlueInstance::supplyModel);
|
||||||
model = new ConditionalInstance<>(instancer)
|
model = new ConditionalInstance<>(instancer)
|
||||||
.withCondition(this::shouldShow)
|
.withCondition(this::shouldShow)
|
||||||
|
@ -109,6 +110,6 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(quads.length * 4);
|
ByteBuffer buffer = ByteBuffer.allocate(quads.length * 4);
|
||||||
buffer.asFloatBuffer().put(quads);
|
buffer.asFloatBuffer().put(quads);
|
||||||
|
|
||||||
return IndexedModel.fromSequentialQuads(AllMaterialSpecs.UNLIT_MODEL, buffer, 8);
|
return IndexedModel.fromSequentialQuads(Formats.UNLIT_MODEL, buffer, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
float offset = getOffset(te, partialTicks);
|
float offset = getOffset(te, partialTicks);
|
||||||
|
|
|
@ -11,14 +11,10 @@ import static org.lwjgl.opengl.GL13.glEnable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
|
||||||
import com.jozufozu.flywheel.backend.loading.ModelTemplate;
|
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
|
||||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||||
|
@ -31,6 +27,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
import com.simibubi.create.foundation.render.Compartment;
|
import com.simibubi.create.foundation.render.Compartment;
|
||||||
|
import com.simibubi.create.foundation.render.CreateContexts;
|
||||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||||
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
||||||
import com.simibubi.create.foundation.render.TileEntityRenderHelper;
|
import com.simibubi.create.foundation.render.TileEntityRenderHelper;
|
||||||
|
@ -53,7 +50,6 @@ import net.minecraft.client.renderer.RenderTypeLookup;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -74,12 +70,6 @@ public class ContraptionRenderDispatcher {
|
||||||
public static final Int2ObjectMap<ContraptionWorldHolder> WORLD_HOLDERS = new Int2ObjectOpenHashMap<>();
|
public static final Int2ObjectMap<ContraptionWorldHolder> WORLD_HOLDERS = new Int2ObjectOpenHashMap<>();
|
||||||
public static final Compartment<Pair<Contraption, Integer>> CONTRAPTION = new Compartment<>();
|
public static final Compartment<Pair<Contraption, Integer>> CONTRAPTION = new Compartment<>();
|
||||||
|
|
||||||
private static final ResourceLocation ctxRoot = new ResourceLocation("create", "context/contraption");
|
|
||||||
public static final WorldContext<ContraptionProgram> TILES = contraptionContext();
|
|
||||||
public static final WorldContext<ContraptionProgram> STRUCTURE = contraptionContext()
|
|
||||||
.withSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE))
|
|
||||||
.withTemplateFactory(ModelTemplate::new);
|
|
||||||
|
|
||||||
public static void tick() {
|
public static void tick() {
|
||||||
if (Minecraft.getInstance().isGamePaused()) return;
|
if (Minecraft.getInstance().isGamePaused()) return;
|
||||||
|
|
||||||
|
@ -118,8 +108,8 @@ public class ContraptionRenderDispatcher {
|
||||||
glEnable(GL_TEXTURE_3D);
|
glEnable(GL_TEXTURE_3D);
|
||||||
glActiveTexture(GL_TEXTURE4); // the shaders expect light volumes to be in texture 4
|
glActiveTexture(GL_TEXTURE4); // the shaders expect light volumes to be in texture 4
|
||||||
|
|
||||||
if (Backend.canUseVBOs()) {
|
if (Backend.getInstance().canUseVBOs()) {
|
||||||
ContraptionProgram structureShader = STRUCTURE.getProgram(AllProgramSpecs.STRUCTURE);
|
ContraptionProgram structureShader = CreateContexts.STRUCTURE.getProgram(AllProgramSpecs.STRUCTURE);
|
||||||
|
|
||||||
structureShader.bind();
|
structureShader.bind();
|
||||||
structureShader.uploadViewProjection(event.viewProjection);
|
structureShader.uploadViewProjection(event.viewProjection);
|
||||||
|
@ -130,7 +120,7 @@ public class ContraptionRenderDispatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
for (RenderedContraption renderer : RENDERERS.values()) {
|
for (RenderedContraption renderer : RENDERERS.values()) {
|
||||||
renderer.materialManager.render(layer, event.viewProjection, event.camX, event.camY, event.camZ, renderer::setup);
|
renderer.materialManager.render(layer, event.viewProjection, event.camX, event.camY, event.camZ, renderer::setup);
|
||||||
}
|
}
|
||||||
|
@ -150,7 +140,7 @@ public class ContraptionRenderDispatcher {
|
||||||
public static void render(AbstractContraptionEntity entity, Contraption contraption,
|
public static void render(AbstractContraptionEntity entity, Contraption contraption,
|
||||||
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
ContraptionMatrices matrices, IRenderTypeBuffer buffers) {
|
||||||
World world = entity.world;
|
World world = entity.world;
|
||||||
if (Backend.canUseVBOs() && Backend.isFlywheelWorld(world)) {
|
if (Backend.getInstance().canUseVBOs() && Backend.isFlywheelWorld(world)) {
|
||||||
RenderedContraption renderer = getRenderer(world, contraption);
|
RenderedContraption renderer = getRenderer(world, contraption);
|
||||||
PlacementSimulationWorld renderWorld = renderer.renderWorld;
|
PlacementSimulationWorld renderWorld = renderer.renderWorld;
|
||||||
|
|
||||||
|
@ -343,10 +333,4 @@ public class ContraptionRenderDispatcher {
|
||||||
WORLD_HOLDERS.values().removeIf(ContraptionWorldHolder::isDead);
|
WORLD_HOLDERS.values().removeIf(ContraptionWorldHolder::isDead);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WorldContext<ContraptionProgram> contraptionContext() {
|
|
||||||
return new WorldContext<>(ContraptionProgram::new)
|
|
||||||
.withName(ctxRoot)
|
|
||||||
.withBuiltin(ShaderType.FRAGMENT, ctxRoot, "/builtin.frag")
|
|
||||||
.withBuiltin(ShaderType.VERTEX, ctxRoot, "/builtin.vert");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionLighter;
|
||||||
|
import com.simibubi.create.foundation.render.CreateContexts;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
|
@ -59,11 +60,11 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
public RenderedContraption(PlacementSimulationWorld renderWorld, Contraption contraption) {
|
public RenderedContraption(PlacementSimulationWorld renderWorld, Contraption contraption) {
|
||||||
super(contraption, renderWorld);
|
super(contraption, renderWorld);
|
||||||
this.lighter = contraption.makeLighter();
|
this.lighter = contraption.makeLighter();
|
||||||
this.materialManager = new ContraptionMaterialManager(ContraptionRenderDispatcher.TILES);
|
this.materialManager = new ContraptionMaterialManager(CreateContexts.CWORLD);
|
||||||
this.kinetics = new ContraptionInstanceManager(this, materialManager);
|
this.kinetics = new ContraptionInstanceManager(this, materialManager);
|
||||||
|
|
||||||
buildLayers();
|
buildLayers();
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
buildInstancedTiles();
|
buildInstancedTiles();
|
||||||
buildActors();
|
buildActors();
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,7 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
BufferedModel layerModel = buildStructureModel(renderWorld, contraption, layer);
|
BufferedModel layerModel = buildStructureModel(renderWorld, contraption, layer);
|
||||||
|
|
||||||
if (layerModel != null) {
|
if (layerModel != null) {
|
||||||
if (Backend.compat.vertexArrayObjectsSupported())
|
if (Backend.getInstance().compat.vertexArrayObjectsSupported())
|
||||||
renderLayers.put(layer, new ArrayModelRenderer(layerModel));
|
renderLayers.put(layer, new ArrayModelRenderer(layerModel));
|
||||||
else
|
else
|
||||||
renderLayers.put(layer, new ModelRenderer(layerModel));
|
renderLayers.put(layer, new ModelRenderer(layerModel));
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
|
||||||
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(tileEntityIn, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
||||||
if (!Backend.canUseInstancing(tileEntityIn.getWorld())) {
|
if (!Backend.getInstance().canUseInstancing(tileEntityIn.getWorld())) {
|
||||||
KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light);
|
KineticTileEntityRenderer.renderRotatingBuffer(tileEntityIn, getRotatedModel(tileEntityIn), ms, builder, light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(BeltTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (!Backend.canUseInstancing(te.getWorld())) {
|
if (!Backend.getInstance().canUseInstancing(te.getWorld())) {
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
if (!AllBlocks.BELT.has(blockState)) return;
|
if (!AllBlocks.BELT.has(blockState)) return;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
Block block = te.getBlockState().getBlock();
|
Block block = te.getBlockState().getBlock();
|
||||||
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
final Axis boxAxis = ((IRotate) block).getRotationAxis(te.getBlockState());
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
BlockState gaugeState = te.getBlockState();
|
BlockState gaugeState = te.getBlockState();
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
final Axis boxAxis = te.getBlockState().get(BlockStateProperties.AXIS);
|
||||||
final BlockPos pos = te.getPos();
|
final BlockPos pos = te.getPos();
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.curiosities.projector;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.simibubi.create.foundation.render.effects.EffectsHandler;
|
import com.simibubi.create.foundation.render.effects.EffectsHandler;
|
||||||
|
|
||||||
public class ChromaticProjectorInstance extends TileEntityInstance<ChromaticProjectorTileEntity> implements IDynamicInstance {
|
public class ChromaticProjectorInstance extends TileEntityInstance<ChromaticProjectorTileEntity> implements IDynamicInstance {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.logistics.block.FlapData;
|
import com.simibubi.create.content.logistics.block.FlapData;
|
||||||
import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
|
import com.simibubi.create.foundation.gui.widgets.InterpolatedValue;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
|
SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
|
||||||
float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks);
|
float lidProgress = ((EjectorTileEntity) te).getLidProgress(partialTicks);
|
||||||
float angle = lidProgress * 70;
|
float angle = lidProgress * 70;
|
||||||
|
|
||||||
if (!Backend.canUseInstancing(te.getWorld())) {
|
if (!Backend.getInstance().canUseInstancing(te.getWorld())) {
|
||||||
SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
|
SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
|
||||||
applyLidAngle(te, angle, model.matrixStacker());
|
applyLidAngle(te, angle, model.matrixStacker());
|
||||||
model.light(light)
|
model.light(light)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.logistics.block.diodes;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.logistics.block.FlapData;
|
import com.simibubi.create.content.logistics.block.FlapData;
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (!te.hasFlap() || Backend.canUseInstancing(te.getWorld()))
|
if (!te.hasFlap() || Backend.getInstance().canUseInstancing(te.getWorld()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
||||||
super.renderSafe(te, pt, ms, buffer, light, overlay);
|
super.renderSafe(te, pt, ms, buffer, light, overlay);
|
||||||
ArmTileEntity arm = (ArmTileEntity) te;
|
ArmTileEntity arm = (ArmTileEntity) te;
|
||||||
|
|
||||||
boolean usingFlywheel = Backend.canUseInstancing(te.getWorld());
|
boolean usingFlywheel = Backend.getInstance().canUseInstancing(te.getWorld());
|
||||||
|
|
||||||
ItemStack item = arm.heldItem;
|
ItemStack item = arm.heldItem;
|
||||||
boolean hasItem = !item.isEmpty();
|
boolean hasItem = !item.isEmpty();
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.logistics.block.redstone;
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
|
||||||
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
BlockState leverState = te.getBlockState();
|
BlockState leverState = te.getBlockState();
|
||||||
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
|
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.schematics.block;
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
||||||
if (blocksLaunching)
|
if (blocksLaunching)
|
||||||
renderLaunchedBlocks(tileEntityIn, partialTicks, ms, buffer, light, overlay);
|
renderLaunchedBlocks(tileEntityIn, partialTicks, ms, buffer, light, overlay);
|
||||||
|
|
||||||
if (Backend.canUseInstancing(tileEntityIn.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(tileEntityIn.getWorld())) return;
|
||||||
|
|
||||||
BlockPos pos = tileEntityIn.getPos();
|
BlockPos pos = tileEntityIn.getPos();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL30;
|
import org.lwjgl.opengl.GL30;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
|
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
|
||||||
|
@ -96,11 +97,12 @@ public abstract class ConfigScreen extends AbstractSimiScreen {
|
||||||
Framebuffer thisBuffer = UIRenderHelper.framebuffer;
|
Framebuffer thisBuffer = UIRenderHelper.framebuffer;
|
||||||
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.framebufferObject);
|
GlCompat functions = Backend.getInstance().compat;
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.framebufferObject);
|
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, mainBuffer.framebufferObject);
|
||||||
Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, thisBuffer.framebufferObject);
|
||||||
|
functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, thisBuffer.framebufferObject);
|
functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, thisBuffer.framebufferObject);
|
||||||
GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
|
GL11.glClear(GL30.GL_STENCIL_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -111,11 +113,12 @@ public abstract class ConfigScreen extends AbstractSimiScreen {
|
||||||
Framebuffer thisBuffer = UIRenderHelper.framebuffer;
|
Framebuffer thisBuffer = UIRenderHelper.framebuffer;
|
||||||
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.framebufferObject);
|
GlCompat functions = Backend.getInstance().compat;
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject);
|
functions.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, thisBuffer.framebufferObject);
|
||||||
Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
functions.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject);
|
||||||
|
functions.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject);
|
functions.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.foundation.data;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.ITileInstanceFactory;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory;
|
||||||
import com.tterrag.registrate.AbstractRegistrate;
|
import com.tterrag.registrate.AbstractRegistrate;
|
||||||
import com.tterrag.registrate.builders.BuilderCallback;
|
import com.tterrag.registrate.builders.BuilderCallback;
|
||||||
import com.tterrag.registrate.builders.TileEntityBuilder;
|
import com.tterrag.registrate.builders.TileEntityBuilder;
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class CancelEntityRenderMixin {
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "getAllEntities", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getAllEntities", cancellable = true)
|
||||||
private void filterEntities(CallbackInfoReturnable<Iterable<Entity>> cir) {
|
private void filterEntities(CallbackInfoReturnable<Iterable<Entity>> cir) {
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
Iterable<Entity> entities = cir.getReturnValue();
|
Iterable<Entity> entities = cir.getReturnValue();
|
||||||
|
|
||||||
ArrayList<Entity> list = Lists.newArrayList(entities);
|
ArrayList<Entity> list = Lists.newArrayList(entities);
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class CancelTileEntityRenderMixin {
|
||||||
*/
|
*/
|
||||||
@Inject(at = @At("RETURN"), method = "getTileEntities", cancellable = true)
|
@Inject(at = @At("RETURN"), method = "getTileEntities", cancellable = true)
|
||||||
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
|
private void noRenderInstancedTiles(CallbackInfoReturnable<List<TileEntity>> cir) {
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.getInstance().canUseInstancing()) {
|
||||||
List<TileEntity> tiles = cir.getReturnValue();
|
List<TileEntity> tiles = cir.getReturnValue();
|
||||||
|
|
||||||
tiles.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderNormally());
|
tiles.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderNormally());
|
||||||
|
|
|
@ -8,7 +8,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||||
|
@ -51,13 +50,13 @@ public class RenderHooksMixin {
|
||||||
@Inject(at = @At("TAIL"), method = "renderLayer")
|
@Inject(at = @At("TAIL"), method = "renderLayer")
|
||||||
private void renderLayer(RenderType type, MatrixStack stack, double camX, double camY, double camZ,
|
private void renderLayer(RenderType type, MatrixStack stack, double camX, double camY, double camZ,
|
||||||
CallbackInfo ci) {
|
CallbackInfo ci) {
|
||||||
if (!Backend.available())
|
if (!Backend.getInstance().available())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Matrix4f view = stack.peek()
|
Matrix4f view = stack.peek()
|
||||||
.getModel();
|
.getModel();
|
||||||
Matrix4f viewProjection = view.copy();
|
Matrix4f viewProjection = view.copy();
|
||||||
viewProjection.multiplyBackward(Backend.getProjectionMatrix());
|
viewProjection.multiplyBackward(Backend.getInstance().getProjectionMatrix());
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(world, type, viewProjection, camX, camY, camZ));
|
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(world, type, viewProjection, camX, camY, camZ));
|
||||||
GL20.glUseProgram(0);
|
GL20.glUseProgram(0);
|
||||||
|
@ -65,8 +64,7 @@ public class RenderHooksMixin {
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "loadRenderers")
|
@Inject(at = @At("TAIL"), method = "loadRenderers")
|
||||||
private void refresh(CallbackInfo ci) {
|
private void refresh(CallbackInfo ci) {
|
||||||
OptifineHandler.refresh();
|
Backend.getInstance().refresh();
|
||||||
Backend.refresh();
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(world));
|
MinecraftForge.EVENT_BUS.post(new ReloadRenderersEvent(world));
|
||||||
}
|
}
|
||||||
|
@ -82,13 +80,13 @@ public class RenderHooksMixin {
|
||||||
private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_,
|
private void renderBlockBreaking(MatrixStack stack, float p_228426_2_, long p_228426_3_, boolean p_228426_5_,
|
||||||
ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_,
|
ActiveRenderInfo info, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f p_228426_9_,
|
||||||
CallbackInfo ci) {
|
CallbackInfo ci) {
|
||||||
if (!Backend.available())
|
if (!Backend.getInstance().available())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Matrix4f view = stack.peek()
|
Matrix4f view = stack.peek()
|
||||||
.getModel();
|
.getModel();
|
||||||
Matrix4f viewProjection = view.copy();
|
Matrix4f viewProjection = view.copy();
|
||||||
viewProjection.multiplyBackward(Backend.getProjectionMatrix());
|
viewProjection.multiplyBackward(Backend.getInstance().getProjectionMatrix());
|
||||||
|
|
||||||
Vector3d cameraPos = info.getProjectedView();
|
Vector3d cameraPos = info.getProjectedView();
|
||||||
InstancedRenderDispatcher.renderBreaking(world, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
InstancedRenderDispatcher.renderBreaking(world, viewProjection, cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public abstract class StoreProjectionMatrixMixin {
|
||||||
@Inject(method = "loadProjectionMatrix", at = @At("TAIL"))
|
@Inject(method = "loadProjectionMatrix", at = @At("TAIL"))
|
||||||
private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) {
|
private void onProjectionMatrixLoad(Matrix4f projection, CallbackInfo ci) {
|
||||||
if (shouldCopy) {
|
if (shouldCopy) {
|
||||||
Backend.setProjectionMatrix(projection.copy());
|
Backend.getInstance().setProjectionMatrix(projection.copy());
|
||||||
shouldCopy = false;
|
shouldCopy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,11 @@
|
||||||
package com.simibubi.create.foundation.render;
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.MatrixAttributes;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||||
|
import com.jozufozu.flywheel.core.Formats;
|
||||||
|
|
||||||
public class AllInstanceFormats {
|
public class AllInstanceFormats {
|
||||||
|
|
||||||
public static final VertexFormat MODEL = litInstance()
|
|
||||||
.addAttributes(MatrixAttributes.MAT4,
|
|
||||||
MatrixAttributes.MAT3)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public static final VertexFormat ORIENTED = litInstance()
|
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.VEC3, CommonAttributes.QUATERNION)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public static VertexFormat ROTATING = kineticInstance()
|
public static VertexFormat ROTATING = kineticInstance()
|
||||||
.addAttributes(CommonAttributes.NORMAL)
|
.addAttributes(CommonAttributes.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
@ -35,13 +26,8 @@ public class AllInstanceFormats {
|
||||||
CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT)
|
CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT, CommonAttributes.FLOAT)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static VertexFormat.Builder litInstance() {
|
|
||||||
return VertexFormat.builder()
|
|
||||||
.addAttributes(CommonAttributes.LIGHT, CommonAttributes.RGBA);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static VertexFormat.Builder kineticInstance() {
|
private static VertexFormat.Builder kineticInstance() {
|
||||||
return litInstance()
|
return Formats.litInstance()
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT);
|
.addAttributes(CommonAttributes.VEC3, CommonAttributes.FLOAT, CommonAttributes.FLOAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package com.simibubi.create.foundation.render;
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
import static com.jozufozu.flywheel.backend.Backend.register;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.Formats;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
import com.simibubi.create.content.contraptions.components.actors.ActorData;
|
import com.simibubi.create.content.contraptions.components.actors.ActorData;
|
||||||
|
@ -14,27 +12,33 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltData;
|
||||||
import com.simibubi.create.content.logistics.block.FlapData;
|
import com.simibubi.create.content.logistics.block.FlapData;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class AllMaterialSpecs {
|
public class AllMaterialSpecs {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// noop, make sure the static field are loaded.
|
// noop, make sure the static field are loaded.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final VertexFormat UNLIT_MODEL = VertexFormat.builder()
|
public static final MaterialSpec<RotatingData> ROTATING = new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, Formats.UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new);
|
||||||
.addAttributes(CommonAttributes.VEC3, CommonAttributes.NORMAL, CommonAttributes.UV)
|
public static final MaterialSpec<BeltData> BELTS = new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, Formats.UNLIT_MODEL, AllInstanceFormats.BELT, BeltData::new);
|
||||||
.build();
|
public static final MaterialSpec<ActorData> ACTORS = new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, Formats.UNLIT_MODEL, AllInstanceFormats.ACTOR, ActorData::new);
|
||||||
|
public static final MaterialSpec<FlapData> FLAPS = new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, Formats.UNLIT_MODEL, AllInstanceFormats.FLAP, FlapData::new);
|
||||||
|
|
||||||
public static final MaterialSpec<RotatingData> ROTATING = register(new MaterialSpec<>(Locations.ROTATING, AllProgramSpecs.ROTATING, UNLIT_MODEL, AllInstanceFormats.ROTATING, RotatingData::new));
|
public static <D extends InstanceData> MaterialSpec<D> register(MaterialSpec<D> spec) {
|
||||||
public static final MaterialSpec<ModelData> TRANSFORMED = register(new MaterialSpec<>(Locations.MODEL, AllProgramSpecs.MODEL, UNLIT_MODEL, AllInstanceFormats.MODEL, ModelData::new));
|
return Backend.getInstance().register(spec);
|
||||||
public static final MaterialSpec<OrientedData> ORIENTED = register(new MaterialSpec<>(Locations.ORIENTED, AllProgramSpecs.ORIENTED, UNLIT_MODEL, AllInstanceFormats.ORIENTED, OrientedData::new));
|
}
|
||||||
|
|
||||||
public static final MaterialSpec<BeltData> BELTS = register(new MaterialSpec<>(Locations.BELTS, AllProgramSpecs.BELT, UNLIT_MODEL, AllInstanceFormats.BELT, BeltData::new));
|
@SubscribeEvent
|
||||||
public static final MaterialSpec<ActorData> ACTORS = register(new MaterialSpec<>(Locations.ACTORS, AllProgramSpecs.ACTOR, UNLIT_MODEL, AllInstanceFormats.ACTOR, ActorData::new));
|
public static void flwInit(GatherContextEvent event) {
|
||||||
public static final MaterialSpec<FlapData> FLAPS = register(new MaterialSpec<>(Locations.FLAPS, AllProgramSpecs.FLAPS, UNLIT_MODEL, AllInstanceFormats.FLAP, FlapData::new));
|
register(ROTATING);
|
||||||
|
register(BELTS);
|
||||||
|
register(ACTORS);
|
||||||
|
register(FLAPS);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Locations {
|
public static class Locations {
|
||||||
public static final ResourceLocation MODEL = new ResourceLocation("create", "model");
|
|
||||||
public static final ResourceLocation ORIENTED = new ResourceLocation("create", "oriented");
|
|
||||||
public static final ResourceLocation ROTATING = new ResourceLocation(Create.ID, "rotating");
|
public static final ResourceLocation ROTATING = new ResourceLocation(Create.ID, "rotating");
|
||||||
public static final ResourceLocation BELTS = new ResourceLocation(Create.ID, "belts");
|
public static final ResourceLocation BELTS = new ResourceLocation(Create.ID, "belts");
|
||||||
public static final ResourceLocation ACTORS = new ResourceLocation(Create.ID, "actors");
|
public static final ResourceLocation ACTORS = new ResourceLocation(Create.ID, "actors");
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
package com.simibubi.create.foundation.render;
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.Flywheel;
|
|
||||||
import com.simibubi.create.Create;
|
import com.simibubi.create.Create;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class AllProgramSpecs {
|
public class AllProgramSpecs {
|
||||||
|
|
||||||
public static final ResourceLocation MODEL = new ResourceLocation(Flywheel.ID, "model");//, Locations.MODEL_VERT, Locations.BLOCK);
|
|
||||||
public static final ResourceLocation ORIENTED = new ResourceLocation(Flywheel.ID, "oriented");//, Locations.ORIENTED, Locations.BLOCK);
|
|
||||||
|
|
||||||
public static final ResourceLocation ROTATING = loc("rotating");
|
public static final ResourceLocation ROTATING = loc("rotating");
|
||||||
public static final ResourceLocation CHROMATIC = loc("chromatic");
|
public static final ResourceLocation CHROMATIC = loc("chromatic");
|
||||||
public static final ResourceLocation BELT = loc("belt");
|
public static final ResourceLocation BELT = loc("belt");
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.SpecMetaRegistry;
|
||||||
|
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||||
|
import com.jozufozu.flywheel.backend.loading.ModelTemplate;
|
||||||
|
import com.jozufozu.flywheel.core.WorldContext;
|
||||||
|
import com.jozufozu.flywheel.core.shader.gamestate.RainbowDebugStateProvider;
|
||||||
|
import com.jozufozu.flywheel.event.GatherContextEvent;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram;
|
||||||
|
import com.simibubi.create.foundation.render.effects.EffectsContext;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class CreateContexts {
|
||||||
|
private static final ResourceLocation CONTRAPTION = new ResourceLocation("create", "context/contraption");
|
||||||
|
|
||||||
|
public static EffectsContext EFFECTS;
|
||||||
|
public static WorldContext<ContraptionProgram> CWORLD;
|
||||||
|
public static WorldContext<ContraptionProgram> STRUCTURE;
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void flwInit(GatherContextEvent event) {
|
||||||
|
Backend backend = event.getBackend();
|
||||||
|
|
||||||
|
SpecMetaRegistry.register(RainbowDebugStateProvider.INSTANCE);
|
||||||
|
|
||||||
|
EFFECTS = backend.register(new EffectsContext(backend));
|
||||||
|
CWORLD = backend.register(contraptionContext(backend));
|
||||||
|
STRUCTURE = backend.register(contraptionContext(backend)
|
||||||
|
.withSpecStream(() -> Stream.of(AllProgramSpecs.STRUCTURE))
|
||||||
|
.withTemplateFactory(ModelTemplate::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WorldContext<ContraptionProgram> contraptionContext(Backend backend) {
|
||||||
|
return new WorldContext<>(backend, ContraptionProgram::new)
|
||||||
|
.withName(CONTRAPTION)
|
||||||
|
.withBuiltin(ShaderType.FRAGMENT, CONTRAPTION, "/builtin.frag")
|
||||||
|
.withBuiltin(ShaderType.VERTEX, CONTRAPTION, "/builtin.vert");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package com.simibubi.create.foundation.render;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
|
||||||
import com.simibubi.create.foundation.render.effects.EffectsContext;
|
|
||||||
|
|
||||||
public class CreateFlywheelHandler {
|
|
||||||
public static void init() {
|
|
||||||
Backend.register(ContraptionRenderDispatcher.TILES);
|
|
||||||
Backend.register(ContraptionRenderDispatcher.STRUCTURE);
|
|
||||||
Backend.register(EffectsContext.INSTANCE);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,15 +11,13 @@ import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class EffectsContext extends ShaderContext<SphereFilterProgram> {
|
public class EffectsContext extends ShaderContext<SphereFilterProgram> {
|
||||||
|
|
||||||
public static final EffectsContext INSTANCE = new EffectsContext();
|
public EffectsContext(Backend backend) {
|
||||||
|
super(backend);
|
||||||
public EffectsContext() {
|
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
ProgramSpec programSpec = Backend.getSpec(AllProgramSpecs.CHROMATIC);
|
ProgramSpec programSpec = Backend.getInstance().getSpec(AllProgramSpecs.CHROMATIC);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
programs.put(programSpec.name, new SphereFilterProgram(loadAndLink(programSpec, null)));
|
programs.put(programSpec.name, new SphereFilterProgram(loadAndLink(programSpec, null)));
|
||||||
|
@ -27,7 +25,7 @@ public class EffectsContext extends ShaderContext<SphereFilterProgram> {
|
||||||
Backend.log.debug("Loaded program {}", programSpec.name);
|
Backend.log.debug("Loaded program {}", programSpec.name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Backend.log.error("Program '{}': {}", programSpec.name, e);
|
Backend.log.error("Program '{}': {}", programSpec.name, e);
|
||||||
sourceRepo.notifyError();
|
backend.sources.notifyError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.core.FullscreenQuad;
|
import com.jozufozu.flywheel.core.FullscreenQuad;
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
import com.simibubi.create.foundation.render.AllProgramSpecs;
|
||||||
|
import com.simibubi.create.foundation.render.CreateContexts;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.MainWindow;
|
import net.minecraft.client.MainWindow;
|
||||||
|
@ -29,11 +30,11 @@ public class EffectsHandler {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static EffectsHandler getInstance() {
|
public static EffectsHandler getInstance() {
|
||||||
if (Backend.available() && instance == null) {
|
if (Backend.getInstance().available() && instance == null) {
|
||||||
instance = new EffectsHandler();
|
instance = new EffectsHandler(Backend.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Backend.available() && instance != null) {
|
if (!Backend.getInstance().available() && instance != null) {
|
||||||
instance.delete();
|
instance.delete();
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
@ -49,12 +50,12 @@ public class EffectsHandler {
|
||||||
return Minecraft.getInstance().gameRenderer.getFarPlaneDistance() * 4;
|
return Minecraft.getInstance().gameRenderer.getFarPlaneDistance() * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Backend backend;
|
||||||
private final Framebuffer framebuffer;
|
private final Framebuffer framebuffer;
|
||||||
|
|
||||||
private final ArrayList<FilterSphere> spheres;
|
private final ArrayList<FilterSphere> spheres;
|
||||||
|
|
||||||
public EffectsHandler() {
|
public EffectsHandler(Backend backend) {
|
||||||
|
this.backend = backend;
|
||||||
spheres = new ArrayList<>();
|
spheres = new ArrayList<>();
|
||||||
|
|
||||||
Framebuffer render = Minecraft.getInstance().getFramebuffer();
|
Framebuffer render = Minecraft.getInstance().getFramebuffer();
|
||||||
|
@ -79,10 +80,10 @@ public class EffectsHandler {
|
||||||
|
|
||||||
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
Framebuffer mainBuffer = Minecraft.getInstance().getFramebuffer();
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject);
|
backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, framebuffer.framebufferObject);
|
||||||
GL11.glClear(GL30.GL_COLOR_BUFFER_BIT);
|
GL11.glClear(GL30.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
SphereFilterProgram program = EffectsContext.INSTANCE.getProgram(AllProgramSpecs.CHROMATIC);
|
SphereFilterProgram program = CreateContexts.EFFECTS.getProgram(AllProgramSpecs.CHROMATIC);
|
||||||
program.bind();
|
program.bind();
|
||||||
|
|
||||||
program.bindColorTexture(mainBuffer.getColorAttachment());
|
program.bindColorTexture(mainBuffer.getColorAttachment());
|
||||||
|
@ -129,10 +130,10 @@ public class EffectsHandler {
|
||||||
program.unbind();
|
program.unbind();
|
||||||
spheres.clear();
|
spheres.clear();
|
||||||
|
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject);
|
backend.compat.fbo.bindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebuffer.framebufferObject);
|
||||||
Backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject);
|
backend.compat.fbo.bindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, mainBuffer.framebufferObject);
|
||||||
Backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
backend.compat.blit.blitFramebuffer(0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, 0, 0, mainBuffer.framebufferWidth, mainBuffer.framebufferHeight, GL30.GL_COLOR_BUFFER_BIT, GL20.GL_LINEAR);
|
||||||
Backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject);
|
backend.compat.fbo.bindFramebuffer(FramebufferConstants.FRAME_BUFFER, mainBuffer.framebufferObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public abstract class ColoredOverlayTileEntityRenderer<T extends TileEntity> ext
|
||||||
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||||
int light, int overlay) {
|
int light, int overlay) {
|
||||||
|
|
||||||
if (Backend.canUseInstancing(te.getWorld())) return;
|
if (Backend.getInstance().canUseInstancing(te.getWorld())) return;
|
||||||
|
|
||||||
SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light);
|
SuperByteBuffer render = render(getOverlayBuffer(te), getColor(te, partialTicks), light);
|
||||||
render.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
render.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#flwinclude <"flywheel:core/lightutil.glsl">
|
#flwinclude <"flywheel:core/lightutil.glsl">
|
||||||
|
|
||||||
varying vec3 BoxCoord;
|
varying vec3 BoxCoord;
|
||||||
|
varying vec2 BoxLight;
|
||||||
uniform sampler3D uLightVolume;
|
uniform sampler3D uLightVolume;
|
||||||
|
|
||||||
uniform sampler2D uBlockAtlas;
|
uniform sampler2D uBlockAtlas;
|
||||||
|
|
Loading…
Reference in a new issue