Abstract fog

- WorldPrograms no longer accept an explicit fog mode.
 - They now inherit from a class that takes a list of arbitrary shader extensions
This commit is contained in:
JozsefA 2021-05-19 19:11:06 -07:00
parent 4d755dc506
commit 9a178ef9d8
29 changed files with 292 additions and 160 deletions

View file

@ -20,12 +20,12 @@ import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLCapabilities;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.core.CrumblingRenderer;
import com.jozufozu.flywheel.backend.core.WorldContext;
import com.jozufozu.flywheel.backend.core.WorldTileRenderer;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
import com.jozufozu.flywheel.backend.instancing.IFlywheelWorld;
import com.jozufozu.flywheel.backend.instancing.InstanceData;
@ -64,7 +64,7 @@ public class Backend {
public static GLCapabilities capabilities;
public static GlCompat compat;
public static WorldAttached<WorldTileRenderer<BasicProgram>> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE));
public static WorldAttached<WorldTileRenderer<WorldProgram>> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE));
public static LazyValue<Vector<CrumblingRenderer>> blockBreaking = new LazyValue<>(() -> {
Vector<CrumblingRenderer> renderers = new Vector<>(10);
for (int i = 0; i < 10; i++) {
@ -87,7 +87,7 @@ public class Backend {
listeners.refreshListener(world -> {
if (canUseInstancing() && world != null) {
WorldTileRenderer<BasicProgram> tileRenderer = Backend.tileRenderer.get(world);
WorldTileRenderer<WorldProgram> tileRenderer = Backend.tileRenderer.get(world);
tileRenderer.invalidate();
world.loadedTileEntityList.forEach(tileRenderer::add);
}
@ -190,7 +190,7 @@ public class Backend {
Minecraft mc = Minecraft.getInstance();
ClientWorld world = mc.world;
WorldTileRenderer<BasicProgram> instancer = tileRenderer.get(world);
WorldTileRenderer<WorldProgram> instancer = tileRenderer.get(world);
Entity renderViewEntity = mc.renderViewEntity;
instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ());
@ -198,7 +198,7 @@ public class Backend {
public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
if (!canUseInstancing(world)) return;
WorldTileRenderer<BasicProgram> renderer = tileRenderer.get(world);
WorldTileRenderer<WorldProgram> renderer = tileRenderer.get(world);
layer.startDrawing();

View file

@ -4,9 +4,9 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram;
import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader;
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
import com.jozufozu.flywheel.backend.loading.Program;

View file

@ -2,14 +2,17 @@ package com.jozufozu.flywheel.backend.core;
import static org.lwjgl.opengl.GL20.glUniform2f;
import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode;
import java.util.List;
import com.jozufozu.flywheel.backend.core.shader.ProgramExtender;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.loading.Program;
public class CrumblingProgram extends BasicProgram {
public class CrumblingProgram extends WorldProgram {
protected final int uTextureScale;
protected int uCrumbling;
public CrumblingProgram(Program program, ProgramFogMode.Factory fogFactory) {
public CrumblingProgram(Program program, List<ProgramExtender> fogFactory) {
super(program, fogFactory);
uTextureScale = getUniformLocation("uTextureScale");

View file

@ -0,0 +1,6 @@
package com.jozufozu.flywheel.backend.core;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
public class FirstNonnullMultiProgram<P extends GlProgram> {
}

View file

@ -12,9 +12,9 @@ import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.ResourceUtil;
import com.jozufozu.flywheel.backend.ShaderContext;
import com.jozufozu.flywheel.backend.ShaderLoader;
import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram;
import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader;
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
@ -27,13 +27,13 @@ import com.jozufozu.flywheel.backend.loading.ShaderTransformer;
import net.minecraft.util.ResourceLocation;
public class WorldContext<P extends BasicProgram> extends ShaderContext<P> {
public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
private static final String declaration = "#flwbuiltins";
private static final Pattern builtinPattern = Pattern.compile(declaration);
public static final WorldContext<BasicProgram> INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new FogSensitiveProgram.SpecLoader<>(BasicProgram::new));
public static final WorldContext<CrumblingProgram> CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new FogSensitiveProgram.SpecLoader<>(CrumblingProgram::new));
public static final WorldContext<WorldProgram> INSTANCE = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/world"), new WorldMultiProgram.SpecLoader<>(WorldProgram::new));
public static final WorldContext<CrumblingProgram> CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), new WorldMultiProgram.SpecLoader<>(CrumblingProgram::new));
protected ProgramTemplate template;
protected final ResourceLocation name;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.backend.gl.shader;
package com.jozufozu.flywheel.backend.core;
import java.util.ArrayList;
import java.util.Collections;
@ -8,16 +8,21 @@ import java.util.Map;
import com.jozufozu.flywheel.backend.ShaderContext;
import com.jozufozu.flywheel.backend.ShaderLoader;
import com.jozufozu.flywheel.backend.gl.GlFog;
import com.jozufozu.flywheel.backend.gl.GlFogMode;
import com.jozufozu.flywheel.backend.core.shader.ExtensibleGlProgram;
import com.jozufozu.flywheel.backend.core.shader.GlFog;
import com.jozufozu.flywheel.backend.core.shader.GlFogMode;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram;
import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader;
import com.jozufozu.flywheel.backend.loading.Program;
public class FogSensitiveProgram<P extends GlProgram> implements IMultiProgram<P> {
public class WorldMultiProgram<P extends GlProgram> implements IMultiProgram<P> {
private final Map<GlFogMode, P> programs;
private final List<P> debugPrograms;
public FogSensitiveProgram(Map<GlFogMode, P> programs, List<P> debugPrograms) {
public WorldMultiProgram(Map<GlFogMode, P> programs, List<P> debugPrograms) {
this.programs = programs;
this.debugPrograms = debugPrograms;
}
@ -34,10 +39,10 @@ public class FogSensitiveProgram<P extends GlProgram> implements IMultiProgram<P
public static class SpecLoader<P extends GlProgram> implements ShaderSpecLoader<P> {
private final FogProgramLoader<P> fogProgramLoader;
private final ExtensibleGlProgram.Factory<P> factory;
public SpecLoader(FogProgramLoader<P> fogProgramLoader) {
this.fogProgramLoader = fogProgramLoader;
public SpecLoader(ExtensibleGlProgram.Factory<P> factory) {
this.factory = factory;
}
@Override
@ -49,7 +54,7 @@ public class FogSensitiveProgram<P extends GlProgram> implements IMultiProgram<P
for (String mode : modes) {
Program builder = ctx.loadProgram(loader, spec, Collections.singletonList(mode));
debugModes.add(fogProgramLoader.create(builder, GlFogMode.NONE.getFogFactory()));
debugModes.add(factory.create(builder, null));
}
Map<GlFogMode, P> programs = new EnumMap<>(GlFogMode.class);
@ -57,16 +62,12 @@ public class FogSensitiveProgram<P extends GlProgram> implements IMultiProgram<P
for (GlFogMode fogMode : GlFogMode.values()) {
Program builder = ctx.loadProgram(loader, spec, fogMode.getDefines());
programs.put(fogMode, fogProgramLoader.create(builder, fogMode.getFogFactory()));
programs.put(fogMode, factory.create(builder, Collections.singletonList(fogMode)));
}
return new FogSensitiveProgram<>(programs, debugModes);
return new WorldMultiProgram<>(programs, debugModes);
}
}
public interface FogProgramLoader<P extends GlProgram> {
P create(Program program, ProgramFogMode.Factory fogFactory);
}
}

View file

@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.core;
import java.util.ArrayList;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback;
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
@ -12,7 +13,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Matrix4f;
public class WorldTileRenderer<P extends BasicProgram> extends InstancedTileRenderer<P> {
public class WorldTileRenderer<P extends WorldProgram> extends InstancedTileRenderer<P> {
public static int MAX_ORIGIN_DISTANCE = 100;
public BlockPos originCoordinate = BlockPos.ZERO;

View file

@ -0,0 +1,62 @@
package com.jozufozu.flywheel.backend.core.shader;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.loading.Program;
/**
* A shader program that be arbitrarily "extended". This class can take in any number of program extensions, and
* will initialize them and then call their {@link IProgramExtension#bind() bind} function every subsequent time this
* program is bound. An "extension" is something that interacts with the shader program in a way that is invisible to
* the caller using the program. This is used by some programs to implement the different fog modes. Other uses might
* include binding extra textures to allow for blocks to have normal maps, for example. As the extensions are
* per-program, this also allows for same extra specialization within a
* {@link com.jozufozu.flywheel.backend.ShaderContext ShaderContext}.
*/
public class ExtensibleGlProgram extends GlProgram {
protected final List<IProgramExtension> extensions;
public ExtensibleGlProgram(Program program, @Nullable List<ProgramExtender> extensions) {
super(program);
if (extensions != null) {
this.extensions = extensions.stream()
.map(e -> e.create(this))
.collect(Collectors.toList());
} else {
this.extensions = Collections.emptyList();
}
}
@Override
public void bind() {
super.bind();
extensions.forEach(IProgramExtension::bind);
}
@Override
public String toString() {
return "ExtensibleGlProgram{" +
"name=" + name +
", extensions=" + extensions +
'}';
}
/**
* A factory interface to create {@link GlProgram}s parameterized by a list of extensions. This doesn't necessarily
* have to return an {@link ExtensibleGlProgram} if implementors want more flexibility for whatever reason.
*/
public interface Factory<P extends GlProgram> {
@Nonnull
P create(Program program, @Nullable List<ProgramExtender> fogFactory);
}
}

View file

@ -0,0 +1,81 @@
package com.jozufozu.flywheel.backend.core.shader;
import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import net.minecraft.util.ResourceLocation;
public abstract class FogMode {
public static class None implements IProgramExtension {
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_none");
public None(GlProgram program) {
}
@Override
public void bind() {
}
@Override
public ResourceLocation name() {
return NAME;
}
}
public static class Linear implements IProgramExtension {
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_linear");
private final int uFogColor;
private final int uFogRange;
public Linear(GlProgram program) {
this.uFogColor = program.getUniformLocation("uFogColor");
this.uFogRange = program.getUniformLocation("uFogRange");
}
@Override
public void bind() {
GL20.glUniform2f(uFogRange, GlFog.getFogStart(), GlFog.getFogEnd());
GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR);
}
@Override
public ResourceLocation name() {
return NAME;
}
}
public static class Exp2 implements IProgramExtension {
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_exp2");
private final int uFogColor;
private final int uFogDensity;
public Exp2(GlProgram program) {
this.uFogColor = program.getUniformLocation("uFogColor");
this.uFogDensity = program.getUniformLocation("uFogDensity");
}
@Override
public void bind() {
GL20.glUniform1f(uFogDensity, GlFog.getFogDensity());
GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR);
}
@Override
public ResourceLocation name() {
return NAME;
}
}
public interface Factory extends IProgramExtension {
}
}

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.backend.gl;
package com.jozufozu.flywheel.backend.core.shader;
import org.lwjgl.opengl.GL11;

View file

@ -0,0 +1,38 @@
package com.jozufozu.flywheel.backend.core.shader;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
public enum GlFogMode implements ProgramExtender {
NONE(FogMode.None::new),
LINEAR(FogMode.Linear::new, "USE_FOG_LINEAR"),
EXP2(FogMode.Exp2::new, "USE_FOG_EXP2"),
;
public static final String USE_FOG = "USE_FOG";
private final ProgramExtender fogFactory;
private final List<String> defines;
GlFogMode(ProgramExtender fogFactory) {
this.fogFactory = fogFactory;
this.defines = Collections.emptyList();
}
GlFogMode(ProgramExtender fogFactory, String name) {
this.fogFactory = fogFactory;
this.defines = Lists.newArrayList(USE_FOG, name);
}
public List<String> getDefines() {
return defines;
}
@Override
public IProgramExtension create(GlProgram program) {
return fogFactory.create(program);
}
}

View file

@ -0,0 +1,17 @@
package com.jozufozu.flywheel.backend.core.shader;
import net.minecraft.util.ResourceLocation;
/**
* A program extension to be passed to
*/
public interface IProgramExtension {
/**
* Bind the extra program state. It is recommended to grab the state information from global variables,
* or local variables passed through a {@link ProgramExtender} closure.
*/
void bind();
ResourceLocation name();
}

View file

@ -0,0 +1,18 @@
package com.jozufozu.flywheel.backend.core.shader;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
/**
* A factory interface for creating {@link IProgramExtension}s. These are what end up being passed in
* during shader program construction.
*/
public interface ProgramExtender {
/**
* Construct the extension, binding any necessary information using the provided {@link GlProgram}.
*
* @param program The program being extended.
* @return An extension object, possibly initialized using the program.
*/
IProgramExtension create(GlProgram program);
}

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.backend.gl.shader;
package com.jozufozu.flywheel.backend.core.shader;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,7 +1,10 @@
package com.jozufozu.flywheel.backend.gl.shader;
package com.jozufozu.flywheel.backend.core.shader;
import com.jozufozu.flywheel.backend.ShaderContext;
import com.jozufozu.flywheel.backend.ShaderLoader;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.gl.shader.IMultiProgram;
import com.jozufozu.flywheel.backend.gl.shader.ShaderSpecLoader;
import com.jozufozu.flywheel.backend.loading.Program;
public class SingleProgram<P extends GlProgram> implements IMultiProgram<P> {

View file

@ -1,33 +1,29 @@
package com.jozufozu.flywheel.backend.core;
package com.jozufozu.flywheel.backend.core.shader;
import static org.lwjgl.opengl.GL20.glUniform1f;
import static org.lwjgl.opengl.GL20.glUniform3f;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode;
import java.util.List;
import com.jozufozu.flywheel.backend.loading.Program;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.util.math.vector.Matrix4f;
public class BasicProgram extends GlProgram {
public class WorldProgram extends ExtensibleGlProgram {
protected final int uTime;
protected final int uViewProjection;
protected final int uCameraPos;
protected final ProgramFogMode fogMode;
protected int uBlockAtlas;
protected int uLightMap;
public BasicProgram(Program program, ProgramFogMode.Factory fogFactory) {
super(program);
public WorldProgram(Program program, List<ProgramExtender> fogFactory) {
super(program, fogFactory);
uTime = getUniformLocation("uTime");
uViewProjection = getUniformLocation("uViewProjection");
uCameraPos = getUniformLocation("uCameraPos");
fogMode = fogFactory.create(this);
bind();
registerSamplers();
unbind();
@ -55,7 +51,5 @@ public class BasicProgram extends GlProgram {
super.bind();
uploadTime(AnimationTickHolder.getRenderTime());
fogMode.bind();
}
}

View file

@ -1,37 +0,0 @@
package com.jozufozu.flywheel.backend.gl;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode;
public enum GlFogMode {
NONE(ProgramFogMode.None::new),
LINEAR(ProgramFogMode.Linear::new, "USE_FOG_LINEAR"),
EXP2(ProgramFogMode.Exp2::new, "USE_FOG_EXP2"),
;
public static final String USE_FOG = "USE_FOG";
private final ProgramFogMode.Factory fogFactory;
private final List<String> defines;
GlFogMode(ProgramFogMode.Factory fogFactory) {
this.fogFactory = fogFactory;
this.defines = Collections.emptyList();
}
GlFogMode(ProgramFogMode.Factory fogFactory, String name) {
this.fogFactory = fogFactory;
this.defines = Lists.newArrayList(USE_FOG, name);
}
public List<String> getDefines() {
return defines;
}
public ProgramFogMode.Factory getFogFactory() {
return fogFactory;
}
}

View file

@ -1,58 +0,0 @@
package com.jozufozu.flywheel.backend.gl.shader;
import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.backend.gl.GlFog;
public abstract class ProgramFogMode {
public abstract void bind();
public static class None extends ProgramFogMode {
public None(GlProgram program) {
}
@Override
public void bind() {
}
}
public static class Linear extends ProgramFogMode {
private final int uFogColor;
private final int uFogRange;
public Linear(GlProgram program) {
this.uFogColor = program.getUniformLocation("uFogColor");
this.uFogRange = program.getUniformLocation("uFogRange");
}
@Override
public void bind() {
GL20.glUniform2f(uFogRange, GlFog.getFogStart(), GlFog.getFogEnd());
GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR);
}
}
public static class Exp2 extends ProgramFogMode {
private final int uFogColor;
private final int uFogDensity;
public Exp2(GlProgram program) {
this.uFogColor = program.getUniformLocation("uFogColor");
this.uFogDensity = program.getUniformLocation("uFogDensity");
}
@Override
public void bind() {
GL20.glUniform1f(uFogDensity, GlFog.getFogDensity());
GL20.glUniform4fv(uFogColor, GlFog.FOG_COLOR);
}
}
public interface Factory {
ProgramFogMode create(GlProgram program);
}
}

View file

@ -2,6 +2,7 @@ package com.jozufozu.flywheel.backend.gl.shader;
import com.jozufozu.flywheel.backend.ShaderContext;
import com.jozufozu.flywheel.backend.ShaderLoader;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
public interface ShaderSpecLoader<P extends GlProgram> {

View file

@ -8,10 +8,10 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.core.WorldContext;
import com.jozufozu.flywheel.backend.core.materials.ModelData;
import com.jozufozu.flywheel.backend.core.materials.OrientedData;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
@ -25,7 +25,7 @@ import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public abstract class InstancedTileRenderer<P extends BasicProgram> {
public abstract class InstancedTileRenderer<P extends WorldProgram> {
public final WorldContext<P> context;

View file

@ -1,7 +1,7 @@
package com.jozufozu.flywheel.backend.instancing;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec;
import net.minecraft.util.ResourceLocation;

View file

@ -12,8 +12,8 @@ import org.lwjgl.opengl.GL11;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.core.PartialModel;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
import com.jozufozu.flywheel.backend.gl.shader.ShaderCallback;
import com.jozufozu.flywheel.util.BufferBuilderReader;
@ -34,7 +34,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
public class RenderMaterial<P extends BasicProgram, D extends InstanceData> {
public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
protected final InstancedTileRenderer<P> renderer;
protected final Cache<Object, InstancedModel<D>> models;

View file

@ -1,22 +1,24 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render;
import java.util.List;
import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.gl.shader.ProgramFogMode;
import com.jozufozu.flywheel.backend.core.shader.ProgramExtender;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.jozufozu.flywheel.backend.loading.Program;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Matrix4f;
public class ContraptionProgram extends BasicProgram {
public class ContraptionProgram extends WorldProgram {
protected final int uLightBoxSize;
protected final int uLightBoxMin;
protected final int uModel;
protected int uLightVolume;
public ContraptionProgram(Program program, ProgramFogMode.Factory fogFactory) {
public ContraptionProgram(Program program, List<ProgramExtender> fogFactory) {
super(program, fogFactory);
uLightBoxSize = getUniformLocation("uLightBoxSize");
uLightBoxMin = getUniformLocation("uLightBoxMin");

View file

@ -16,7 +16,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.core.WorldContext;
import com.jozufozu.flywheel.backend.gl.shader.FogSensitiveProgram;
import com.jozufozu.flywheel.backend.core.WorldMultiProgram;
import com.jozufozu.flywheel.backend.loading.ModelTemplate;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllMovementBehaviours;
@ -71,8 +71,8 @@ public class ContraptionRenderDispatcher {
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> STRUCTURE = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new);
public static final WorldContext<ContraptionProgram> TILES = new WorldContext<>(ctxRoot, new FogSensitiveProgram.SpecLoader<>(ContraptionProgram::new));
public static final WorldContext<ContraptionProgram> STRUCTURE = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new), () -> Stream.of(AllProgramSpecs.STRUCTURE), ModelTemplate::new);
public static final WorldContext<ContraptionProgram> TILES = new WorldContext<>(ctxRoot, new WorldMultiProgram.SpecLoader<>(ContraptionProgram::new));
public static void tick() {
if (Minecraft.getInstance().isGamePaused()) return;

View file

@ -5,8 +5,8 @@ import java.util.List;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.RenderWork;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.core.WorldTileRenderer;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.AllFluids;
@ -145,7 +145,7 @@ public class ClientEvents {
if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) {
CreateClient.invalidateRenderers(world);
AnimationTickHolder.reset();
WorldTileRenderer<BasicProgram> renderer = Backend.tileRenderer.get(world);
WorldTileRenderer<WorldProgram> renderer = Backend.tileRenderer.get(world);
renderer.invalidate();
((ClientWorld) world).loadedTileEntityList.forEach(renderer::add);
}

View file

@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.backend.gl.GlFog;
import com.jozufozu.flywheel.backend.core.shader.GlFog;
import com.mojang.blaze3d.platform.GlStateManager;
@Mixin(GlStateManager.class)

View file

@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.core.BasicProgram;
import com.jozufozu.flywheel.backend.core.WorldTileRenderer;
import com.jozufozu.flywheel.backend.core.shader.WorldProgram;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -47,7 +47,7 @@ public class TileWorldHookMixin {
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
private void onChunkUnload(CallbackInfo ci) {
if (isRemote) {
WorldTileRenderer<BasicProgram> kineticRenderer = Backend.tileRenderer.get(self);
WorldTileRenderer<WorldProgram> kineticRenderer = Backend.tileRenderer.get(self);
for (TileEntity tile : tileEntitiesToBeRemoved) {
kineticRenderer.remove(tile);
}

View file

@ -3,7 +3,7 @@ package com.simibubi.create.foundation.render;
import static com.jozufozu.flywheel.backend.Backend.register;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.gl.shader.ProgramSpec;
import com.jozufozu.flywheel.backend.core.shader.ProgramSpec;
import com.simibubi.create.Create;
import net.minecraft.util.ResourceLocation;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.foundation.render.effects;
import com.jozufozu.flywheel.backend.ShaderContext;
import com.jozufozu.flywheel.backend.ShaderLoader;
import com.jozufozu.flywheel.backend.gl.shader.SingleProgram;
import com.jozufozu.flywheel.backend.core.shader.SingleProgram;
import com.jozufozu.flywheel.backend.loading.ShaderTransformer;
import com.simibubi.create.foundation.render.AllProgramSpecs;