mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 01:43:53 +01:00
Diffuse fixes II
- Add ForcedDiffuseState to push/pop forced diffuse calculators - Transform the SBB instead of the global PoseStack when applying ponder transforms - Tweak used shaders in RenderTypes - Rename LerpedFloat.Interpolater to Interpolator - Update Flywheel
This commit is contained in:
parent
22af1604b4
commit
3aa0644426
9 changed files with 60 additions and 29 deletions
|
@ -19,7 +19,7 @@ parchment_version = 2022.01.23
|
||||||
|
|
||||||
# dependency versions
|
# dependency versions
|
||||||
registrate_version = MC1.18-1.0.21
|
registrate_version = MC1.18-1.0.21
|
||||||
flywheel_version = 1.18-0.6.1.58
|
flywheel_version = 1.18-0.6.1.60
|
||||||
jei_minecraft_version = 1.18.1
|
jei_minecraft_version = 1.18.1
|
||||||
jei_version = 9.2.1.69
|
jei_version = 9.2.1.69
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ public class SchematicRenderer {
|
||||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||||
if (!active)
|
if (!active)
|
||||||
return;
|
return;
|
||||||
buffer.getBuffer(RenderType.solid());
|
|
||||||
for (RenderType layer : RenderType.chunkBufferLayers()) {
|
for (RenderType layer : RenderType.chunkBufferLayers()) {
|
||||||
if (!usedBlockRenderLayers.contains(layer))
|
if (!usedBlockRenderLayers.contains(layer))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -18,7 +18,7 @@ import javax.annotation.Nullable;
|
||||||
import org.apache.commons.lang3.mutable.MutableDouble;
|
import org.apache.commons.lang3.mutable.MutableDouble;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.math.Matrix4f;
|
import com.mojang.math.Matrix4f;
|
||||||
|
@ -32,6 +32,7 @@ import com.simibubi.create.foundation.ponder.element.WorldSectionElement;
|
||||||
import com.simibubi.create.foundation.ponder.instruction.HideAllInstruction;
|
import com.simibubi.create.foundation.ponder.instruction.HideAllInstruction;
|
||||||
import com.simibubi.create.foundation.ponder.instruction.PonderInstruction;
|
import com.simibubi.create.foundation.ponder.instruction.PonderInstruction;
|
||||||
import com.simibubi.create.foundation.ponder.ui.PonderUI;
|
import com.simibubi.create.foundation.ponder.ui.PonderUI;
|
||||||
|
import com.simibubi.create.foundation.render.ForcedDiffuseState;
|
||||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.Pair;
|
import com.simibubi.create.foundation.utility.Pair;
|
||||||
|
@ -225,7 +226,7 @@ public class PonderScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) {
|
public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) {
|
||||||
OptifineHandler.pushForceDiffuse();
|
ForcedDiffuseState.pushCalculator(DiffuseLightCalculator.DEFAULT);
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Entity prevRVE = mc.cameraEntity;
|
Entity prevRVE = mc.cameraEntity;
|
||||||
|
@ -244,7 +245,7 @@ public class PonderScene {
|
||||||
outliner.renderOutlines(ms, buffer, pt);
|
outliner.renderOutlines(ms, buffer, pt);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
OptifineHandler.popForceDiffuse();
|
ForcedDiffuseState.popCalculator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderOverlay(PonderUI screen, PoseStack ms, float partialTicks) {
|
public void renderOverlay(PonderUI screen, PoseStack ms, float partialTicks) {
|
||||||
|
|
|
@ -348,12 +348,6 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
@Override
|
@Override
|
||||||
protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade,
|
protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade,
|
||||||
float pt) {
|
float pt) {
|
||||||
transformMS(ms, pt);
|
|
||||||
renderStructure(world, ms, buffer, type, fade);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void renderStructure(PonderWorld world, PoseStack ms, MultiBufferSource buffer, RenderType type,
|
|
||||||
float fade) {
|
|
||||||
SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE;
|
SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE;
|
||||||
|
|
||||||
int code = hashCode() ^ world.hashCode();
|
int code = hashCode() ^ world.hashCode();
|
||||||
|
@ -367,9 +361,9 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
if (contraptionBuffer.isEmpty())
|
if (contraptionBuffer.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
transformMS(contraptionBuffer.getTransforms(), pt);
|
||||||
int light = lightCoordsFromFade(fade);
|
int light = lightCoordsFromFade(fade);
|
||||||
contraptionBuffer
|
contraptionBuffer
|
||||||
.fullNormalTransform()
|
|
||||||
.light(light)
|
.light(light)
|
||||||
.renderInto(ms, buffer.getBuffer(type));
|
.renderInto(ms, buffer.getBuffer(type));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.simibubi.create.foundation.render;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
|
||||||
|
public final class ForcedDiffuseState {
|
||||||
|
private static final ThreadLocal<ObjectArrayList<DiffuseLightCalculator>> FORCED_DIFFUSE = ThreadLocal.withInitial(ObjectArrayList::new);
|
||||||
|
|
||||||
|
private ForcedDiffuseState() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void pushCalculator(DiffuseLightCalculator calculator) {
|
||||||
|
FORCED_DIFFUSE.get().push(calculator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void popCalculator() {
|
||||||
|
FORCED_DIFFUSE.get().pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static DiffuseLightCalculator getForcedCalculator() {
|
||||||
|
ObjectArrayList<DiffuseLightCalculator> stack = FORCED_DIFFUSE.get();
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return stack.top();
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ public class RenderTypes extends RenderStateShard {
|
||||||
public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) {
|
public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) {
|
||||||
return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")),
|
return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")),
|
||||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
.setShaderState(cull ? RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER : RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
||||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setCullState(cull ? CULL : NO_CULL)
|
.setCullState(cull ? CULL : NO_CULL)
|
||||||
|
@ -42,7 +42,7 @@ public class RenderTypes extends RenderStateShard {
|
||||||
public static RenderType getGlowingSolid(ResourceLocation texture) {
|
public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||||
return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||||
true, false, RenderType.CompositeState.builder()
|
true, false, RenderType.CompositeState.builder()
|
||||||
.setShaderState(NEW_ENTITY_SHADER)
|
.setShaderState(RENDERTYPE_BEACON_BEAM_SHADER)
|
||||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||||
.setLightmapState(LIGHTMAP)
|
.setLightmapState(LIGHTMAP)
|
||||||
.setOverlayState(OVERLAY)
|
.setOverlayState(OVERLAY)
|
||||||
|
@ -58,7 +58,7 @@ public class RenderTypes extends RenderStateShard {
|
||||||
public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||||
return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||||
256, true, true, RenderType.CompositeState.builder()
|
256, true, true, RenderType.CompositeState.builder()
|
||||||
.setShaderState(NEW_ENTITY_SHADER)
|
.setShaderState(RENDERTYPE_BEACON_BEAM_SHADER)
|
||||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setCullState(NO_CULL)
|
.setCullState(NO_CULL)
|
||||||
|
@ -78,7 +78,6 @@ public class RenderTypes extends RenderStateShard {
|
||||||
false, RenderType.CompositeState.builder()
|
false, RenderType.CompositeState.builder()
|
||||||
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
||||||
.setTextureState(BLOCK_SHEET)
|
.setTextureState(BLOCK_SHEET)
|
||||||
.setTransparencyState(NO_TRANSPARENCY)
|
|
||||||
.setLightmapState(LIGHTMAP)
|
.setLightmapState(LIGHTMAP)
|
||||||
.setOverlayState(OVERLAY)
|
.setOverlayState(OVERLAY)
|
||||||
.createCompositeState(true));
|
.createCompositeState(true));
|
||||||
|
@ -89,7 +88,7 @@ public class RenderTypes extends RenderStateShard {
|
||||||
|
|
||||||
private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.create(createLayerName("item_partial_translucent"),
|
private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.create(createLayerName("item_partial_translucent"),
|
||||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||||
.setTextureState(BLOCK_SHEET)
|
.setTextureState(BLOCK_SHEET)
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setLightmapState(LIGHTMAP)
|
.setLightmapState(LIGHTMAP)
|
||||||
|
@ -102,7 +101,7 @@ public class RenderTypes extends RenderStateShard {
|
||||||
|
|
||||||
private static final RenderType FLUID = RenderType.create(createLayerName("fluid"),
|
private static final RenderType FLUID = RenderType.create(createLayerName("fluid"),
|
||||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||||
.setLightmapState(LIGHTMAP)
|
.setLightmapState(LIGHTMAP)
|
||||||
|
|
|
@ -98,10 +98,13 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
final Vector3f normal = new Vector3f();
|
final Vector3f normal = new Vector3f();
|
||||||
final Vector4f lightPos = new Vector4f();
|
final Vector4f lightPos = new Vector4f();
|
||||||
|
|
||||||
final boolean disableDiffuseMult = this.disableDiffuseMult || !OptifineHandler.shouldApplyDiffuse();
|
DiffuseLightCalculator diffuseCalculator = ForcedDiffuseState.getForcedCalculator();
|
||||||
DiffuseLightCalculator diffuseCalculator = this.diffuseCalculator;
|
final boolean disableDiffuseMult = this.disableDiffuseMult || (OptifineHandler.isUsingShaders() && diffuseCalculator == null);
|
||||||
if (diffuseCalculator == null) {
|
if (diffuseCalculator == null) {
|
||||||
diffuseCalculator = DiffuseLightCalculator.forCurrentLevel();
|
diffuseCalculator = this.diffuseCalculator;
|
||||||
|
if (diffuseCalculator == null) {
|
||||||
|
diffuseCalculator = DiffuseLightCalculator.forCurrentLevel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int vertexCount = template.getVertexCount();
|
final int vertexCount = template.getVertexCount();
|
||||||
|
@ -218,6 +221,10 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
return template.isEmpty();
|
return template.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PoseStack getTransforms() {
|
||||||
|
return transforms;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SuperByteBuffer translate(double x, double y, double z) {
|
public SuperByteBuffer translate(double x, double y, double z) {
|
||||||
transforms.translate(x, y, z);
|
transforms.translate(x, y, z);
|
||||||
|
@ -439,8 +446,8 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface IVertexLighter {
|
public interface VertexLighter {
|
||||||
public int getPackedLight(float x, float y, float z);
|
int getPackedLight(float x, float y, float z);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,9 @@ public class TileEntityRenderHelper {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
|
||||||
String message = "TileEntity " + tileEntity.getType()
|
String message = "BlockEntity " + tileEntity.getType()
|
||||||
.getRegistryName()
|
.getRegistryName()
|
||||||
.toString() + " didn't want to render while moved.\n";
|
.toString() + " could not be rendered virtually.";
|
||||||
if (AllConfigs.CLIENT.explainRenderErrors.get())
|
if (AllConfigs.CLIENT.explainRenderErrors.get())
|
||||||
Create.LOGGER.error(message, e);
|
Create.LOGGER.error(message, e);
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.util.Mth;
|
||||||
// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle
|
// InterpolatedChasingValue, InterpolatedValue, InterpolatedChasingAngle, InterpolatedAngle
|
||||||
public class LerpedFloat {
|
public class LerpedFloat {
|
||||||
|
|
||||||
protected Interpolater interpolater;
|
protected Interpolator interpolator;
|
||||||
protected float previousValue;
|
protected float previousValue;
|
||||||
protected float value;
|
protected float value;
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public class LerpedFloat {
|
||||||
|
|
||||||
protected boolean forcedSync;
|
protected boolean forcedSync;
|
||||||
|
|
||||||
public LerpedFloat(Interpolater interpolater) {
|
public LerpedFloat(Interpolator interpolator) {
|
||||||
this.interpolater = interpolater;
|
this.interpolator = interpolator;
|
||||||
startWithValue(0);
|
startWithValue(0);
|
||||||
forcedSync = true;
|
forcedSync = true;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public class LerpedFloat {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Interpolater {
|
public interface Interpolator {
|
||||||
float interpolate(double progress, double current, double target);
|
float interpolate(double progress, double current, double target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue