mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-07 11:43:43 +01:00
Update Flywheel + diffuse fixes
- Fix ponder diffuse when using shaders - Partially fix incorrect diffuse formula being used in the nether - Invalidate schematic renderers at the appropriate time
This commit is contained in:
parent
3c71e8041b
commit
99e94f7c6e
13 changed files with 84 additions and 50 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.56
|
flywheel_version = 1.18-0.6.1.58
|
||||||
jei_minecraft_version = 1.18.1
|
jei_minecraft_version = 1.18.1
|
||||||
jei_version = 9.2.1.69
|
jei_version = 9.2.1.69
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ public class CreateClient {
|
||||||
public static void invalidateRenderers() {
|
public static void invalidateRenderers() {
|
||||||
BUFFER_CACHE.invalidate();
|
BUFFER_CACHE.invalidate();
|
||||||
|
|
||||||
|
SCHEMATIC_HANDLER.updateRenderers();
|
||||||
ContraptionRenderDispatcher.reset();
|
ContraptionRenderDispatcher.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
||||||
@Override
|
@Override
|
||||||
protected void renderSafe(PortableStorageInterfaceTileEntity te, float partialTicks, PoseStack ms,
|
protected void renderSafe(PortableStorageInterfaceTileEntity te, float partialTicks, PoseStack ms,
|
||||||
MultiBufferSource buffer, int light, int overlay) {
|
MultiBufferSource buffer, int light, int overlay) {
|
||||||
if (Backend.isOn()) return;
|
if (Backend.canUseInstancing(te.getLevel()))
|
||||||
|
return;
|
||||||
|
|
||||||
BlockState blockState = te.getBlockState();
|
BlockState blockState = te.getBlockState();
|
||||||
float progress = te.getExtensionDistance(partialTicks);
|
float progress = te.getExtensionDistance(partialTicks);
|
||||||
|
|
|
@ -9,7 +9,8 @@ import com.jozufozu.flywheel.core.Materials;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
import com.jozufozu.flywheel.core.materials.model.ModelData;
|
||||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||||
|
@ -30,7 +31,7 @@ import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
public class DeployerActorInstance extends ActorInstance {
|
public class DeployerActorInstance extends ActorInstance {
|
||||||
|
|
||||||
private final MatrixTransformStack stack = new MatrixTransformStack();
|
private final PoseStack stack = new PoseStack();
|
||||||
Direction facing;
|
Direction facing;
|
||||||
boolean stationaryTimer;
|
boolean stationaryTimer;
|
||||||
|
|
||||||
|
@ -94,27 +95,29 @@ public class DeployerActorInstance extends ActorInstance {
|
||||||
|
|
||||||
Vec3 offset = Vec3.atLowerCornerOf(facing.getNormal()).scale(factor);
|
Vec3 offset = Vec3.atLowerCornerOf(facing.getNormal()).scale(factor);
|
||||||
|
|
||||||
stack.setIdentity()
|
TransformStack tstack = TransformStack.cast(stack);
|
||||||
.translate(context.localPos)
|
stack.setIdentity();
|
||||||
|
tstack.translate(context.localPos)
|
||||||
.translate(offset);
|
.translate(offset);
|
||||||
|
|
||||||
transformModel(stack, pole, hand, yRot, xRot, zRot);
|
transformModel(stack, pole, hand, yRot, xRot, zRot);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transformModel(MatrixTransformStack msr, ModelData pole, ModelData hand, float yRot, float xRot, float zRot) {
|
static void transformModel(PoseStack stack, ModelData pole, ModelData hand, float yRot, float xRot, float zRot) {
|
||||||
|
TransformStack tstack = TransformStack.cast(stack);
|
||||||
|
|
||||||
msr.centre();
|
tstack.centre();
|
||||||
msr.rotate(Direction.UP, (float) ((yRot) / 180 * Math.PI));
|
tstack.rotate(Direction.UP, (float) ((yRot) / 180 * Math.PI));
|
||||||
msr.rotate(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
tstack.rotate(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
||||||
|
|
||||||
msr.pushPose();
|
stack.pushPose();
|
||||||
msr.rotate(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
|
tstack.rotate(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
|
||||||
msr.unCentre();
|
tstack.unCentre();
|
||||||
pole.setTransform(msr.unwrap());
|
pole.setTransform(stack);
|
||||||
msr.popPose();
|
stack.popPose();
|
||||||
|
|
||||||
msr.unCentre();
|
tstack.unCentre();
|
||||||
|
|
||||||
hand.setTransform(msr.unwrap());
|
hand.setTransform(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
|
||||||
import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import com.mojang.math.Vector3f;
|
import com.mojang.math.Vector3f;
|
||||||
|
@ -197,7 +197,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
||||||
float time = AnimationTickHolder.getRenderTime(context.world) / 20;
|
float time = AnimationTickHolder.getRenderTime(context.world) / 20;
|
||||||
float angle = (time * speed) % 360;
|
float angle = (time * speed) % 360;
|
||||||
|
|
||||||
new MatrixTransformStack(m)
|
TransformStack.cast(m)
|
||||||
.centre()
|
.centre()
|
||||||
.rotateY(axis == Axis.Z ? 90 : 0)
|
.rotateY(axis == Axis.Z ? 90 : 0)
|
||||||
.rotateZ(axis.isHorizontal() ? 90 : 0)
|
.rotateZ(axis.isHorizontal() ? 90 : 0)
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class CustomRotationParticle extends SimpleAnimatedParticle {
|
||||||
float maxU = mirror ? getU0() : getU1();
|
float maxU = mirror ? getU0() : getU1();
|
||||||
float minV = getV0();
|
float minV = getV0();
|
||||||
float maxV = getV1();
|
float maxV = getV1();
|
||||||
int brightness = OptifineHandler.usingShaders() ? LightTexture.pack(12, 15 ) : getLightColor(partialTicks);
|
int brightness = OptifineHandler.isUsingShaders() ? LightTexture.pack(12, 15) : getLightColor(partialTicks);
|
||||||
builder.vertex(vertices[0].x(), vertices[0].y(), vertices[0].z()).uv(maxU, maxV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
builder.vertex(vertices[0].x(), vertices[0].y(), vertices[0].z()).uv(maxU, maxV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
||||||
builder.vertex(vertices[1].x(), vertices[1].y(), vertices[1].z()).uv(maxU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
builder.vertex(vertices[1].x(), vertices[1].y(), vertices[1].z()).uv(maxU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
||||||
builder.vertex(vertices[2].x(), vertices[2].y(), vertices[2].z()).uv(minU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
builder.vertex(vertices[2].x(), vertices[2].y(), vertices[2].z()).uv(minU, minV).color(rCol, gCol, bCol, alpha).uv2(brightness).endVertex();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.simibubi.create.Create;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||||
|
@ -142,10 +143,15 @@ public class SchematicWorld extends WrappedWorld implements ServerLevelAccessor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBrightness(LightLayer p_226658_1_, BlockPos p_226658_2_) {
|
public int getBrightness(LightLayer lightLayer, BlockPos pos) {
|
||||||
return 15;
|
return 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getShade(Direction face, boolean hasShade) {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LevelTickAccess<Block> getBlockTicks() {
|
public LevelTickAccess<Block> getBlockTicks() {
|
||||||
return BlackholeTickAccess.emptyLevelList();
|
return BlackholeTickAccess.emptyLevelList();
|
||||||
|
|
|
@ -196,6 +196,12 @@ public class SchematicHandler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateRenderers() {
|
||||||
|
for (SchematicRenderer renderer : renderers) {
|
||||||
|
renderer.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IIngameOverlay getOverlayRenderer() {
|
public IIngameOverlay getOverlayRenderer() {
|
||||||
return overlayRenderer;
|
return overlayRenderer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
|
@ -64,7 +65,7 @@ public class SchematicRenderer {
|
||||||
if (mc.level == null || mc.player == null || !changed)
|
if (mc.level == null || mc.player == null || !changed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
redraw(mc);
|
redraw();
|
||||||
changed = false;
|
changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,18 +77,17 @@ public class SchematicRenderer {
|
||||||
if (!usedBlockRenderLayers.contains(layer))
|
if (!usedBlockRenderLayers.contains(layer))
|
||||||
continue;
|
continue;
|
||||||
SuperByteBuffer superByteBuffer = bufferCache.get(layer);
|
SuperByteBuffer superByteBuffer = bufferCache.get(layer);
|
||||||
superByteBuffer.disableDiffuseMult();
|
|
||||||
superByteBuffer.renderInto(ms, buffer.getBuffer(layer));
|
superByteBuffer.renderInto(ms, buffer.getBuffer(layer));
|
||||||
}
|
}
|
||||||
TileEntityRenderHelper.renderTileEntities(schematic, schematic.getRenderedTileEntities(), ms, buffer);
|
TileEntityRenderHelper.renderTileEntities(schematic, schematic.getRenderedTileEntities(), ms, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void redraw(Minecraft minecraft) {
|
protected void redraw() {
|
||||||
usedBlockRenderLayers.clear();
|
usedBlockRenderLayers.clear();
|
||||||
startedBufferBuilders.clear();
|
startedBufferBuilders.clear();
|
||||||
|
|
||||||
final SchematicWorld blockAccess = schematic;
|
final SchematicWorld blockAccess = schematic;
|
||||||
final BlockRenderDispatcher blockRendererDispatcher = minecraft.getBlockRenderer();
|
final BlockRenderDispatcher blockRendererDispatcher = ModelUtil.VANILLA_RENDERER;
|
||||||
|
|
||||||
List<BlockState> blockstates = new LinkedList<>();
|
List<BlockState> blockstates = new LinkedList<>();
|
||||||
Map<RenderType, BufferBuilder> buffers = new HashMap<>();
|
Map<RenderType, BufferBuilder> buffers = new HashMap<>();
|
||||||
|
|
|
@ -33,8 +33,8 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.inventory.InventoryMenu;
|
import net.minecraft.world.inventory.InventoryMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
import net.minecraft.world.level.block.BaseFireBlock;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.FireBlock;
|
|
||||||
import net.minecraft.world.level.block.LiquidBlock;
|
import net.minecraft.world.level.block.LiquidBlock;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.material.Fluid;
|
import net.minecraft.world.level.material.Fluid;
|
||||||
|
@ -208,7 +208,7 @@ public class GuiGameElement {
|
||||||
@Override
|
@Override
|
||||||
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
protected void renderModel(BlockRenderDispatcher blockRenderer, MultiBufferSource.BufferSource buffer,
|
||||||
RenderType renderType, VertexConsumer vb, PoseStack ms) {
|
RenderType renderType, VertexConsumer vb, PoseStack ms) {
|
||||||
if (blockState.getBlock() instanceof FireBlock) {
|
if (blockState.getBlock() instanceof BaseFireBlock) {
|
||||||
Lighting.setupForFlatItems();
|
Lighting.setupForFlatItems();
|
||||||
blockRenderer.renderSingleBlock(blockState, ms, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
blockRenderer.renderSingleBlock(blockState, ms, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
||||||
VirtualEmptyModelData.INSTANCE);
|
VirtualEmptyModelData.INSTANCE);
|
||||||
|
|
|
@ -18,6 +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.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;
|
||||||
|
@ -224,6 +225,7 @@ public class PonderScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) {
|
public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) {
|
||||||
|
OptifineHandler.pushForceDiffuse();
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Entity prevRVE = mc.cameraEntity;
|
Entity prevRVE = mc.cameraEntity;
|
||||||
|
@ -242,6 +244,7 @@ public class PonderScene {
|
||||||
outliner.renderOutlines(ms, buffer, pt);
|
outliner.renderOutlines(ms, buffer, pt);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
|
OptifineHandler.popForceDiffuse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderOverlay(PonderUI screen, PoseStack ms, float partialTicks) {
|
public void renderOverlay(PonderUI screen, PoseStack ms, float partialTicks) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.model.ModelUtil;
|
||||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||||
|
@ -298,13 +299,6 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
tileEntity.getBlockPos(), tileEntity.getBlockState(), tileEntity)));
|
tileEntity.getBlockPos(), tileEntity.getBlockState(), tileEntity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade,
|
|
||||||
float pt) {
|
|
||||||
transformMS(ms, pt);
|
|
||||||
renderStructure(world, ms, buffer, type, fade);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) {
|
public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) {
|
||||||
int light = -1;
|
int light = -1;
|
||||||
|
@ -342,8 +336,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
.pose(),
|
.pose(),
|
||||||
overlayMS.last()
|
overlayMS.last()
|
||||||
.normal());
|
.normal());
|
||||||
Minecraft.getInstance()
|
ModelUtil.VANILLA_RENDERER
|
||||||
.getBlockRenderer()
|
|
||||||
.renderBatched(world.getBlockState(pos), pos, world, ms, builder, true, new Random(),
|
.renderBatched(world.getBlockState(pos), pos, world, ms, builder, true, new Random(),
|
||||||
EmptyModelData.INSTANCE);
|
EmptyModelData.INSTANCE);
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
|
@ -352,13 +345,21 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderLayer(PonderWorld world, MultiBufferSource buffer, RenderType type, PoseStack ms, float fade,
|
||||||
|
float pt) {
|
||||||
|
transformMS(ms, pt);
|
||||||
|
renderStructure(world, ms, buffer, type, fade);
|
||||||
|
}
|
||||||
|
|
||||||
protected void renderStructure(PonderWorld world, PoseStack ms, MultiBufferSource buffer, RenderType type,
|
protected void renderStructure(PonderWorld world, PoseStack ms, MultiBufferSource buffer, RenderType type,
|
||||||
float fade) {
|
float fade) {
|
||||||
SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE;
|
SuperByteBufferCache bufferCache = CreateClient.BUFFER_CACHE;
|
||||||
int code = hashCode() ^ world.hashCode();
|
|
||||||
|
|
||||||
|
int code = hashCode() ^ world.hashCode();
|
||||||
Pair<Integer, Integer> key = Pair.of(code, RenderType.chunkBufferLayers()
|
Pair<Integer, Integer> key = Pair.of(code, RenderType.chunkBufferLayers()
|
||||||
.indexOf(type));
|
.indexOf(type));
|
||||||
|
|
||||||
if (redraw)
|
if (redraw)
|
||||||
bufferCache.invalidate(DOC_WORLD_SECTION, key);
|
bufferCache.invalidate(DOC_WORLD_SECTION, key);
|
||||||
SuperByteBuffer contraptionBuffer =
|
SuperByteBuffer contraptionBuffer =
|
||||||
|
@ -367,7 +368,9 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int light = lightCoordsFromFade(fade);
|
int light = lightCoordsFromFade(fade);
|
||||||
contraptionBuffer.light(light)
|
contraptionBuffer
|
||||||
|
.fullNormalTransform()
|
||||||
|
.light(light)
|
||||||
.renderInto(ms, buffer.getBuffer(type));
|
.renderInto(ms, buffer.getBuffer(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,8 +408,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
|
|
||||||
private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) {
|
private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) {
|
||||||
ForgeHooksClient.setRenderType(layer);
|
ForgeHooksClient.setRenderType(layer);
|
||||||
BlockRenderDispatcher dispatcher = Minecraft.getInstance()
|
BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
|
||||||
.getBlockRenderer();
|
|
||||||
PoseStack ms = new PoseStack();
|
PoseStack ms = new PoseStack();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
BufferBuilder builder = new BufferBuilder(512);
|
BufferBuilder builder = new BufferBuilder(512);
|
||||||
|
@ -415,7 +417,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
|
|
||||||
section.forEach(pos -> {
|
section.forEach(pos -> {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
FluidState ifluidstate = world.getFluidState(pos);
|
FluidState fluidState = world.getFluidState(pos);
|
||||||
|
|
||||||
ms.pushPose();
|
ms.pushPose();
|
||||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
@ -426,8 +428,8 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
||||||
tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
|
tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ifluidstate.isEmpty() && ItemBlockRenderTypes.canRenderInLayer(ifluidstate, layer))
|
if (!fluidState.isEmpty() && ItemBlockRenderTypes.canRenderInLayer(fluidState, layer))
|
||||||
dispatcher.renderLiquid(pos, world, builder, ifluidstate);
|
dispatcher.renderLiquid(pos, world, builder, fluidState);
|
||||||
|
|
||||||
ms.popPose();
|
ms.popPose();
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.foundation.render;
|
||||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
import com.jozufozu.flywheel.backend.OptifineHandler;
|
||||||
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
import com.jozufozu.flywheel.core.vertex.BlockVertexList;
|
||||||
|
import com.jozufozu.flywheel.util.DiffuseLightCalculator;
|
||||||
import com.jozufozu.flywheel.util.transform.Rotate;
|
import com.jozufozu.flywheel.util.transform.Rotate;
|
||||||
import com.jozufozu.flywheel.util.transform.Scale;
|
import com.jozufozu.flywheel.util.transform.Scale;
|
||||||
import com.jozufozu.flywheel.util.transform.TStack;
|
import com.jozufozu.flywheel.util.transform.TStack;
|
||||||
|
@ -29,7 +30,6 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
|
||||||
|
|
||||||
public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperByteBuffer>, Rotate<SuperByteBuffer>, TStack<SuperByteBuffer> {
|
public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperByteBuffer>, Rotate<SuperByteBuffer>, TStack<SuperByteBuffer> {
|
||||||
|
|
||||||
|
@ -42,13 +42,14 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
private boolean shouldColor;
|
private boolean shouldColor;
|
||||||
private int r, g, b, a;
|
private int r, g, b, a;
|
||||||
private boolean disableDiffuseMult;
|
private boolean disableDiffuseMult;
|
||||||
|
private DiffuseLightCalculator diffuseCalculator;
|
||||||
|
|
||||||
// Vertex Texture Coords
|
// Vertex Texture Coords
|
||||||
private SpriteShiftFunc spriteShiftFunc;
|
private SpriteShiftFunc spriteShiftFunc;
|
||||||
|
|
||||||
// Vertex Overlay Color
|
// Vertex Overlay Color
|
||||||
private boolean hasOverlay;
|
private boolean hasOverlay;
|
||||||
private int overlay = OverlayTexture.NO_OVERLAY;;
|
private int overlay = OverlayTexture.NO_OVERLAY;
|
||||||
|
|
||||||
// Vertex Lighting
|
// Vertex Lighting
|
||||||
private boolean useWorldLight;
|
private boolean useWorldLight;
|
||||||
|
@ -97,8 +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();
|
||||||
|
|
||||||
float f = .5f;
|
final boolean disableDiffuseMult = this.disableDiffuseMult || !OptifineHandler.shouldApplyDiffuse();
|
||||||
int vertexCount = template.getVertexCount();
|
DiffuseLightCalculator diffuseCalculator = this.diffuseCalculator;
|
||||||
|
if (diffuseCalculator == null) {
|
||||||
|
diffuseCalculator = DiffuseLightCalculator.forCurrentLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
final int vertexCount = template.getVertexCount();
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (int i = 0; i < vertexCount; i++) {
|
||||||
float x = template.getX(i);
|
float x = template.getX(i);
|
||||||
float y = template.getY(i);
|
float y = template.getY(i);
|
||||||
|
@ -130,10 +136,10 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
b = template.getB(i);
|
b = template.getB(i);
|
||||||
a = template.getA(i);
|
a = template.getA(i);
|
||||||
}
|
}
|
||||||
if (disableDiffuseMult || OptifineHandler.usingShaders()) {
|
if (disableDiffuseMult) {
|
||||||
builder.color(r, g, b, a);
|
builder.color(r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
float instanceDiffuse = LightUtil.diffuseLight(nx, ny, nz);
|
float instanceDiffuse = diffuseCalculator.getDiffuse(nx, ny, nz);
|
||||||
int colorR = transformColor(r, instanceDiffuse);
|
int colorR = transformColor(r, instanceDiffuse);
|
||||||
int colorG = transformColor(g, instanceDiffuse);
|
int colorG = transformColor(g, instanceDiffuse);
|
||||||
int colorB = transformColor(b, instanceDiffuse);
|
int colorB = transformColor(b, instanceDiffuse);
|
||||||
|
@ -154,7 +160,7 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
|
|
||||||
int light;
|
int light;
|
||||||
if (useWorldLight) {
|
if (useWorldLight) {
|
||||||
lightPos.set(((x - f) * 15 / 16f) + f, (y - f) * 15 / 16f + f, (z - f) * 15 / 16f + f, 1F);
|
lightPos.set(((x - .5f) * 15 / 16f) + .5f, (y - .5f) * 15 / 16f + .5f, (z - .5f) * 15 / 16f + .5f, 1f);
|
||||||
lightPos.transform(localTransforms);
|
lightPos.transform(localTransforms);
|
||||||
if (lightTransform != null) {
|
if (lightTransform != null) {
|
||||||
lightPos.transform(lightTransform);
|
lightPos.transform(lightTransform);
|
||||||
|
@ -195,6 +201,7 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
b = 0;
|
b = 0;
|
||||||
a = 0;
|
a = 0;
|
||||||
disableDiffuseMult = false;
|
disableDiffuseMult = false;
|
||||||
|
diffuseCalculator = null;
|
||||||
spriteShiftFunc = null;
|
spriteShiftFunc = null;
|
||||||
hasOverlay = false;
|
hasOverlay = false;
|
||||||
overlay = OverlayTexture.NO_OVERLAY;
|
overlay = OverlayTexture.NO_OVERLAY;
|
||||||
|
@ -296,6 +303,11 @@ public class SuperByteBuffer implements Scale<SuperByteBuffer>, Translate<SuperB
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer diffuseCalculator(DiffuseLightCalculator diffuseCalculator) {
|
||||||
|
this.diffuseCalculator = diffuseCalculator;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public SuperByteBuffer shiftUV(SpriteShiftEntry entry) {
|
public SuperByteBuffer shiftUV(SpriteShiftEntry entry) {
|
||||||
this.spriteShiftFunc = (builder, u, v) -> {
|
this.spriteShiftFunc = (builder, u, v) -> {
|
||||||
float targetU = entry.getTarget()
|
float targetU = entry.getTarget()
|
||||||
|
|
Loading…
Reference in a new issue