remove the FogService SPI #43
No files matched your search
+4
-4
@@ -35,11 +35,11 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer {
|
||||
|
||||
protected final boolean enableLegacyGLPatches;
|
||||
|
||||
protected final FogService fogService;
|
||||
protected final ChunkShaderEnvironment environment;
|
||||
|
||||
public ShaderChunkRenderer(RenderDevice device, RenderPassConfiguration<?> renderPassConfiguration, FogService fogService) {
|
||||
this.device = device;
|
||||
this.fogService = fogService;
|
||||
this.environment = new ChunkShaderEnvironment(fogService);
|
||||
this.renderPassConfiguration = renderPassConfiguration;
|
||||
this.enableLegacyGLPatches = !LWJGL.isOpenGLVersionSupported(3, 2);
|
||||
if (this.enableLegacyGLPatches) {
|
||||
@@ -112,7 +112,7 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer {
|
||||
if (!this.enableLegacyGLPatches) {
|
||||
builder.bindFragmentData("fragColor", ChunkShaderBindingPoints.FRAG_COLOR);
|
||||
}
|
||||
return builder.link((shader) -> new DefaultChunkShaderInterface(shader, options, this.fogService));
|
||||
return builder.link((shader) -> new DefaultChunkShaderInterface(shader, options, this.environment));
|
||||
} finally {
|
||||
loadedShaders.forEach(GlShader::delete);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer {
|
||||
|
||||
protected List<ChunkShaderComponent.Factory<?>> getShaderComponents() {
|
||||
var componentFactories = new ArrayList<ChunkShaderComponent.Factory<?>>(4);
|
||||
componentFactories.add(this.fogService.getFogMode());
|
||||
componentFactories.add(this.environment.fogService().getFogMode());
|
||||
return componentFactories;
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -4,7 +4,6 @@ import org.taumc.celeritas.lwjgl.GL20;
|
||||
import static org.taumc.celeritas.lwjgl.LWJGLServiceProvider.LWJGL;
|
||||
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderBindingContext;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
@@ -15,17 +14,17 @@ public enum ChunkFogMode implements ChunkShaderComponent.Factory<ChunkShaderFogC
|
||||
EXP2(ChunkShaderFogComponent.Exp2::new, List.of("USE_FOG", "USE_FOG_EXP2")),
|
||||
SMOOTH(ChunkShaderFogComponent.Smooth::new, List.of("USE_FOG", "USE_FOG_SMOOTH"));
|
||||
|
||||
private final BiFunction<ShaderBindingContext, FogService, ChunkShaderFogComponent> factory;
|
||||
private final BiFunction<ShaderBindingContext, ChunkShaderEnvironment, ChunkShaderFogComponent> factory;
|
||||
private final List<String> defines;
|
||||
|
||||
ChunkFogMode(BiFunction<ShaderBindingContext, FogService, ChunkShaderFogComponent> factory, List<String> defines) {
|
||||
ChunkFogMode(BiFunction<ShaderBindingContext, ChunkShaderEnvironment, ChunkShaderFogComponent> factory, List<String> defines) {
|
||||
this.factory = factory;
|
||||
this.defines = defines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkShaderFogComponent create(ShaderBindingContext context, FogService fogService) {
|
||||
return factory.apply(context, fogService);
|
||||
public ChunkShaderFogComponent create(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
return factory.apply(context, environment);
|
||||
}
|
||||
|
||||
public List<String> getDefines() {
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package org.embeddedt.embeddium.impl.render.chunk.shader;
|
||||
|
||||
import org.embeddedt.embeddium.impl.gl.shader.ShaderBindingContext;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -10,7 +9,7 @@ public interface ChunkShaderComponent {
|
||||
void setup();
|
||||
|
||||
interface Factory<T extends ChunkShaderComponent> {
|
||||
T create(ShaderBindingContext context, FogService fogService);
|
||||
T create(ShaderBindingContext context, ChunkShaderEnvironment environment);
|
||||
|
||||
default Collection<String> getDefines() {
|
||||
return List.of();
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package org.embeddedt.embeddium.impl.render.chunk.shader;
|
||||
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
|
||||
public record ChunkShaderEnvironment(FogService fogService) {
|
||||
}
|
||||
+8
-8
@@ -24,8 +24,8 @@ public abstract class ChunkShaderFogComponent implements ChunkShaderComponent {
|
||||
}
|
||||
|
||||
public static class None extends ChunkShaderFogComponent {
|
||||
public None(ShaderBindingContext context, FogService fogService) {
|
||||
super(fogService);
|
||||
public None(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
super(environment.fogService());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,8 +38,8 @@ public abstract class ChunkShaderFogComponent implements ChunkShaderComponent {
|
||||
private final GlUniformFloat4v uFogColor;
|
||||
private final GlUniformFloat uFogDensity;
|
||||
|
||||
public Exp(ShaderBindingContext context, FogService fogService) {
|
||||
super(fogService);
|
||||
public Exp(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
super(environment.fogService());
|
||||
|
||||
this.uFogColor = context.bindUniform("u_FogColor", GlUniformFloat4v::new);
|
||||
this.uFogDensity = context.bindUniform("u_FogDensity", GlUniformFloat::new);
|
||||
@@ -56,8 +56,8 @@ public abstract class ChunkShaderFogComponent implements ChunkShaderComponent {
|
||||
private final GlUniformFloat4v uFogColor;
|
||||
private final GlUniformFloat uFogDensity;
|
||||
|
||||
public Exp2(ShaderBindingContext context, FogService fogService) {
|
||||
super(fogService);
|
||||
public Exp2(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
super(environment.fogService());
|
||||
|
||||
this.uFogColor = context.bindUniform("u_FogColor", GlUniformFloat4v::new);
|
||||
this.uFogDensity = context.bindUniform("u_FogDensity", GlUniformFloat::new);
|
||||
@@ -77,8 +77,8 @@ public abstract class ChunkShaderFogComponent implements ChunkShaderComponent {
|
||||
private final GlUniformFloat uFogStart;
|
||||
private final GlUniformFloat uFogEnd;
|
||||
|
||||
public Smooth(ShaderBindingContext context, FogService fogService) {
|
||||
super(fogService);
|
||||
public Smooth(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
super(environment.fogService());
|
||||
|
||||
this.uFogColor = context.bindUniform("u_FogColor", GlUniformFloat4v::new);
|
||||
this.uFogShape = context.bindUniform("u_FogShape", GlUniformInt::new);
|
||||
|
||||
+2
-3
@@ -7,7 +7,6 @@ import org.embeddedt.embeddium.impl.gl.shader.uniform.GlUniformInt;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.uniform.GlUniformMatrix4f;
|
||||
import org.embeddedt.embeddium.impl.gl.tessellation.GlPrimitiveType;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.sorting.QuadPrimitiveType;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.joml.Matrix4fc;
|
||||
import org.taumc.celeritas.lwjgl.MemoryStack;
|
||||
@@ -37,7 +36,7 @@ public class DefaultChunkShaderInterface implements ChunkShaderInterface {
|
||||
|
||||
private GlPrimitiveType primitiveType;
|
||||
|
||||
public DefaultChunkShaderInterface(ShaderBindingContext context, ChunkShaderOptions options, FogService fogService) {
|
||||
public DefaultChunkShaderInterface(ShaderBindingContext context, ChunkShaderOptions options, ChunkShaderEnvironment environment) {
|
||||
this.uniformModelViewMatrix = context.bindUniform("u_ModelViewMatrix", GlUniformMatrix4f::new);
|
||||
this.uniformProjectionMatrix = context.bindUniform("u_ProjectionMatrix", GlUniformMatrix4f::new);
|
||||
this.uniformRegionOffset = context.bindUniform("u_RegionOffset", GlUniformFloat3v::new);
|
||||
@@ -49,7 +48,7 @@ public class DefaultChunkShaderInterface implements ChunkShaderInterface {
|
||||
this.uniformTextures.put(ChunkShaderTextureSlot.LIGHT, context.bindUniform("u_LightTex", GlUniformInt::new));
|
||||
}
|
||||
|
||||
this.components = options.components().stream().map(c -> c.create(context, fogService)).toList();
|
||||
this.components = options.components().stream().map(c -> c.create(context, environment)).toList();
|
||||
}
|
||||
|
||||
@Deprecated // the shader interface should not modify pipeline state
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import org.embeddedt.embeddium.impl.gl.shader.uniform.GlUniformFloat;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.uniform.GlUniformFloat4v;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.fog.FogService;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderComponent;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderEnvironment;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -57,7 +58,7 @@ public class FogHelper implements FogService {
|
||||
private static class PostmodernFogComponent implements ChunkShaderComponent {
|
||||
private static final ChunkShaderComponent.Factory<PostmodernFogComponent> FACTORY = new ChunkShaderComponent.Factory<>() {
|
||||
@Override
|
||||
public PostmodernFogComponent create(ShaderBindingContext context, FogService fogService) {
|
||||
public PostmodernFogComponent create(ShaderBindingContext context, ChunkShaderEnvironment environment) {
|
||||
return new PostmodernFogComponent(context);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user