mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-04 17:24:59 +01:00
24w13oneSectionAtATime
- Hook into ClientChunkCache#onLightUpdate for light updates to be compatible with both vanilla and starlight at once - Bump embeddium/occulus versions - Move embedding uniform names to static finals and fix culling program complaining about missing uniform names - Light minecart visuals on init
This commit is contained in:
parent
5775eb863f
commit
f0cbce0ae4
12 changed files with 64 additions and 65 deletions
|
@ -76,8 +76,9 @@ dependencies {
|
|||
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
compileOnly fg.deobf("maven.modrinth:embeddium:0.2.10+mc1.20.1")
|
||||
compileOnly fg.deobf("maven.modrinth:oculus:1.20.1-1.6.9")
|
||||
compileOnly fg.deobf("maven.modrinth:embeddium:0.3.9+mc1.20.1")
|
||||
compileOnly fg.deobf("maven.modrinth:oculus:1.20.1-1.6.15a")
|
||||
// implementation fg.deobf("maven.modrinth:starlight-forge:1.1.2+1.20")
|
||||
|
||||
// https://discord.com/channels/313125603924639766/725850371834118214/910619168821354497
|
||||
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
|
||||
|
|
|
@ -61,15 +61,15 @@ public abstract class AbstractEmbeddedEnvironment extends AtomicReferenceCounted
|
|||
public void setupDraw(GlProgram program) {
|
||||
setupLight(program);
|
||||
|
||||
program.setMat4("_flw_modelMatrix", poseComposed);
|
||||
program.setMat3("_flw_normalMatrix", normalComposed);
|
||||
program.setMat4(EmbeddingUniforms.MODEL_MATRIX, poseComposed);
|
||||
program.setMat3(EmbeddingUniforms.NORMAL_MATRIX, normalComposed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupCull(GlProgram program) {
|
||||
program.setBool("_flw_useModelMatrix", true);
|
||||
program.setBool(EmbeddingUniforms.USE_MODEL_MATRIX, true);
|
||||
|
||||
program.setMat4("_flw_modelMatrix", poseComposed);
|
||||
program.setMat4(EmbeddingUniforms.MODEL_MATRIX1, poseComposed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.jozufozu.flywheel.backend.engine.embed;
|
||||
|
||||
public class EmbeddingUniforms {
|
||||
public static final String MODEL_MATRIX = "_flw_modelMatrix";
|
||||
public static final String NORMAL_MATRIX = "_flw_normalMatrix";
|
||||
public static final String USE_MODEL_MATRIX = "_flw_useModelMatrix";
|
||||
public static final String MODEL_MATRIX1 = "_flw_modelMatrix";
|
||||
public static final String ONE_OVER_LIGHT_BOX_SIZE = "_flw_oneOverLightBoxSize";
|
||||
public static final String LIGHT_VOLUME_MIN = "_flw_lightVolumeMin";
|
||||
public static final String USE_LIGHT_VOLUME = "_flw_useLightVolume";
|
||||
}
|
|
@ -21,7 +21,7 @@ public class GlobalEnvironment implements Environment {
|
|||
|
||||
@Override
|
||||
public void setupCull(GlProgram cullProgram) {
|
||||
cullProgram.setBool("_flw_useEmbeddedModel", false);
|
||||
cullProgram.setBool(EmbeddingUniforms.USE_MODEL_MATRIX, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,6 @@ public class TopLevelEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
|||
lightTexture.upload(lightVolume.ptr(), lightVolume.sizeX(), lightVolume.sizeY(), lightVolume.sizeZ());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void collectLight(BlockAndTintGetter level, int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
|
||||
lightVolume.collect(level, minX, minY, minZ, sizeX, sizeY, sizeZ);
|
||||
|
@ -56,11 +55,11 @@ public class TopLevelEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
|||
float oneOverSizeY = 1f / (float) lightTexture.sizeY;
|
||||
float oneOverSizeZ = 1f / (float) lightTexture.sizeZ;
|
||||
|
||||
program.setVec3("_flw_oneOverLightBoxSize", oneOverSizeX, oneOverSizeY, oneOverSizeZ);
|
||||
program.setVec3("_flw_lightVolumeMin", lightVolume.x(), lightVolume.y(), lightVolume.z());
|
||||
program.setBool("_flw_useLightVolume", true);
|
||||
program.setVec3(EmbeddingUniforms.ONE_OVER_LIGHT_BOX_SIZE, oneOverSizeX, oneOverSizeY, oneOverSizeZ);
|
||||
program.setVec3(EmbeddingUniforms.LIGHT_VOLUME_MIN, lightVolume.x(), lightVolume.y(), lightVolume.z());
|
||||
program.setBool(EmbeddingUniforms.USE_LIGHT_VOLUME, true);
|
||||
} else {
|
||||
program.setBool("_flw_useLightVolume", false);
|
||||
program.setBool(EmbeddingUniforms.USE_LIGHT_VOLUME, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package com.jozufozu.flywheel.impl.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.impl.visualization.VisualizationManagerImpl;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
|
||||
@Mixin(ClientChunkCache.class)
|
||||
public class ClientChunkCacheMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
ClientLevel level;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "onLightUpdate")
|
||||
private void flywheel$onLightUpdate(LightLayer pType, SectionPos pPos, CallbackInfo ci) {
|
||||
var manager = VisualizationManagerImpl.get(level);
|
||||
|
||||
if (manager != null) {
|
||||
manager.enqueueLightUpdateSection(pPos.asLong());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.jozufozu.flywheel.impl.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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.impl.visualization.VisualizationManagerImpl;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.chunk.LightChunkGetter;
|
||||
import net.minecraft.world.level.lighting.LayerLightSectionStorage;
|
||||
|
||||
@Mixin(LayerLightSectionStorage.class)
|
||||
abstract class LayerLightSectionStorageMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
protected LightChunkGetter chunkSource;
|
||||
@Shadow
|
||||
@Final
|
||||
protected LongSet sectionsAffectedByLightUpdates;
|
||||
|
||||
@Inject(method = "swapSectionMap()V", at = @At("HEAD"))
|
||||
private void flywheel$listenForChangedSections(CallbackInfo ci) {
|
||||
if (sectionsAffectedByLightUpdates.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(chunkSource.getLevel() instanceof LevelAccessor level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var manager = VisualizationManagerImpl.get(level);
|
||||
|
||||
if (manager != null) {
|
||||
manager.enqueueLightUpdateSections(sectionsAffectedByLightUpdates);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,7 +48,6 @@ import com.jozufozu.flywheel.lib.task.SimplePlan;
|
|||
import com.jozufozu.flywheel.lib.util.LevelAttached;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.server.level.BlockDestructionProgress;
|
||||
|
@ -317,12 +316,12 @@ public class VisualizationManagerImpl implements VisualizationManager {
|
|||
engine.delete();
|
||||
}
|
||||
|
||||
public void enqueueLightUpdateSections(LongSet sections) {
|
||||
public void enqueueLightUpdateSection(long section) {
|
||||
blockEntities.getStorage()
|
||||
.enqueueLightUpdateSections(sections);
|
||||
.enqueueLightUpdateSection(section);
|
||||
entities.getStorage()
|
||||
.enqueueLightUpdateSections(sections);
|
||||
.enqueueLightUpdateSection(section);
|
||||
effects.getStorage()
|
||||
.enqueueLightUpdateSections(sections);
|
||||
.enqueueLightUpdateSection(section);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ public class LitVisualStorage {
|
|||
}
|
||||
}
|
||||
|
||||
public void enqueueLightUpdateSections(LongSet sections) {
|
||||
sectionsUpdatedThisFrame.addAll(sections);
|
||||
public void enqueueLightUpdateSection(long section) {
|
||||
sectionsUpdatedThisFrame.add(section);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.jozufozu.flywheel.lib.task.PlanMap;
|
|||
import com.jozufozu.flywheel.lib.visual.SimpleDynamicVisual;
|
||||
import com.jozufozu.flywheel.lib.visual.SimpleTickableVisual;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
|
||||
public abstract class Storage<T> {
|
||||
|
@ -144,8 +143,8 @@ public abstract class Storage<T> {
|
|||
return NestedPlan.of(tickableVisuals, ForEachPlan.of(() -> simpleTickableVisuals, SimpleTickableVisual::tick));
|
||||
}
|
||||
|
||||
public void enqueueLightUpdateSections(LongSet sections) {
|
||||
litVisuals.enqueueLightUpdateSections(sections);
|
||||
public void enqueueLightUpdateSection(long section) {
|
||||
litVisuals.enqueueLightUpdateSection(section);
|
||||
}
|
||||
|
||||
private void setup(Visual visual, float partialTick) {
|
||||
|
|
|
@ -70,6 +70,7 @@ public class MinecartVisual<T extends AbstractMinecart> extends SimpleEntityVisu
|
|||
contents = createContentsInstance();
|
||||
|
||||
updateInstances(partialTick);
|
||||
updateLight();
|
||||
|
||||
super.init(partialTick);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
"refmap": "flywheel.refmap.json",
|
||||
"client": [
|
||||
"BlockEntityTypeMixin",
|
||||
"ClientChunkCacheMixin",
|
||||
"ClientLevelMixin",
|
||||
"EntityTypeMixin",
|
||||
"LayerLightSectionStorageMixin",
|
||||
"LevelMixin",
|
||||
"LevelRendererMixin",
|
||||
"MinecraftMixin",
|
||||
|
|
Loading…
Reference in a new issue