merge-stonecutter #16

Merged
embeddedt merged 9 commits from mitchej123/celeritas:merge-stonecutter into shader-refactor 2025-07-07 21:28:48 -04:00
16 changed files with 155 additions and 608 deletions
Showing only changes of commit c89680083f - Show all commits

No files matched your search

@@ -12,10 +12,10 @@ import net.irisshaders.iris.gl.sampler.SamplerHolder;
import net.irisshaders.iris.gl.shader.GlShader;
import net.irisshaders.iris.gl.shader.ProgramCreator;
import net.irisshaders.iris.gl.shader.ShaderCompileException;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.gl.state.ValueUpdateNotifier;
import net.irisshaders.iris.gl.texture.InternalTextureFormat;
import net.irisshaders.iris.gl.texture.TextureType;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.jetbrains.annotations.Nullable;
public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHolder, ImageHolder {
@@ -9,6 +9,7 @@ import net.irisshaders.iris.gl.IrisRenderSystem;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.lwjgl.opengl.GL20C;
import org.lwjgl.opengl.KHRDebug;
@@ -1,25 +0,0 @@
// This file is based on code from Sodium by JellySquid, licensed under the LGPLv3 license.
package net.irisshaders.iris.gl.shader;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL32C;
import org.lwjgl.opengl.GL43C;
/**
* An enumeration over the supported OpenGL shader types.
*/
public enum ShaderType {
VERTEX(GL20.GL_VERTEX_SHADER),
GEOMETRY(GL32C.GL_GEOMETRY_SHADER),
FRAGMENT(GL20.GL_FRAGMENT_SHADER),
COMPUTE(GL43C.GL_COMPUTE_SHADER),
TESSELATION_CONTROL(GL43C.GL_TESS_CONTROL_SHADER),
TESSELATION_EVAL(GL43C.GL_TESS_EVALUATION_SHADER);
public final int id;
ShaderType(int id) {
this.id = id;
}
}
@@ -2,6 +2,11 @@ package net.irisshaders.iris.pipeline;
import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Ints;
import lombok.Getter;
import lombok.experimental.Accessors;
import net.irisshaders.iris.compat.sodium.impl.shader_overrides.IrisTerrainPass;
import org.embeddedt.embeddium.impl.Celeritas;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.embeddedt.embeddium.compat.mc.MCResourceLocation;
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
import net.irisshaders.iris.gl.blending.AlphaTest;
@@ -25,12 +30,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.regex.Matcher;
@@ -39,9 +39,6 @@ import java.util.regex.Pattern;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class SodiumTerrainPipeline {
private static final Supplier<Optional<AlphaTest>> terrainCutoutDefault = () -> Optional.of(AlphaTests.ONE_TENTH_ALPHA);
private static final Supplier<Optional<AlphaTest>> translucentDefault = () -> Optional.of(AlphaTest.ALWAYS);
private static final Supplier<Optional<AlphaTest>> shadowDefault = () -> Optional.of(AlphaTests.ONE_TENTH_ALPHA);
private static final String defaultVertex = """
#version 330 core
@@ -193,42 +190,26 @@ public class SodiumTerrainPipeline {
private final IntFunction<ProgramSamplers> createShadowSamplers;
private final IntFunction<ProgramImages> createTerrainImages;
private final IntFunction<ProgramImages> createShadowImages;
Optional<String> terrainSolidVertex;
Optional<String> terrainSolidGeometry;
Optional<String> terrainSolidTessControl;
Optional<String> terrainSolidTessEval;
Optional<String> terrainSolidFragment;
GlFramebuffer terrainSolidFramebuffer;
BlendModeOverride terrainSolidBlendOverride;
List<BufferBlendOverride> terrainSolidBufferOverrides;
Optional<String> terrainCutoutVertex;
Optional<String> terrainCutoutGeometry;
Optional<String> terrainCutoutTessControl;
Optional<String> terrainCutoutTessEval;
Optional<String> terrainCutoutFragment;
GlFramebuffer terrainCutoutFramebuffer;
BlendModeOverride terrainCutoutBlendOverride;
List<BufferBlendOverride> terrainCutoutBufferOverrides;
Optional<AlphaTest> terrainCutoutAlpha;
Optional<String> translucentVertex;
Optional<String> translucentGeometry;
Optional<String> translucentTessControl;
Optional<String> translucentTessEval;
Optional<String> translucentFragment;
GlFramebuffer translucentFramebuffer;
BlendModeOverride translucentBlendOverride;
List<BufferBlendOverride> translucentBufferOverrides;
Optional<AlphaTest> translucentAlpha;
Optional<String> shadowVertex;
Optional<String> shadowGeometry;
Optional<String> shadowTessControl;
Optional<String> shadowTessEval;
Optional<String> shadowFragment;
Optional<String> shadowCutoutFragment;
GlFramebuffer shadowFramebuffer;
BlendModeOverride shadowBlendOverride = BlendModeOverride.OFF;
List<BufferBlendOverride> shadowBufferOverrides;
Optional<AlphaTest> shadowAlpha;
@Getter
@Accessors(fluent = true)
public static final class PassInfo {
private final Map<ShaderType, Optional<String>> sources = new EnumMap<>(ShaderType.class);
private GlFramebuffer framebuffer;
private BlendModeOverride blendModeOverride;
private List<BufferBlendOverride> bufferOverrides;
private Optional<AlphaTest> alphaTest;
private PassInfo() {
for (var shaderType : ShaderType.values()) {
sources.put(shaderType, Optional.empty());
}
}
}
private final Map<IrisTerrainPass, PassInfo> passInfoMap;
private final Map<IrisTerrainPass, Optional<ProgramSource>> gbufferProgramSource;
ProgramSet programSet;
public SodiumTerrainPipeline(WorldRenderingPipeline parent, ProgramSet programSet, IntFunction<ProgramSamplers> createTerrainSamplers,
@@ -239,32 +220,32 @@ public class SodiumTerrainPipeline {
this.parent = Objects.requireNonNull(parent);
this.customUniforms = customUniforms;
Optional<ProgramSource> terrainSolidSource = first(programSet.getGbuffersTerrainSolid(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic());
Optional<ProgramSource> terrainCutoutSource = first(programSet.getGbuffersTerrainCutout(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic());
Optional<ProgramSource> translucentSource = first(programSet.getGbuffersWater(), terrainCutoutSource);
this.gbufferProgramSource = new EnumMap<>(IrisTerrainPass.class);
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_SOLID, first(programSet.getGbuffersTerrainSolid(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic()));
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_CUTOUT, first(programSet.getGbuffersTerrainCutout(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic()));
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_TRANSLUCENT, first(programSet.getGbuffersWater(), gbufferProgramSource.get(IrisTerrainPass.GBUFFER_CUTOUT)));
gbufferProgramSource.put(IrisTerrainPass.SHADOW, programSet.getShadow());
this.programSet = programSet;
this.shadowFramebuffer = shadowFramebuffer;
this.passInfoMap = new EnumMap<>(IrisTerrainPass.class);
terrainSolidSource.ifPresent(sources -> terrainSolidFramebuffer = targets.createGbufferFramebuffer(flippedAfterPrepare,
sources.getDirectives().getDrawBuffers()));
for (var pass : IrisTerrainPass.values()) {
var passInfo = new PassInfo();
this.passInfoMap.put(pass, passInfo);
terrainCutoutSource.ifPresent(sources -> terrainCutoutFramebuffer = targets.createGbufferFramebuffer(flippedAfterPrepare,
sources.getDirectives().getDrawBuffers()));
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
passInfo.framebuffer = shadowFramebuffer;
} else {
var programSource = gbufferProgramSource.get(pass);
translucentSource.ifPresent(sources -> translucentFramebuffer = targets.createGbufferFramebuffer(flippedAfterTranslucent,
sources.getDirectives().getDrawBuffers()));
if (terrainSolidFramebuffer == null) {
terrainSolidFramebuffer = targets.createGbufferFramebuffer(flippedAfterPrepare, new int[]{0});
if (programSource != null) {
// embeddedt - buffers to use, I think?
ImmutableSet<Integer> flipped = pass == IrisTerrainPass.GBUFFER_TRANSLUCENT ? flippedAfterTranslucent : flippedAfterPrepare;
programSource.ifPresentOrElse(
sources -> passInfo.framebuffer = targets.createGbufferFramebuffer(flipped, sources.getDirectives().getDrawBuffers()),
() -> passInfo.framebuffer = targets.createGbufferFramebuffer(flipped, new int[] {0}));
}
if (terrainCutoutFramebuffer == null) {
terrainCutoutFramebuffer = targets.createGbufferFramebuffer(flippedAfterPrepare, new int[]{0});
}
if (translucentFramebuffer == null) {
translucentFramebuffer = targets.createGbufferFramebuffer(flippedAfterTranslucent, new int[]{0});
}
this.createTerrainSamplers = createTerrainSamplers;
@@ -302,21 +283,35 @@ public class SodiumTerrainPipeline {
public void patchShaders(RenderPassConfiguration configuration) {
ShaderAttributeInputs inputs = new ShaderAttributeInputs(true, true, false, true, true);
Optional<ProgramSource> terrainSolidSource = first(programSet.getGbuffersTerrainSolid(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic());
Optional<ProgramSource> terrainCutoutSource = first(programSet.getGbuffersTerrainCutout(), programSet.getGbuffersTerrain(), programSet.getGbuffersTexturedLit(), programSet.getGbuffersTextured(), programSet.getGbuffersBasic());
Optional<ProgramSource> translucentSource = first(programSet.getGbuffersWater(), terrainCutoutSource);
terrainSolidSource.ifPresentOrElse(sources -> {
terrainSolidBlendOverride = sources.getDirectives().getBlendModeOverride().orElse(ProgramId.Terrain.getBlendModeOverride());
terrainSolidBufferOverrides = new ArrayList<>();
for (var pass : IrisTerrainPass.values()) {
var passInfo = passInfoMap.get(pass);
var programId = switch (pass) {
case GBUFFER_TRANSLUCENT -> ProgramId.Water;
case SHADOW -> ProgramId.Shadow;
default -> ProgramId.Terrain;
};
var programSource = gbufferProgramSource.get(pass == IrisTerrainPass.SHADOW_CUTOUT ? IrisTerrainPass.SHADOW : pass);
if (programSource == null) {
Celeritas.logger().warn("Missing program source for pass {}", pass.name());
continue;
}
programSource.ifPresentOrElse(sources -> {
passInfo.blendModeOverride = sources.getDirectives().getBlendModeOverride().orElse(programId.getBlendModeOverride());
passInfo.bufferOverrides = new ArrayList<>();
sources.getDirectives().getBufferBlendOverrides().forEach(information -> {
int index = Ints.indexOf(sources.getDirectives().getDrawBuffers(), information.index());
if (index > -1) {
terrainSolidBufferOverrides.add(new BufferBlendOverride(index, information.blendMode()));
passInfo.bufferOverrides.add(new BufferBlendOverride(index, information.blendMode()));
}
});
AlphaTest defaultPassAlpha = switch (pass) {
case SHADOW_CUTOUT, GBUFFER_CUTOUT -> AlphaTests.ONE_TENTH_ALPHA;
default -> AlphaTest.ALWAYS;
};
passInfo.alphaTest = sources.getDirectives().getAlphaTestOverride().or(() -> Optional.of(defaultPassAlpha));
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getVertexSource().orElse(null),
@@ -324,293 +319,23 @@ public class SodiumTerrainPipeline {
sources.getTessControlSource().orElse(null),
sources.getTessEvalSource().orElse(null),
sources.getFragmentSource().orElse(null),
AlphaTest.ALWAYS, inputs, parent.getTextureMap());
terrainSolidVertex = Optional.ofNullable(transformed.get(PatchShaderType.VERTEX));
terrainSolidGeometry = Optional.ofNullable(transformed.get(PatchShaderType.GEOMETRY));
terrainSolidTessControl = Optional.ofNullable(transformed.get(PatchShaderType.TESS_CONTROL));
terrainSolidTessEval = Optional.ofNullable(transformed.get(PatchShaderType.TESS_EVAL));
terrainSolidFragment = Optional.ofNullable(transformed.get(PatchShaderType.FRAGMENT));
passInfo.alphaTest.orElseThrow(), inputs, parent.getTextureMap());
for (var type : PatchShaderType.values()) {
passInfo.sources.put(type.glShaderType, Optional.ofNullable(transformed.get(type)));
}
ShaderPrinter.printProgram(sources.getName() + "_sodium_" + pass.getName()).addSources(transformed).print();
ShaderPrinter.printProgram(sources.getName() + "_sodium_solid").addSources(transformed).print();
}, () -> {
terrainSolidBlendOverride = null;
terrainSolidBufferOverrides = Collections.emptyList();
terrainSolidVertex = Optional.of(defaultVertex);
terrainSolidGeometry = Optional.empty();
terrainSolidTessControl = Optional.empty();
terrainSolidTessEval = Optional.empty();
terrainSolidFragment = Optional.of(defaultFragment);
});
terrainCutoutSource.ifPresentOrElse(sources -> {
terrainCutoutBlendOverride = sources.getDirectives().getBlendModeOverride().orElse(ProgramId.Terrain.getBlendModeOverride());
terrainCutoutBufferOverrides = new ArrayList<>();
sources.getDirectives().getBufferBlendOverrides().forEach(information -> {
int index = Ints.indexOf(sources.getDirectives().getDrawBuffers(), information.index());
if (index > -1) {
terrainCutoutBufferOverrides.add(new BufferBlendOverride(index, information.blendMode()));
passInfo.blendModeOverride = null;
passInfo.bufferOverrides = Collections.emptyList();
if (pass != IrisTerrainPass.SHADOW && pass != IrisTerrainPass.SHADOW_CUTOUT) {
passInfo.sources.put(ShaderType.VERTEX, Optional.of(defaultVertex));
passInfo.sources.put(ShaderType.FRAGMENT, Optional.of(defaultFragment));
}
});
terrainCutoutAlpha = sources.getDirectives().getAlphaTestOverride().or(terrainCutoutDefault);
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getVertexSource().orElse(null),
sources.getGeometrySource().orElse(null),
sources.getTessControlSource().orElse(null),
sources.getTessEvalSource().orElse(null),
sources.getFragmentSource().orElse(null),
terrainCutoutAlpha.orElse(AlphaTests.ONE_TENTH_ALPHA), inputs, parent.getTextureMap());
terrainCutoutVertex = Optional.ofNullable(transformed.get(PatchShaderType.VERTEX));
terrainCutoutGeometry = Optional.ofNullable(transformed.get(PatchShaderType.GEOMETRY));
terrainCutoutTessControl = Optional.ofNullable(transformed.get(PatchShaderType.TESS_CONTROL));
terrainCutoutTessEval = Optional.ofNullable(transformed.get(PatchShaderType.TESS_EVAL));
terrainCutoutFragment = Optional.ofNullable(transformed.get(PatchShaderType.FRAGMENT));
ShaderPrinter.printProgram(sources.getName() + "_sodium_cutout").addSources(transformed).print();
}, () -> {
terrainCutoutBlendOverride = null;
terrainCutoutBufferOverrides = Collections.emptyList();
terrainCutoutAlpha = terrainCutoutDefault.get();
terrainCutoutVertex = Optional.of(defaultVertex);
terrainCutoutGeometry = Optional.empty();
terrainCutoutTessControl = Optional.empty();
terrainCutoutTessEval = Optional.empty();
terrainCutoutFragment = Optional.of(defaultFragment);
});
translucentSource.ifPresentOrElse(sources -> {
translucentBlendOverride = sources.getDirectives().getBlendModeOverride().orElse(ProgramId.Water.getBlendModeOverride());
translucentBufferOverrides = new ArrayList<>();
sources.getDirectives().getBufferBlendOverrides().forEach(information -> {
int index = Ints.indexOf(sources.getDirectives().getDrawBuffers(), information.index());
if (index > -1) {
translucentBufferOverrides.add(new BufferBlendOverride(index, information.blendMode()));
}
});
translucentAlpha = sources.getDirectives().getAlphaTestOverride().or(translucentDefault);
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getVertexSource().orElse(null),
sources.getGeometrySource().orElse(null),
sources.getTessControlSource().orElse(null),
sources.getTessEvalSource().orElse(null),
sources.getFragmentSource().orElse(null),
translucentAlpha.orElse(AlphaTest.ALWAYS), inputs, parent.getTextureMap());
translucentVertex = Optional.ofNullable(transformed.get(PatchShaderType.VERTEX));
translucentGeometry = Optional.ofNullable(transformed.get(PatchShaderType.GEOMETRY));
translucentTessControl = Optional.ofNullable(transformed.get(PatchShaderType.TESS_CONTROL));
translucentTessEval = Optional.ofNullable(transformed.get(PatchShaderType.TESS_EVAL));
translucentFragment = Optional.ofNullable(transformed.get(PatchShaderType.FRAGMENT));
ShaderPrinter.printProgram(sources.getName() + "_sodium").addSources(transformed).print();
}, () -> {
translucentBlendOverride = null;
translucentBufferOverrides = Collections.emptyList();
translucentAlpha = translucentDefault.get();
translucentVertex = Optional.of(defaultVertex);
translucentGeometry = Optional.empty();
translucentTessControl = Optional.empty();
translucentTessEval = Optional.empty();
translucentFragment = Optional.of(defaultFragment);
});
programSet.getShadow().ifPresentOrElse(sources -> {
shadowBlendOverride = sources.getDirectives().getBlendModeOverride().orElse(ProgramId.Shadow.getBlendModeOverride());
shadowBufferOverrides = new ArrayList<>();
sources.getDirectives().getBufferBlendOverrides().forEach(information -> {
int index = Ints.indexOf(sources.getDirectives().getDrawBuffers(), information.index());
if (index > -1) {
shadowBufferOverrides.add(new BufferBlendOverride(index, information.blendMode()));
}
});
shadowAlpha = sources.getDirectives().getAlphaTestOverride().or(shadowDefault);
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getVertexSource().orElse(null),
sources.getGeometrySource().orElse(null),
sources.getTessControlSource().orElse(null),
sources.getTessEvalSource().orElse(null),
sources.getFragmentSource().orElse(null),
AlphaTest.ALWAYS, inputs, parent.getTextureMap());
Map<PatchShaderType, String> transformedCutout = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getVertexSource().orElse(null),
sources.getGeometrySource().orElse(null),
sources.getTessControlSource().orElse(null),
sources.getTessEvalSource().orElse(null),
sources.getFragmentSource().orElse(null),
shadowAlpha.get(), inputs, parent.getTextureMap());
shadowVertex = Optional.ofNullable(transformed.get(PatchShaderType.VERTEX));
shadowGeometry = Optional.ofNullable(transformed.get(PatchShaderType.GEOMETRY));
shadowTessControl = Optional.ofNullable(transformed.get(PatchShaderType.TESS_CONTROL));
shadowTessEval = Optional.ofNullable(transformed.get(PatchShaderType.TESS_EVAL));
shadowCutoutFragment = Optional.ofNullable(transformedCutout.get(PatchShaderType.FRAGMENT));
shadowFragment = Optional.ofNullable(transformed.get(PatchShaderType.FRAGMENT));
ShaderPrinter.printProgram(sources.getName() + "_sodium")
.addSources(transformed)
.setName(sources.getName() + "_sodium_cutout")
.addSource(PatchShaderType.FRAGMENT, shadowCutoutFragment.orElse(null))
.print();
}, () -> {
shadowBlendOverride = null;
shadowBufferOverrides = Collections.emptyList();
shadowAlpha = shadowDefault.get();
shadowVertex = Optional.empty();
shadowGeometry = Optional.empty();
shadowTessControl = Optional.empty();
shadowTessEval = Optional.empty();
shadowCutoutFragment = Optional.empty();
shadowFragment = Optional.empty();
});
}
public Optional<String> getTerrainSolidVertexShaderSource() {
return terrainSolidVertex;
}
public Optional<String> getTerrainSolidGeometryShaderSource() {
return terrainSolidGeometry;
}
public Optional<String> getTerrainSolidTessControlShaderSource() {
return terrainSolidTessControl;
}
public Optional<String> getTerrainSolidTessEvalShaderSource() {
return terrainSolidTessEval;
}
public Optional<String> getTerrainSolidFragmentShaderSource() {
return terrainSolidFragment;
}
public Optional<String> getTerrainCutoutVertexShaderSource() {
return terrainCutoutVertex;
}
public Optional<String> getTerrainCutoutGeometryShaderSource() {
return terrainCutoutGeometry;
}
public Optional<String> getTerrainCutoutTessControlShaderSource() {
return terrainCutoutTessControl;
}
public Optional<String> getTerrainCutoutTessEvalShaderSource() {
return terrainCutoutTessEval;
}
public Optional<String> getTerrainCutoutFragmentShaderSource() {
return terrainCutoutFragment;
}
public GlFramebuffer getTerrainSolidFramebuffer() {
return terrainSolidFramebuffer;
}
public GlFramebuffer getTerrainCutoutFramebuffer() {
return terrainCutoutFramebuffer;
}
public BlendModeOverride getTerrainSolidBlendOverride() {
return terrainSolidBlendOverride;
}
public List<BufferBlendOverride> getTerrainSolidBufferOverrides() {
return terrainSolidBufferOverrides;
}
public BlendModeOverride getTerrainCutoutBlendOverride() {
return terrainCutoutBlendOverride;
}
public List<BufferBlendOverride> getTerrainCutoutBufferOverrides() {
return terrainCutoutBufferOverrides;
}
public Optional<AlphaTest> getTerrainCutoutAlpha() {
return terrainCutoutAlpha;
}
public Optional<String> getTranslucentVertexShaderSource() {
return translucentVertex;
}
public Optional<String> getTranslucentGeometryShaderSource() {
return translucentGeometry;
}
public Optional<String> getTranslucentTessControlShaderSource() {
return translucentTessControl;
}
public Optional<String> getTranslucentTessEvalShaderSource() {
return translucentTessEval;
}
public Optional<String> getTranslucentFragmentShaderSource() {
return translucentFragment;
}
public GlFramebuffer getTranslucentFramebuffer() {
return translucentFramebuffer;
}
public BlendModeOverride getTranslucentBlendOverride() {
return translucentBlendOverride;
}
public List<BufferBlendOverride> getTranslucentBufferOverrides() {
return translucentBufferOverrides;
}
public Optional<AlphaTest> getTranslucentAlpha() {
return translucentAlpha;
}
public Optional<String> getShadowVertexShaderSource() {
return shadowVertex;
}
public Optional<String> getShadowGeometryShaderSource() {
return shadowGeometry;
}
public Optional<String> getShadowTessControlShaderSource() {
return shadowTessControl;
}
public Optional<String> getShadowTessEvalShaderSource() {
return shadowTessEval;
}
public Optional<String> getShadowFragmentShaderSource() {
return shadowFragment;
}
public Optional<String> getShadowCutoutFragmentShaderSource() {
return shadowCutoutFragment;
}
public GlFramebuffer getShadowFramebuffer() {
return shadowFramebuffer;
}
public BlendModeOverride getShadowBlendOverride() {
return shadowBlendOverride;
}
public List<BufferBlendOverride> getShadowBufferOverrides() {
return shadowBufferOverrides;
}
public Optional<AlphaTest> getShadowAlpha() {
return shadowAlpha;
}
public ProgramUniforms.Builder initUniforms(int programId) {
@@ -628,6 +353,14 @@ public class SodiumTerrainPipeline {
return createShadowSamplers != null;
}
public PassInfo getPassInfo(IrisTerrainPass pass) {
var info = this.passInfoMap.get(pass);
if (info == null) {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
return info;
}
public ProgramSamplers initTerrainSamplers(int programId) {
return createTerrainSamplers.apply(programId);
}
@@ -1,8 +1,8 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.Parameters;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.Transformer;
import org.taumc.glsl.grammar.GLSLLexer;
import org.taumc.glsl.grammar.GLSLParser;
@@ -1,8 +1,8 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.Parameters;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.Transformer;
import static net.irisshaders.iris.pipeline.foss_transform.ShaderTransformer.*;
@@ -1,7 +1,7 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.VanillaParameters;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.Transformer;
public class EntityPatcherNew {
@@ -2,13 +2,13 @@ package net.irisshaders.iris.pipeline.foss_transform;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import net.irisshaders.iris.gl.blending.AlphaTest;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.Patch;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.Parameters;
import net.irisshaders.iris.pipeline.transform.parameter.SodiumParameters;
import net.irisshaders.iris.pipeline.transform.parameter.VanillaParameters;
import org.apache.commons.lang3.mutable.MutableObject;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.ShaderParser;
import org.taumc.glsl.StorageCollector;
import org.taumc.glsl.Transformer;
@@ -1,9 +1,9 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.SodiumParameters;
import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.Transformer;
import static net.irisshaders.iris.pipeline.foss_transform.ShaderTransformer.*;
@@ -1,9 +1,9 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.blending.AlphaTests;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.VanillaParameters;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.taumc.glsl.Transformer;
import static net.irisshaders.iris.pipeline.foss_transform.ShaderTransformer.addIfNotExistsType;
@@ -1,6 +1,6 @@
package net.irisshaders.iris.pipeline.transform;
import net.irisshaders.iris.gl.shader.ShaderType;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
public enum PatchShaderType {
VERTEX(ShaderType.VERTEX, ".vsh"),
@@ -21,9 +21,9 @@ public enum PatchShaderType {
public static PatchShaderType[] fromGlShaderType(ShaderType glShaderType) {
return switch (glShaderType) {
case VERTEX -> new PatchShaderType[]{VERTEX};
case GEOMETRY -> new PatchShaderType[]{GEOMETRY};
case TESSELATION_CONTROL -> new PatchShaderType[]{TESS_CONTROL};
case TESSELATION_EVAL -> new PatchShaderType[]{TESS_EVAL};
case GEOM -> new PatchShaderType[]{GEOMETRY};
case TESS_CTRL -> new PatchShaderType[]{TESS_CONTROL};
case TESS_EVALUATE -> new PatchShaderType[]{TESS_EVAL};
case COMPUTE -> new PatchShaderType[]{COMPUTE};
case FRAGMENT -> new PatchShaderType[]{FRAGMENT};
default -> throw new IllegalArgumentException("Unknown shader type: " + glShaderType);
@@ -1,22 +1,31 @@
package org.embeddedt.embeddium.impl.gl.shader;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import org.lwjgl.opengl.GL20C;
import org.lwjgl.opengl.GL32C;
import org.lwjgl.opengl.GL42C;
import org.lwjgl.opengl.GL43C;
/**
* An enumeration over the supported OpenGL shader types.
*/
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum ShaderType {
VERTEX(GL20C.GL_VERTEX_SHADER),
FRAGMENT(GL20C.GL_FRAGMENT_SHADER),
GEOM(GL32C.GL_GEOMETRY_SHADER),
TESS_CTRL(GL42C.GL_TESS_CONTROL_SHADER),
TESS_EVALUATE(GL42C.GL_TESS_EVALUATION_SHADER);
VERTEX(GL20C.GL_VERTEX_SHADER, "vsh"),
FRAGMENT(GL20C.GL_FRAGMENT_SHADER, "fsh"),
GEOM(GL32C.GL_GEOMETRY_SHADER, "gsh"),
TESS_CTRL(GL42C.GL_TESS_CONTROL_SHADER, "tcs"),
TESS_EVALUATE(GL42C.GL_TESS_EVALUATION_SHADER, "tes"),
COMPUTE(GL43C.GL_COMPUTE_SHADER, "csh");
@Deprecated
public static final ShaderType TESSELATION_CONTROL = ShaderType.TESS_CTRL;
@Deprecated
public static final ShaderType TESSELATION_EVAL = ShaderType.TESS_EVALUATE;
@Deprecated
public static final ShaderType GEOMETRY = ShaderType.GEOM;
public final int id;
ShaderType(int id) {
this.id = id;
}
public final String fileExtension;
}
@@ -26,7 +26,6 @@ import net.irisshaders.iris.gl.program.ProgramImages;
import net.irisshaders.iris.gl.program.ProgramSamplers;
import net.irisshaders.iris.gl.program.ProgramUniforms;
import net.irisshaders.iris.gl.shader.GlShader;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
@@ -39,6 +38,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.client.Minecraft;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.lwjgl.opengl.GL30C;
@@ -17,7 +17,6 @@ import net.irisshaders.iris.gl.program.ProgramImages;
import net.irisshaders.iris.gl.program.ProgramSamplers;
import net.irisshaders.iris.gl.program.ProgramUniforms;
import net.irisshaders.iris.gl.shader.GlShader;
import net.irisshaders.iris.gl.shader.ShaderType;
import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
@@ -30,6 +29,7 @@ import net.irisshaders.iris.uniforms.CommonUniforms;
import net.irisshaders.iris.uniforms.builtin.BuiltinReplacementUniforms;
import net.irisshaders.iris.uniforms.custom.CustomUniforms;
import net.minecraft.client.Minecraft;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;
@@ -11,214 +11,73 @@ import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkFogMode;
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderOptions;
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.blending.AlphaTest;
import net.irisshaders.iris.gl.blending.AlphaTests;
import net.irisshaders.iris.gl.blending.BlendModeOverride;
import net.irisshaders.iris.gl.blending.BufferBlendOverride;
import net.irisshaders.iris.gl.framebuffer.GlFramebuffer;
import net.irisshaders.iris.pipeline.SodiumTerrainPipeline;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.irisshaders.iris.shadows.ShadowRenderingState;
import net.minecraft.client.Minecraft;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL43C;
import java.util.EnumMap;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.*;
public class IrisChunkProgramOverrides {
private static final List<ShaderType> RELEVANT_SHADER_TYPES = List.of(ShaderType.VERTEX, ShaderType.GEOM, ShaderType.TESS_CTRL, ShaderType.TESS_EVALUATE, ShaderType.FRAGMENT);
private final EnumMap<IrisTerrainPass, GlProgram<IrisChunkShaderInterface>> programs = new EnumMap<>(IrisTerrainPass.class);
private boolean shadersCreated = false;
private int versionCounterForSodiumShaderReload = -1;
private GlShader createVertexShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
private GlShader createShader(ShaderType type, IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
Optional<String> irisVertexShader;
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
irisVertexShader = pipeline.getShadowVertexShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
irisVertexShader = pipeline.getTerrainSolidVertexShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
irisVertexShader = pipeline.getTerrainCutoutVertexShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
irisVertexShader = pipeline.getTranslucentVertexShaderSource();
} else {
if (pass == IrisTerrainPass.SHADOW_CUTOUT && type != ShaderType.FRAGMENT) {
pass = IrisTerrainPass.SHADOW;
}
var info = pipeline.getPassInfo(pass);
if (info == null) {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
irisVertexShader = info.sources().get(type);
String source = irisVertexShader.orElse(null);
if (source == null) {
return null;
}
return new GlShader(ShaderType.VERTEX, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + ".vsh", source);
}
private GlShader createGeometryShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
Optional<String> irisGeometryShader;
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
irisGeometryShader = pipeline.getShadowGeometryShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
irisGeometryShader = pipeline.getTerrainSolidGeometryShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
irisGeometryShader = pipeline.getTerrainCutoutGeometryShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
irisGeometryShader = pipeline.getTranslucentGeometryShaderSource();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
String source = irisGeometryShader.orElse(null);
if (source == null) {
return null;
}
return new GlShader(ShaderType.GEOM, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + ".gsh", source);
}
private GlShader createTessControlShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
Optional<String> irisTessControlShader;
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
irisTessControlShader = pipeline.getShadowTessControlShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
irisTessControlShader = pipeline.getTerrainSolidTessControlShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
irisTessControlShader = pipeline.getTerrainCutoutTessControlShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
irisTessControlShader = pipeline.getTranslucentTessControlShaderSource();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
String source = irisTessControlShader.orElse(null);
if (source == null) {
return null;
}
return new GlShader(ShaderType.TESS_CTRL, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + ".tcs", source);
}
private GlShader createTessEvalShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
Optional<String> irisTessEvalShader;
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
irisTessEvalShader = pipeline.getShadowTessEvalShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
irisTessEvalShader = pipeline.getTerrainSolidTessEvalShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
irisTessEvalShader = pipeline.getTerrainCutoutTessEvalShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
irisTessEvalShader = pipeline.getTranslucentTessEvalShaderSource();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
String source = irisTessEvalShader.orElse(null);
if (source == null) {
return null;
}
return new GlShader(ShaderType.TESS_EVALUATE, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + ".tes", source);
}
private GlShader createFragmentShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
Optional<String> irisFragmentShader;
if (pass == IrisTerrainPass.SHADOW) {
irisFragmentShader = pipeline.getShadowFragmentShaderSource();
} else if (pass == IrisTerrainPass.SHADOW_CUTOUT) {
irisFragmentShader = pipeline.getShadowCutoutFragmentShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
irisFragmentShader = pipeline.getTerrainSolidFragmentShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
irisFragmentShader = pipeline.getTerrainCutoutFragmentShaderSource();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
irisFragmentShader = pipeline.getTranslucentFragmentShaderSource();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
String source = irisFragmentShader.orElse(null);
if (source == null) {
return null;
}
return new GlShader(ShaderType.FRAGMENT, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + ".fsh", source);
return new GlShader(type, "iris:" +
"sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT) + "." + type.fileExtension, source);
}
private BlendModeOverride getBlendOverride(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
return pipeline.getShadowBlendOverride();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
return pipeline.getTerrainSolidBlendOverride();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
return pipeline.getTerrainCutoutBlendOverride();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
return pipeline.getTranslucentBlendOverride();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
return pipeline.getPassInfo(pass).blendModeOverride();
}
private List<BufferBlendOverride> getBufferBlendOverride(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
return pipeline.getShadowBufferOverrides();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
return pipeline.getTerrainSolidBufferOverrides();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
return pipeline.getTerrainCutoutBufferOverrides();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
return pipeline.getTranslucentBufferOverrides();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
return pipeline.getPassInfo(pass).bufferOverrides();
}
@Nullable
private GlProgram<IrisChunkShaderInterface> createShader(IrisTerrainPass pass, SodiumTerrainPipeline pipeline, RenderPassConfiguration configuration) {
GlShader vertShader = createVertexShader(pass, pipeline);
GlShader geomShader = createGeometryShader(pass, pipeline);
GlShader tessCShader = createTessControlShader(pass, pipeline);
GlShader tessEShader = createTessEvalShader(pass, pipeline);
GlShader fragShader = createFragmentShader(pass, pipeline);
Map<ShaderType, GlShader> createdShaders = new EnumMap<>(ShaderType.class);
for (var type : RELEVANT_SHADER_TYPES) {
var shader = createShader(type, pass, pipeline);
if (shader != null) {
createdShaders.put(type, shader);
}
}
BlendModeOverride blendOverride = getBlendOverride(pass, pipeline);
List<BufferBlendOverride> bufferOverrides = getBufferBlendOverride(pass, pipeline);
float alpha = getAlphaReference(pass, pipeline);
if (vertShader == null || fragShader == null) {
if (vertShader != null) {
vertShader.delete();
}
if (geomShader != null) {
geomShader.delete();
}
if (tessCShader != null) {
tessCShader.delete();
}
if (tessEShader != null) {
tessEShader.delete();
}
if (fragShader != null) {
fragShader.delete();
}
if (createdShaders.get(ShaderType.VERTEX) == null || createdShaders.get(ShaderType.FRAGMENT) == null) {
createdShaders.values().forEach(GlShader::delete);
// TODO: Partial shader programs?
return null;
@@ -228,18 +87,8 @@ public class IrisChunkProgramOverrides {
GlProgram.Builder builder = GlProgram.builder("sodium:chunk_shader_for_"
+ pass.getName());
if (geomShader != null) {
builder.attachShader(geomShader);
}
if (tessCShader != null) {
builder.attachShader(tessCShader);
}
if (tessEShader != null) {
builder.attachShader(tessEShader);
}
createdShaders.values().forEach(builder::attachShader);
builder.attachShader(vertShader)
.attachShader(fragShader);
int i = 0;
var vertexType = configuration.getVertexTypeForPass(pass.toTerrainPass(configuration));
for (var attr : vertexType.getVertexFormat().getAttributes()) {
@@ -251,35 +100,15 @@ public class IrisChunkProgramOverrides {
ShaderBindingContext contextExt = shader;
GLDebug.nameObject(GL43C.GL_PROGRAM, handle, "sodium-terrain-" + pass.toString().toLowerCase(Locale.ROOT));
return new IrisChunkShaderInterface(handle, contextExt, pipeline, new ChunkShaderOptions(ChunkFogMode.SMOOTH, pass.toTerrainPass(configuration)),
tessCShader != null || tessEShader != null, pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT, blendOverride, bufferOverrides, alpha, pipeline.getCustomUniforms());
createdShaders.get(ShaderType.TESS_CTRL) != null || createdShaders.get(ShaderType.TESS_EVALUATE) != null, pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT, blendOverride, bufferOverrides, alpha, pipeline.getCustomUniforms());
});
} finally {
vertShader.delete();
if (geomShader != null) {
geomShader.delete();
}
if (tessCShader != null) {
tessCShader.delete();
}
if (tessEShader != null) {
tessEShader.delete();
}
fragShader.delete();
createdShaders.values().forEach(GlShader::delete);
}
}
private float getAlphaReference(IrisTerrainPass pass, SodiumTerrainPipeline pipeline) {
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
return pipeline.getShadowAlpha().orElse(AlphaTests.ONE_TENTH_ALPHA).reference();
} else if (pass == IrisTerrainPass.GBUFFER_SOLID) {
return AlphaTest.ALWAYS.reference();
} else if (pass == IrisTerrainPass.GBUFFER_CUTOUT) {
return pipeline.getTerrainCutoutAlpha().orElse(AlphaTests.ONE_TENTH_ALPHA).reference();
} else if (pass == IrisTerrainPass.GBUFFER_TRANSLUCENT) {
return pipeline.getTranslucentAlpha().orElse(AlphaTest.ALWAYS).reference();
} else {
throw new IllegalArgumentException("Unknown pass type " + pass);
}
return pipeline.getPassInfo(pass).alphaTest().orElseThrow(() -> new IllegalStateException("Expected alpha test to be available")).reference();
}
public void createShaders(SodiumTerrainPipeline pipeline, RenderPassConfiguration configuration) {
@@ -216,11 +216,11 @@ public class IrisChunkShaderInterface implements ChunkShaderInterface {
GlFramebuffer framebuffer;
if (isShadowPass) {
framebuffer = pipeline.getShadowFramebuffer();
framebuffer = pipeline.getPassInfo(IrisTerrainPass.SHADOW).framebuffer();
} else if (pass.isReverseOrder()) {
framebuffer = pipeline.getTranslucentFramebuffer();
framebuffer = pipeline.getPassInfo(IrisTerrainPass.GBUFFER_TRANSLUCENT).framebuffer();
} else {
framebuffer = pipeline.getTerrainSolidFramebuffer();
framebuffer = pipeline.getPassInfo(IrisTerrainPass.GBUFFER_SOLID).framebuffer();
}
if (framebuffer != null) {