mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-28 07:56:26 +01:00
It launches
- yeet the fog - update mixin compatibility level
This commit is contained in:
parent
0b2101c25d
commit
d023b27ae8
14 changed files with 24 additions and 239 deletions
|
@ -100,7 +100,7 @@ dependencies {
|
|||
|
||||
//implementation "org.joml:joml:1.10.1"
|
||||
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||
//annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
|
@ -143,7 +143,6 @@ artifacts {
|
|||
archives jar, sourcesJar, javadocJar
|
||||
}
|
||||
|
||||
/*
|
||||
publishing {
|
||||
tasks.publish.dependsOn 'build'
|
||||
publications {
|
||||
|
@ -173,6 +172,6 @@ curseforge {
|
|||
changelog = file('changelog.txt')
|
||||
releaseType = project.curse_type
|
||||
mainArtifact jar
|
||||
addGameVersion '1.17.1'
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -56,7 +56,8 @@ public class InstanceWorld {
|
|||
* Instantiate all the necessary instances to render the given world.
|
||||
*/
|
||||
public void loadAll(ClientLevel world) {
|
||||
world.blockEntityList.forEach(tileEntityInstanceManager::add);
|
||||
// FIXME: no more global blockEntity list
|
||||
// world.blockEntityList.forEach(tileEntityInstanceManager::add);
|
||||
world.entitiesForRendering()
|
||||
.forEach(entityInstanceManager::add);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@ import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline;
|
|||
import com.jozufozu.flywheel.backend.source.FileResolution;
|
||||
import com.jozufozu.flywheel.backend.source.Resolver;
|
||||
import com.jozufozu.flywheel.core.crumbling.CrumblingProgram;
|
||||
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 com.jozufozu.flywheel.util.ResourceUtil;
|
||||
|
@ -29,12 +27,8 @@ public class Contexts {
|
|||
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);
|
||||
|
||||
FileResolution crumblingBuiltins = Resolver.INSTANCE.findShader(ResourceUtil.subPath(Names.CRUMBLING, ".glsl"));
|
||||
FileResolution worldBuiltins = Resolver.INSTANCE.findShader(ResourceUtil.subPath(Names.WORLD, ".glsl"));
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class ExtensibleGlProgram extends GlProgram {
|
|||
|
||||
if (extensions != null) {
|
||||
List<IExtensionInstance> list = new ArrayList<>();
|
||||
list.add(new FogMode(this)); // TODO: temporary fog fix
|
||||
for (IProgramExtension e : extensions) {
|
||||
IExtensionInstance extension = e.create(this);
|
||||
list.add(extension);
|
||||
|
|
|
@ -5,56 +5,30 @@ import org.lwjgl.opengl.GL20;
|
|||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public abstract class FogMode {
|
||||
public class FogMode implements IExtensionInstance {
|
||||
|
||||
public static class Linear implements IExtensionInstance {
|
||||
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_linear");
|
||||
|
||||
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_linear");
|
||||
private final int uFogColor;
|
||||
private final int uFogRange;
|
||||
|
||||
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 FogMode(GlProgram program) {
|
||||
this.uFogColor = program.getUniformLocation("uFogColor");
|
||||
this.uFogRange = program.getUniformLocation("uFogRange");
|
||||
}
|
||||
|
||||
public static class Exp2 implements IExtensionInstance {
|
||||
@Override
|
||||
public void bind() {
|
||||
GL20.glUniform2f(uFogRange, RenderSystem.getShaderFogStart(), RenderSystem.getShaderFogEnd());
|
||||
GL20.glUniform4fv(uFogColor, RenderSystem.getShaderFogColor());
|
||||
}
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public ResourceLocation name() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
public class GlFog {
|
||||
public static float[] FOG_COLOR = new float[]{0, 0, 0, 0};
|
||||
|
||||
public static boolean fogEnabled() {
|
||||
return GlStateManager.FOG.enable.enabled;
|
||||
}
|
||||
|
||||
public static int getFogModeGlEnum() {
|
||||
return GlStateManager.FOG.mode;
|
||||
}
|
||||
|
||||
public static float getFogDensity() {
|
||||
return GlStateManager.FOG.density;
|
||||
}
|
||||
|
||||
public static float getFogEnd() {
|
||||
return GlStateManager.FOG.end;
|
||||
}
|
||||
|
||||
public static float getFogStart() {
|
||||
return GlStateManager.FOG.start;
|
||||
}
|
||||
|
||||
public static WorldFog getFogMode() {
|
||||
if (!fogEnabled()) {
|
||||
return WorldFog.NONE;
|
||||
}
|
||||
|
||||
int mode = getFogModeGlEnum();
|
||||
|
||||
switch (mode) {
|
||||
case GL11.GL_EXP2:
|
||||
case GL11.GL_EXP:
|
||||
return WorldFog.EXP2;
|
||||
case GL11.GL_LINEAR:
|
||||
return WorldFog.LINEAR;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unknown fog mode: " + mode);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package com.jozufozu.flywheel.core.shader;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IExtensionInstance;
|
||||
import com.jozufozu.flywheel.core.shader.extension.IProgramExtension;
|
||||
import com.jozufozu.flywheel.core.shader.extension.UnitExtensionInstance;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public enum WorldFog implements IProgramExtension {
|
||||
NONE("none", UnitExtensionInstance::new),
|
||||
LINEAR("linear", FogMode.Linear::new),
|
||||
EXP2("exp2", FogMode.Exp2::new),
|
||||
;
|
||||
|
||||
private final ResourceLocation id;
|
||||
private final String name;
|
||||
private final Function<GlProgram, IExtensionInstance> fogFactory;
|
||||
|
||||
WorldFog(String name, Function<GlProgram, IExtensionInstance> fogFactory) {
|
||||
this.id = new ResourceLocation(Flywheel.ID, "fog_" + name);
|
||||
this.name = name;
|
||||
this.fogFactory = fogFactory;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExtensionInstance create(GlProgram program) {
|
||||
return fogFactory.apply(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package com.jozufozu.flywheel.core.shader.gamestate;
|
||||
|
||||
import com.jozufozu.flywheel.Flywheel;
|
||||
import com.jozufozu.flywheel.core.shader.GlFog;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class FogStateProvider implements IGameStateProvider {
|
||||
|
||||
public static final FogStateProvider INSTANCE = new FogStateProvider();
|
||||
public static final ResourceLocation NAME = new ResourceLocation(Flywheel.ID, "fog_mode");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return GlFog.getFogMode();
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.core.shader.GlFog;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
|
||||
@Mixin(GlStateManager.class)
|
||||
public class FogColorTrackerMixin {
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "_fog")
|
||||
private static void copyFogColor(int pname, float[] params, CallbackInfo ci) {
|
||||
if (pname == GL11.GL_FOG_COLOR) {
|
||||
GlFog.FOG_COLOR = params;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
modLoader = "javafml"
|
||||
loaderVersion = "[36,)"
|
||||
loaderVersion = "[37,)"
|
||||
issueTrackerURL = "https://github.com/Jozufozu/Flywheel/issues"
|
||||
license = "MIT"
|
||||
|
||||
|
@ -17,13 +17,13 @@ A modern engine for modded minecraft.
|
|||
[[dependencies.flywheel]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[36,)"
|
||||
versionRange = "[37,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.flywheel]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.16.3,1.17)"
|
||||
versionRange = "[1.17,1.18)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
|
|
@ -7,22 +7,6 @@
|
|||
"value": "true"
|
||||
},
|
||||
"define": "DEBUG_NORMAL"
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"provider": "flywheel:fog_mode",
|
||||
"value": "linear"
|
||||
},
|
||||
"define": ["USE_FOG", "USE_FOG_LINEAR"],
|
||||
"extend": "flywheel:fog_linear"
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"provider": "flywheel:fog_mode",
|
||||
"value": "exp2"
|
||||
},
|
||||
"define": ["USE_FOG", "USE_FOG_EXP2"],
|
||||
"extend": "flywheel:fog_exp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,22 +7,6 @@
|
|||
"value": "true"
|
||||
},
|
||||
"define": "DEBUG_NORMAL"
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"provider": "flywheel:fog_mode",
|
||||
"value": "linear"
|
||||
},
|
||||
"define": ["USE_FOG", "USE_FOG_LINEAR"],
|
||||
"extend": "flywheel:fog_linear"
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"provider": "flywheel:fog_mode",
|
||||
"value": "exp2"
|
||||
},
|
||||
"define": ["USE_FOG", "USE_FOG_EXP2"],
|
||||
"extend": "flywheel:fog_exp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,21 +1,7 @@
|
|||
#if defined(USE_FOG)
|
||||
varying float FragDistance;
|
||||
uniform vec4 uFogColor;
|
||||
#endif
|
||||
|
||||
#if defined(USE_FOG_LINEAR)
|
||||
uniform vec2 uFogRange;
|
||||
|
||||
float FLWFogFactor() {
|
||||
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_FOG_EXP2)
|
||||
uniform float uFogDensity;
|
||||
|
||||
float FLWFogFactor() {
|
||||
float dist = FragDistance * uFogDensity;
|
||||
return 1. / exp2(dist * dist);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.jozufozu.flywheel.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"compatibilityLevel": "JAVA_16",
|
||||
"refmap": "flywheel.refmap.json",
|
||||
"client": [
|
||||
"CancelEntityRenderMixin",
|
||||
"CancelTileEntityRenderMixin",
|
||||
"FixFabulousDepthMixin",
|
||||
"FogColorTrackerMixin",
|
||||
"RenderHooksMixin",
|
||||
"ShaderCloseMixin",
|
||||
"StoreProjectionMatrixMixin",
|
||||
|
|
Loading…
Reference in a new issue