merge-stonecutter #16

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

No files matched your search

@@ -33,7 +33,7 @@ import net.irisshaders.iris.pathways.colorspace.ColorSpaceFragmentConverter;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.programs.ShaderKey;
import net.irisshaders.iris.pipeline.programs.ShaderMap;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisImages;
import net.irisshaders.iris.samplers.IrisSamplers;
@@ -1301,7 +1301,7 @@ public abstract class CommonIrisRenderingPipeline implements WorldRenderingPipel
try {
String transformed = TransformPatcherBridge.patchCompute(source.getName(), source.getSource().orElse(null), stage, getTextureMap());
ShaderPrinter.printProgram(source.getName()).addSource(PatchShaderType.COMPUTE, transformed).print();
ShaderPrinter.printProgram(source.getName()).addSource(ShaderType.COMPUTE, transformed).print();
builder = ProgramBuilder.beginCompute(source.getName(), transformed, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
@@ -1373,7 +1373,7 @@ public abstract class CommonIrisRenderingPipeline implements WorldRenderingPipel
TextureStage.GBUFFERS_AND_SHADOW,
getTextureMap());
ShaderPrinter.printProgram(source.getName()).addSource(PatchShaderType.COMPUTE, transformed).print();
ShaderPrinter.printProgram(source.getName()).addSource(ShaderType.COMPUTE, transformed).print();
builder = ProgramBuilder.beginCompute(source.getName(), transformed, IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
} catch (ShaderCompileException e) {
@@ -29,7 +29,6 @@ import net.irisshaders.iris.gl.texture.TextureAccess;
import net.irisshaders.iris.pathways.CenterDepthSampler;
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisImages;
import net.irisshaders.iris.samplers.IrisSamplers;
@@ -306,14 +305,14 @@ public class CompositeRenderer {
private Program createProgram(ProgramSource source, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot,
Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
// TODO: Properly handle empty shaders
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchComposite(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchComposite(
source.getName(),
source.getSource(ShaderType.VERTEX).orElseThrow(NullPointerException::new),
source.getSource(ShaderType.GEOM).orElse(null),
source.getSource(ShaderType.FRAGMENT).orElseThrow(NullPointerException::new), textureStage, pipeline.getTextureMap());
String vertex = transformed.get(PatchShaderType.VERTEX);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String geometry = transformed.get(ShaderType.GEOMETRY);
String fragment = transformed.get(ShaderType.FRAGMENT);
ShaderPrinter.printProgram(source.getName()).addSources(transformed).print();
@@ -377,7 +376,7 @@ public class CompositeRenderer {
try {
String transformed = TransformPatcherBridge.patchCompute(source.getName(), source.getSource().orElse(null), textureStage, pipeline.getTextureMap());
ShaderPrinter.printProgram(source.getName()).addSource(PatchShaderType.COMPUTE, transformed).print();
ShaderPrinter.printProgram(source.getName()).addSource(ShaderType.COMPUTE, transformed).print();
builder = ProgramBuilder.beginCompute(source.getName(), transformed, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (ShaderCompileException e) {
@@ -26,7 +26,6 @@ import net.irisshaders.iris.gl.texture.TextureAccess;
import net.irisshaders.iris.pathways.CenterDepthSampler;
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisImages;
import net.irisshaders.iris.samplers.IrisSamplers;
@@ -318,14 +317,14 @@ public class FinalPassRenderer {
private Program createProgram(ProgramSource source, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot,
Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
// TODO: Properly handle empty shaders
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchComposite(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchComposite(
source.getName(),
source.getSource(ShaderType.VERTEX).orElseThrow(NullPointerException::new),
source.getSource(ShaderType.GEOM).orElse(null),
source.getSource(ShaderType.FRAGMENT).orElseThrow(NullPointerException::new), TextureStage.COMPOSITE_AND_FINAL, pipeline.getTextureMap());
String vertex = transformed.get(PatchShaderType.VERTEX);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String geometry = transformed.get(ShaderType.GEOMETRY);
String fragment = transformed.get(ShaderType.FRAGMENT);
ShaderPrinter.printProgram(source.getName()).addSources(transformed).print();
@@ -388,7 +387,7 @@ public class FinalPassRenderer {
try {
String transformed = TransformPatcherBridge.patchCompute(source.getName(), source.getSource().orElse(null), TextureStage.COMPOSITE_AND_FINAL, pipeline.getTextureMap());
ShaderPrinter.printProgram(source.getName()).addSource(PatchShaderType.COMPUTE, transformed).print();
ShaderPrinter.printProgram(source.getName()).addSource(ShaderType.COMPUTE, transformed).print();
builder = ProgramBuilder.beginCompute(source.getName(), transformed, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (ShaderCompileException e) {
@@ -20,7 +20,6 @@ import net.irisshaders.iris.gl.program.ProgramUniforms;
import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.shaderpack.loading.ProgramId;
import net.irisshaders.iris.shaderpack.programs.ProgramSet;
@@ -149,7 +148,7 @@ public class SodiumTerrainPipeline {
passInfo.alphaTest = sources.getDirectives().getAlphaTestOverride().or(() -> Optional.of(defaultPassAlpha));
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchSodium(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchSodium(
sources.getName(),
sources.getSourceNullable(ShaderType.VERTEX),
sources.getSourceNullable(ShaderType.GEOM),
@@ -158,8 +157,8 @@ public class SodiumTerrainPipeline {
sources.getSourceNullable(ShaderType.FRAGMENT),
passInfo.alphaTest.orElseThrow(), inputs, parent.getTextureMap());
for (var type : PatchShaderType.values()) {
passInfo.sources.put(type.glShaderType, Optional.ofNullable(transformed.get(type)));
for (var type : ShaderType.values()) {
passInfo.sources.put(type, Optional.ofNullable(transformed.get(type)));
}
ShaderPrinter.printProgram(sources.getName() + "_sodium_" + pass.getName()).addSources(transformed).print();
@@ -1,6 +1,5 @@
package net.irisshaders.iris.pipeline.foss_transform;
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;
@@ -14,7 +13,7 @@ public class CompTransformer {
private static final ShaderType[] pipeline = {ShaderType.VERTEX, ShaderType.TESSELATION_CONTROL, ShaderType.TESSELATION_EVAL, ShaderType.GEOMETRY, ShaderType.FRAGMENT};
public static void transformEach(Transformer root, Parameters parameters) {
if (parameters.type == PatchShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
if ( root.containsCall("fract(worldpos.y + 0.001)")) {
root.replaceExpression("fract(worldpos.y + 0.001)", "fract(worldpos.y + 0.01)");
}
@@ -43,7 +42,7 @@ public class CompTransformer {
}
// does transformations that require cross-shader type data
public static void transformGrouped(Map<PatchShaderType, Transformer> trees, Parameters parameters) {
public static void transformGrouped(Map<ShaderType, Transformer> trees, Parameters parameters) {
/*
find attributes that are declared as "in" in geometry or fragment but not
declared as "out" in the previous stage. The missing "out" declarations for
@@ -62,16 +61,7 @@ public class CompTransformer {
ShaderType prevType = null;
for (ShaderType type : pipeline) {
PatchShaderType[] patchTypes = PatchShaderType.fromGlShaderType(type);
// check if the patch types have sources and continue if not
boolean hasAny = false;
for (PatchShaderType currentType : patchTypes) {
if (trees.get(currentType) != null) {
hasAny = true;
}
}
if (!hasAny) {
if (trees.get(type) == null) {
continue;
}
@@ -82,12 +72,12 @@ public class CompTransformer {
continue;
}
PatchShaderType prevPatchTypes = PatchShaderType.fromGlShaderType(prevType)[0];
ShaderType prevPatchTypes = prevType;
var prevTree = trees.get(prevPatchTypes);
Map<String, GLSLParser.Single_declarationContext> outDec = prevTree.findQualifiers(GLSLLexer.OUT);
for (PatchShaderType currentType : patchTypes) {
var currentTree = trees.get(currentType);
var currentTree = trees.get(type);
if (currentTree == null) {
continue;
@@ -129,7 +119,6 @@ public class CompTransformer {
}
}
}
prevType = type;
}
@@ -1,6 +1,5 @@
package net.irisshaders.iris.pipeline.foss_transform;
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;
@@ -22,7 +21,7 @@ public class CompositeTransformer {
public static void patchCompositeCore(Transformer translationUnit, Parameters parameters) {
patchCompositeDepth(translationUnit, parameters);
if (parameters.type == PatchShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.rename("vaPosition", "Position");
translationUnit.rename("vaUV0", "UV0");
translationUnit.replaceExpression("modelViewMatrix", "mat4(1.0)");
@@ -44,7 +43,7 @@ public class CompositeTransformer {
translationUnit.replaceExpression("gl_TextureMatrix[" + i + "]", "mat4(1.0f)");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.replaceExpression("gl_MultiTexCoord0","vec4(UV0, 0.0, 1.0)");
translationUnit.injectVariable("in vec2 UV0;");
@@ -54,7 +53,7 @@ public class CompositeTransformer {
// No color attributes, the color is always solid white.
translationUnit.replaceExpression("gl_Color", "vec4(1.0, 1.0, 1.0, 1.0)");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glNormal.xml
// The initial value of the current normal is the unit vector, (0, 0, 1).
translationUnit.replaceExpression("gl_Normal", "vec3(0.0, 0.0, 1.0)");
@@ -62,7 +61,7 @@ public class CompositeTransformer {
translationUnit.replaceExpression("gl_NormalMatrix", "mat3(1.0)");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.injectVariable("in vec3 Position;");
if (translationUnit.containsCall("ftransform")) {
translationUnit.injectFunction(
@@ -11,7 +11,7 @@ public class EntityPatcherNew {
translationUnit.removeVariable("entityColor");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// add our own declarations
// TODO: We're exposing entityColor to this stage even if it isn't declared in
// this stage. But this is needed for the pass-through behavior.
@@ -35,7 +35,7 @@ public class EntityPatcherNew {
translationUnit.prependMain("iris_vertexColor = iris_Color;");
translationUnit.prependMain("entityColor = vec4(overlayColor.rgb, 1.0 - overlayColor.a);");
translationUnit.prependMain("vec4 overlayColor = texelFetch(iris_overlay, iris_UV1, 0);");
} else if (parameters.type.glShaderType == ShaderType.TESSELATION_CONTROL) {
} else if (parameters.type == ShaderType.TESSELATION_CONTROL) {
// replace read references to grab the color from the first vertex.
translationUnit.replaceExpression("entityColor", "entityColor[gl_InvocationID]");
@@ -48,7 +48,7 @@ public class EntityPatcherNew {
translationUnit.prependMain(
"entityColorTCS = entityColor[gl_InvocationID];\n" +
"iris_vertexColorTCS[gl_InvocationID] = iris_vertexColor[gl_InvocationID];");
} else if (parameters.type.glShaderType == ShaderType.TESSELATION_EVAL) {
} else if (parameters.type == ShaderType.TESSELATION_EVAL) {
// replace read references to grab the color from the first vertex.
translationUnit.replaceExpression("entityColor", "entityColorTCS");
@@ -60,7 +60,7 @@ public class EntityPatcherNew {
translationUnit.prependMain(
"entityColorTES = entityColorTCS;\n" +
"iris_vertexColorTES = iris_vertexColorTCS[0];");
} else if (parameters.type.glShaderType == ShaderType.GEOMETRY) {
} else if (parameters.type == ShaderType.GEOMETRY) {
// replace read references to grab the color from the first vertex.
translationUnit.replaceExpression("entityColor", "entityColor[0]");
@@ -77,7 +77,7 @@ public class EntityPatcherNew {
translationUnit.rename("iris_vertexColor", "iris_vertexColorTES");
translationUnit.rename("entityColor", "entityColorTES");
}
} else if (parameters.type.glShaderType == ShaderType.FRAGMENT) {
} else if (parameters.type == ShaderType.FRAGMENT) {
translationUnit.injectVariable(
"in vec4 entityColor;");
translationUnit.injectVariable("in vec4 iris_vertexColor;");
@@ -109,7 +109,7 @@ public class EntityPatcherNew {
translationUnit.removeVariable("currentRenderedItemId");
}
if (parameters.type.glShaderType == ShaderType.GEOMETRY) {
if (parameters.type == ShaderType.GEOMETRY) {
translationUnit.replaceExpression("entityId",
"iris_entityInfo[0].x");
@@ -129,7 +129,7 @@ public class EntityPatcherNew {
"iris_entityInfo.z");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// add our own declarations
// TODO: We're exposing entityColor to this stage even if it isn't declared in
// this stage. But this is needed for the pass-through behavior.
@@ -142,7 +142,7 @@ public class EntityPatcherNew {
// stage.
translationUnit.prependMain(
"iris_entityInfo = iris_Entity;");
} else if (parameters.type.glShaderType == ShaderType.TESSELATION_CONTROL) {
} else if (parameters.type == ShaderType.TESSELATION_CONTROL) {
// TODO: this is passthrough behavior
translationUnit.injectVariable(
"flat out ivec3 iris_entityInfoTCS[];");
@@ -151,7 +151,7 @@ public class EntityPatcherNew {
translationUnit.prependMain(
"iris_entityInfoTCS[gl_InvocationID] = iris_entityInfo[gl_InvocationID];");
} else if (parameters.type.glShaderType == ShaderType.TESSELATION_EVAL) {
} else if (parameters.type == ShaderType.TESSELATION_EVAL) {
// TODO: this is passthrough behavior
translationUnit.injectVariable("flat out ivec3 iris_entityInfoTES;");
translationUnit.injectVariable("flat in ivec3 iris_entityInfoTCS[];");
@@ -160,14 +160,14 @@ public class EntityPatcherNew {
translationUnit.replaceExpression("iris_entityInfo", "iris_EntityInfoTCS[0]");
} else if (parameters.type.glShaderType == ShaderType.GEOMETRY) {
} else if (parameters.type == ShaderType.GEOMETRY) {
// TODO: this is passthrough behavior
translationUnit.injectVariable(
"flat out ivec3 iris_entityInfoGS;");
translationUnit.injectVariable("flat in ivec3 iris_entityInfo" + (parameters.hasTesselation ? "TES" : "") + "[];");
translationUnit.prependMain(
"iris_entityInfoGS = iris_entityInfo" + (parameters.hasTesselation ? "TES" : "") + "[0];");
} else if (parameters.type.glShaderType == ShaderType.FRAGMENT) {
} else if (parameters.type == ShaderType.FRAGMENT) {
translationUnit.injectVariable(
"flat in ivec3 iris_entityInfo;");
@@ -2,8 +2,9 @@ package net.irisshaders.iris.pipeline.foss_transform;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import org.apache.commons.codec.binary.Hex;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -31,7 +32,7 @@ public class ShaderTransformationDiskCache {
/**
* This value must be incremented whenever a new version of Cornea is published with updated transformers.
*/
private static final int TRANSFORMER_VERSION = 1;
private static final int TRANSFORMER_VERSION = 2;
private static final Path SHADER_CACHE_PATH = PLATFORM_UTIL.getGameDir().resolve("cornea_transform_cache");
@@ -45,7 +46,7 @@ public class ShaderTransformationDiskCache {
}
}
public static Map<PatchShaderType, String> transformIfAbsent(ShaderTransformer.TransformKey<?> tKey, Supplier<Map<PatchShaderType, String>> transformFn) {
public static Map<ShaderType, String> transformIfAbsent(ShaderTransformer.TransformKey<?> tKey, Supplier<Map<ShaderType, String>> transformFn) {
// TODO - this will be hard to remember to invalidate, disabling disk caching for now
if (true || !ShaderTransformer.useCache) {
return transformFn.get();
@@ -55,9 +56,9 @@ public class ShaderTransformationDiskCache {
byte[] hash = DIGEST.digest(data.getBytes(StandardCharsets.UTF_8));
String hashFileName = Hex.encodeHexString(hash) + ".dat";
Path path = SHADER_CACHE_PATH.resolve(hashFileName);
TypeToken<Map<PatchShaderType, String>> typeToken = new TypeToken<>() {};
TypeToken<Map<ShaderType, String>> typeToken = new TypeToken<>() {};
try (Reader reader = new BufferedReader(new InputStreamReader(new InflaterInputStream(Files.newInputStream(path))))) {
Map<PatchShaderType, String> map = new Gson().fromJson(reader, typeToken.getType());
Map<ShaderType, String> map = new Gson().fromJson(reader, typeToken.getType());
if(map != null && !map.isEmpty()) {
return map;
} else {
@@ -69,7 +70,7 @@ public class ShaderTransformationDiskCache {
IRIS_LOGGER.error("Error loading transformed shader, will re-transform now", e);
}
Map<PatchShaderType, String> results = transformFn.get();
Map<ShaderType, String> results = transformFn.get();
try {
Files.createDirectories(SHADER_CACHE_PATH);
@@ -3,7 +3,6 @@ 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.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;
@@ -26,25 +25,25 @@ import java.util.regex.Pattern;
public class ShaderTransformer {
private static final int CACHE_SIZE = 100;
private static final Object2ObjectLinkedOpenHashMap<TransformKey, Map<PatchShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
private static final Object2ObjectLinkedOpenHashMap<TransformKey, Map<ShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
public static final boolean useCache = true;
public record TransformKey<P extends Parameters>(Patch patchType, EnumMap<PatchShaderType, String> inputs, P params) {}
public record TransformKey<P extends Parameters>(Patch patchType, EnumMap<ShaderType, String> inputs, P params) {}
public static <P extends Parameters> Map<PatchShaderType, String> transform(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment, P parameters) {
public static <P extends Parameters> Map<ShaderType, String> transform(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment, P parameters) {
if (vertex == null && geometry == null && tessControl == null && tessEval == null && fragment == null) {
return null;
} else {
Map<PatchShaderType, String> result;
Map<ShaderType, String> result;
var patchType = parameters.patch;
EnumMap<PatchShaderType, String> inputs = new EnumMap<>(PatchShaderType.class);
inputs.put(PatchShaderType.VERTEX, vertex);
inputs.put(PatchShaderType.GEOMETRY, geometry);
inputs.put(PatchShaderType.TESS_CONTROL, tessControl);
inputs.put(PatchShaderType.TESS_EVAL, tessEval);
inputs.put(PatchShaderType.FRAGMENT, fragment);
EnumMap<ShaderType, String> inputs = new EnumMap<>(ShaderType.class);
inputs.put(ShaderType.VERTEX, vertex);
inputs.put(ShaderType.GEOMETRY, geometry);
inputs.put(ShaderType.TESS_CTRL, tessControl);
inputs.put(ShaderType.TESS_EVALUATE, tessEval);
inputs.put(ShaderType.FRAGMENT, fragment);
var key = new TransformKey(patchType, inputs, parameters);
@@ -68,16 +67,16 @@ public class ShaderTransformer {
}
}
public static <P extends Parameters> Map<PatchShaderType, String> transformCompute(String name, String compute, P parameters) {
public static <P extends Parameters> Map<ShaderType, String> transformCompute(String name, String compute, P parameters) {
if (compute == null) {
return null;
} else {
Map<PatchShaderType, String> result;
Map<ShaderType, String> result;
var patchType = parameters.patch;
EnumMap<PatchShaderType, String> inputs = new EnumMap<>(PatchShaderType.class);
inputs.put(PatchShaderType.COMPUTE, compute);
EnumMap<ShaderType, String> inputs = new EnumMap<>(ShaderType.class);
inputs.put(ShaderType.COMPUTE, compute);
var key = new TransformKey(patchType, inputs, parameters);
@@ -123,12 +122,12 @@ public class ShaderTransformer {
return builder.toString();
}
private static <P extends Parameters> Map<PatchShaderType, String> transformInternal(String name, EnumMap<PatchShaderType, String> inputs, Patch patchType, P parameters) {
EnumMap<PatchShaderType, String> result = new EnumMap<>(PatchShaderType.class);
EnumMap<PatchShaderType, Transformer> types = new EnumMap<>(PatchShaderType.class);
EnumMap<PatchShaderType, String> prepatched = new EnumMap<>(PatchShaderType.class);
private static <P extends Parameters> Map<ShaderType, String> transformInternal(String name, EnumMap<ShaderType, String> inputs, Patch patchType, P parameters) {
EnumMap<ShaderType, String> result = new EnumMap<>(ShaderType.class);
EnumMap<ShaderType, Transformer> types = new EnumMap<>(ShaderType.class);
EnumMap<ShaderType, String> prepatched = new EnumMap<>(ShaderType.class);
for (PatchShaderType type : PatchShaderType.values()) {
for (ShaderType type : ShaderType.values()) {
parameters.type = type;
if (inputs.get(type) == null) {
continue;
@@ -258,7 +257,7 @@ public class ShaderTransformer {
}
public static void patchMultiTexCoord3(Transformer translationUnit, Parameters parameters) {
if (parameters.type.glShaderType == ShaderType.VERTEX && translationUnit.hasVariable("gl_MultiTexCoord3") && !translationUnit.hasVariable("mc_midTexCoord")) {
if (parameters.type == ShaderType.VERTEX && translationUnit.hasVariable("gl_MultiTexCoord3") && !translationUnit.hasVariable("mc_midTexCoord")) {
translationUnit.rename("gl_MultiTexCoord3", "mc_midTexCoord");
translationUnit.injectVariable("attribute vec4 mc_midTexCoord;");
}
@@ -323,19 +322,19 @@ public class ShaderTransformer {
public static void commonPatch(Transformer root, Parameters parameters, boolean core) {
root.rename("gl_FogFragCoord", "iris_FogFragCoord");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
root.injectVariable("out float iris_FogFragCoord;");
root.prependMain("iris_FogFragCoord = 0.0f;");
} else if (parameters.type.glShaderType == ShaderType.FRAGMENT) {
} else if (parameters.type == ShaderType.FRAGMENT) {
root.injectVariable("in float iris_FogFragCoord;");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
root.injectVariable("vec4 iris_FrontColor;");
root.rename("gl_FrontColor", "iris_FrontColor");
}
if (parameters.type.glShaderType == ShaderType.FRAGMENT) {
if (parameters.type == ShaderType.FRAGMENT) {
if (root.containsCall("gl_FragColor")) {
root.replaceExpression("gl_FragColor", "gl_FragData[0]", GLSLParser::unary_expression);
}
@@ -364,7 +363,7 @@ public class ShaderTransformer {
}
if (parameters.type.glShaderType == ShaderType.VERTEX || parameters.type.glShaderType == ShaderType.FRAGMENT) {
if (parameters.type == ShaderType.VERTEX || parameters.type == ShaderType.FRAGMENT) {
upgradeStorageQualifiers(root, parameters);
}
@@ -406,7 +405,7 @@ public class ShaderTransformer {
token.setText(GLSLParser.VOCABULARY.getLiteralName(GLSLParser.IN).replace("'", ""));
}
else if (token.getType() == GLSLParser.VARYING) {
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
token.setType(GLSLParser.OUT);
token.setText(GLSLParser.VOCABULARY.getLiteralName(GLSLParser.OUT).replace("'", ""));
} else {
@@ -1,6 +1,5 @@
package net.irisshaders.iris.pipeline.foss_transform;
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;
@@ -19,7 +18,7 @@ public class SodiumTransformer {
translationUnit.rename("chunkOffset", "u_RegionOffset");
translationUnit.injectVariable("uniform mat4 iris_LightmapTextureMatrix;");
if (parameters.type == PatchShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// _draw_translation replaced with Chunks[_draw_id].offset.xyz
translationUnit.replaceExpression("vaPosition", "_vert_position + _get_draw_translation(_draw_id)");
translationUnit.replaceExpression("vaColor", "_vert_color");
@@ -45,7 +44,7 @@ public class SodiumTransformer {
translationUnit.injectFunction("uniform mat4 iris_LightmapTextureMatrix;");
translationUnit.rename("gl_ProjectionMatrix", "iris_ProjectionMatrix");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.rename("gl_MultiTexCoord2", "gl_MultiTexCoord1");
translationUnit.replaceExpression("gl_MultiTexCoord0", "vec4(_vert_tex_diffuse_coord, 0.0f, 1.0f)");
@@ -61,7 +60,7 @@ public class SodiumTransformer {
translationUnit.rename("gl_Color", "_vert_color");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.rename("gl_Normal", "iris_Normal");
translationUnit.injectVariable("in vec3 iris_Normal;");
}
@@ -82,7 +81,7 @@ public class SodiumTransformer {
translationUnit.rename("gl_ModelViewMatrixInverse", "iris_ModelViewMatrixInverse");
translationUnit.rename("gl_ProjectionMatrixInverse", "iris_ProjectionMatrixInverse");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// TODO: Vaporwave-Shaderpack expects that vertex positions will be aligned to
// chunks.
if (translationUnit.containsCall("ftransform")) {
@@ -6,7 +6,6 @@ import net.irisshaders.iris.gl.state.ShaderAttributeInputs;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.helpers.Tri;
import net.irisshaders.iris.pipeline.transform.Patch;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.parameter.ComputeParameters;
import net.irisshaders.iris.pipeline.transform.parameter.DHParameters;
import net.irisshaders.iris.pipeline.transform.parameter.Parameters;
@@ -14,64 +13,25 @@ import net.irisshaders.iris.pipeline.transform.parameter.SodiumParameters;
import net.irisshaders.iris.pipeline.transform.parameter.TextureStageParameters;
import net.irisshaders.iris.pipeline.transform.parameter.VanillaParameters;
import net.irisshaders.iris.shaderpack.texture.TextureStage;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import java.lang.reflect.Method;
import java.util.Map;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class TransformPatcherBridge {
private static final boolean USE_GLSL_TRANSFORMER;
private static final Method transformPatcherTransform, transformPatcherTransformCompute;
static {
boolean useGlslTransformer = Boolean.getBoolean("cornea.use_glsl_transformer");
Method transform = null, transformCompute = null;
try {
Class<?> transformPatcher = Class.forName("net.irisshaders.iris.pipeline.transform.TransformPatcher");
transform = transformPatcher.getDeclaredMethod("transform", String.class, String.class, String.class, String.class, String.class, String.class, Parameters.class);
transformCompute = transformPatcher.getDeclaredMethod("transformCompute", String.class, String.class, Parameters.class);
} catch(ReflectiveOperationException e) {
}
if(useGlslTransformer && transform == null) {
IRIS_LOGGER.warn("glsl-transformer is requested, but is not available in this jar");
useGlslTransformer = false;
}
transformPatcherTransform = transform;
transformPatcherTransformCompute = transformCompute;
USE_GLSL_TRANSFORMER = useGlslTransformer;
}
private static Map<PatchShaderType, String> transform(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment,
private static Map<ShaderType, String> transform(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment,
Parameters parameters) {
if (USE_GLSL_TRANSFORMER) {
try {
return (Map<PatchShaderType, String>)transformPatcherTransform.invoke(null, name, vertex, geometry, tessControl, tessEval, fragment, parameters);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
} else {
return ShaderTransformer.transform(name, vertex, geometry, tessControl, tessEval, fragment, parameters);
}
}
private static Map<PatchShaderType, String> transformCompute(String name, String compute,
private static Map<ShaderType, String> transformCompute(String name, String compute,
Parameters parameters) {
if (USE_GLSL_TRANSFORMER) {
try {
return (Map<PatchShaderType, String>)transformPatcherTransformCompute.invoke(null, name, compute, parameters);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
} else {
return ShaderTransformer.transformCompute(name, compute, parameters);
}
}
public static Map<PatchShaderType, String> patchVanilla(
public static Map<ShaderType, String> patchVanilla(
String name, String vertex, String geometry, String tessControl, String tessEval, String fragment,
AlphaTest alpha, boolean isLines,
boolean hasChunkOffset,
@@ -82,7 +42,7 @@ public class TransformPatcherBridge {
}
public static Map<PatchShaderType, String> patchDHTerrain(
public static Map<ShaderType, String> patchDHTerrain(
String name, String vertex, String tessControl, String tessEval, String geometry, String fragment,
Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transform(name, vertex, geometry, tessControl, tessEval, fragment,
@@ -90,21 +50,21 @@ public class TransformPatcherBridge {
}
public static Map<PatchShaderType, String> patchDHGeneric(
public static Map<ShaderType, String> patchDHGeneric(
String name, String vertex, String tessControl, String tessEval, String geometry, String fragment,
Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transform(name, vertex, geometry, tessControl, tessEval, fragment,
new DHParameters(Patch.DH_GENERIC, textureMap));
}
public static Map<PatchShaderType, String> patchSodium(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment,
public static Map<ShaderType, String> patchSodium(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment,
AlphaTest alpha, ShaderAttributeInputs inputs,
Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transform(name, vertex, geometry, tessControl, tessEval, fragment,
new SodiumParameters(Patch.SODIUM, textureMap, alpha, inputs));
}
public static Map<PatchShaderType, String> patchComposite(
public static Map<ShaderType, String> patchComposite(
String name, String vertex, String geometry, String fragment,
TextureStage stage,
Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
@@ -116,6 +76,6 @@ public class TransformPatcherBridge {
TextureStage stage,
Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transformCompute(name, compute, new ComputeParameters(Patch.COMPUTE, stage, textureMap))
.getOrDefault(PatchShaderType.COMPUTE, null);
.getOrDefault(ShaderType.COMPUTE, null);
}
}
@@ -1,7 +1,6 @@
package net.irisshaders.iris.pipeline.foss_transform;
import net.irisshaders.iris.gl.blending.AlphaTests;
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;
@@ -22,7 +21,7 @@ public class VanillaTransformer {
ShaderTransformer.commonPatch(translationUnit, parameters, false);
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
// Alias of gl_MultiTexCoord1 on 1.15+ for OptiFine
// See https://github.com/IrisShaders/Iris/issues/1149
translationUnit.rename("gl_MultiTexCoord2", "gl_MultiTexCoord1");
@@ -58,7 +57,7 @@ public class VanillaTransformer {
translationUnit.injectVariable(
"uniform vec4 iris_ColorModulator;");
if (parameters.inputs.hasColor() && parameters.type == PatchShaderType.VERTEX) {
if (parameters.inputs.hasColor() && parameters.type == ShaderType.VERTEX) {
// TODO: Handle the fragment / geometry shader here
if (parameters.alpha == AlphaTests.VERTEX_ALPHA) {
translationUnit.replaceExpression("gl_Color",
@@ -68,7 +67,7 @@ public class VanillaTransformer {
"(iris_Color * iris_ColorModulator)");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.injectVariable(
"in vec4 iris_Color;");
}
@@ -82,7 +81,7 @@ public class VanillaTransformer {
translationUnit.rename("gl_Color", "iris_ColorModulator");
}
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
if (parameters.inputs.hasNormal()) {
if (!parameters.inputs.isNewLines()) {
translationUnit.rename("gl_Normal", "iris_Normal");
@@ -121,7 +120,7 @@ public class VanillaTransformer {
translationUnit.injectVariable("uniform mat4 iris_ProjMatInverse;");
translationUnit.injectVariable("uniform mat4 iris_ModelViewMatInverse;");
if (parameters.type.glShaderType == ShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.injectVariable(
"in vec3 iris_Position;");
if (translationUnit.containsCall("ftransform")) {
@@ -249,7 +248,7 @@ public class VanillaTransformer {
upgradeStorageQualifiers(translationUnit, parameters);
if (parameters.type == PatchShaderType.VERTEX) {
if (parameters.type == ShaderType.VERTEX) {
translationUnit.replaceExpression("gl_Vertex", "vec4(iris_Position, 1.0)");
translationUnit.rename("vaPosition", "iris_Position");
if (parameters.inputs.hasColor()) {
@@ -1,32 +0,0 @@
package net.irisshaders.iris.pipeline.transform;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
public enum PatchShaderType {
VERTEX(ShaderType.VERTEX, ".vsh"),
GEOMETRY(ShaderType.GEOMETRY, ".gsh"),
TESS_CONTROL(ShaderType.TESSELATION_CONTROL, ".tcs"),
TESS_EVAL(ShaderType.TESSELATION_EVAL, ".tes"),
FRAGMENT(ShaderType.FRAGMENT, ".fsh"),
COMPUTE(ShaderType.COMPUTE, ".csh");
public final ShaderType glShaderType;
public final String extension;
PatchShaderType(ShaderType glShaderType, String extension) {
this.glShaderType = glShaderType;
this.extension = extension;
}
public static PatchShaderType[] fromGlShaderType(ShaderType glShaderType) {
return switch (glShaderType) {
case VERTEX -> new PatchShaderType[]{VERTEX};
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,6 +1,8 @@
package net.irisshaders.iris.pipeline.transform;
import org.apache.commons.io.FilenameUtils;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
import org.embeddedt.embeddium.impl.util.PlatformUtil;
import org.taumc.celeritas.api.v0.CeleritasShadersApi;
import java.io.IOException;
@@ -64,7 +66,7 @@ public class ShaderPrinter {
private final String prefix = isActive ? String.format("%03d_", ++programCounter) : null;
// the prefix and the sources list aren't created if debug is disabled
private final List<String> sources = isActive ? new ArrayList<>(PatchShaderType.values().length * 2) : null;
private final List<String> sources = isActive ? new ArrayList<>(ShaderType.values().length * 2) : null;
private String name;
private boolean done = false; // makes the print function idempotent
@@ -85,19 +87,19 @@ public class ShaderPrinter {
}
}
public ProgramPrintBuilder addSource(PatchShaderType type, String source) {
public ProgramPrintBuilder addSource(ShaderType type, String source) {
if (sources == null) {
return this;
}
addItem(type.extension, source);
addItem("." + type.fileExtension, source);
return this;
}
public ProgramPrintBuilder addSources(Map<PatchShaderType, String> sources) {
public ProgramPrintBuilder addSources(Map<ShaderType, String> sources) {
if (sources == null) {
return this;
}
for (Map.Entry<PatchShaderType, String> entry : sources.entrySet()) {
for (Map.Entry<ShaderType, String> entry : sources.entrySet()) {
addSource(entry.getKey(), entry.getValue());
}
return this;
@@ -5,13 +5,13 @@ import net.irisshaders.iris.gl.blending.AlphaTest;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.helpers.Tri;
import net.irisshaders.iris.pipeline.transform.Patch;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.shaderpack.texture.TextureStage;
import org.embeddedt.embeddium.impl.gl.shader.ShaderType;
public abstract class Parameters {
public final Patch patch;
private final Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap;
public PatchShaderType type; // may only be set by TransformPatcher
public ShaderType type; // may only be set by TransformPatcher
// WARNING: adding new fields requires updating hashCode and equals methods!
public Parameters(Patch patch, Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
@@ -24,7 +24,6 @@ import net.irisshaders.iris.gl.texture.TextureAccess;
import net.irisshaders.iris.pathways.FullScreenQuadRenderer;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisImages;
import net.irisshaders.iris.samplers.IrisSamplers;
@@ -246,14 +245,14 @@ public class ShadowCompositeRenderer {
private Program createProgram(ProgramSource source, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot,
ShadowRenderTargets targets) {
// TODO: Properly handle empty shaders
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchComposite(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchComposite(
source.getName(),
source.getSource(ShaderType.VERTEX).orElseThrow(NullPointerException::new),
source.getSourceNullable(ShaderType.GEOM),
source.getSource(ShaderType.FRAGMENT).orElseThrow(NullPointerException::new), TextureStage.SHADOWCOMP, pipeline.getTextureMap());
String vertex = transformed.get(PatchShaderType.VERTEX);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String geometry = transformed.get(ShaderType.GEOMETRY);
String fragment = transformed.get(ShaderType.FRAGMENT);
ShaderPrinter.printProgram(source.getName()).addSources(transformed).print();
Objects.requireNonNull(flipped);
@@ -299,7 +298,7 @@ public class ShadowCompositeRenderer {
try {
String transformed = TransformPatcherBridge.patchCompute(source.getName(), source.getSource().orElse(null), TextureStage.SHADOWCOMP, pipeline.getTextureMap());
ShaderPrinter.printProgram(source.getName()).addSource(PatchShaderType.COMPUTE, transformed).print();
ShaderPrinter.printProgram(source.getName()).addSource(ShaderType.COMPUTE, transformed).print();
builder = ProgramBuilder.beginCompute(source.getName(), transformed, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
@@ -30,7 +30,6 @@ import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisSamplers;
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
@@ -156,7 +155,7 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
}
public static IrisGenericRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, ModernIrisRenderingPipeline pipeline) {
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchDHGeneric(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchDHGeneric(
name,
source.getSource(ShaderType.VERTEX).orElseThrow(RuntimeException::new),
source.getSource(ShaderType.TESS_CTRL).orElse(null),
@@ -164,11 +163,11 @@ public class IrisGenericRenderProgram implements IDhApiGenericObjectShaderProgra
source.getSource(ShaderType.GEOM).orElse(null),
source.getSource(ShaderType.FRAGMENT).orElseThrow(RuntimeException::new),
pipeline.getTextureMap());
String vertex = transformed.get(PatchShaderType.VERTEX);
String tessControl = transformed.get(PatchShaderType.TESS_CONTROL);
String tessEval = transformed.get(PatchShaderType.TESS_EVAL);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String tessControl = transformed.get(ShaderType.TESS_CTRL);
String tessEval = transformed.get(ShaderType.TESS_EVALUATE);
String geometry = transformed.get(ShaderType.GEOMETRY);
String fragment = transformed.get(ShaderType.FRAGMENT);
ShaderPrinter.printProgram(name + "_g")
.addSources(transformed)
.setName("dh_" + name + "_g")
@@ -21,7 +21,6 @@ import net.irisshaders.iris.gl.state.FogMode;
import net.irisshaders.iris.gl.texture.TextureType;
import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.samplers.IrisSamplers;
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
@@ -136,7 +135,7 @@ public class IrisLodRenderProgram {
}
public static IrisLodRenderProgram createProgram(String name, boolean isShadowPass, boolean translucent, ProgramSource source, CustomUniforms uniforms, ModernIrisRenderingPipeline pipeline) {
Map<PatchShaderType, String> transformed = TransformPatcherBridge.patchDHTerrain(
Map<ShaderType, String> transformed = TransformPatcherBridge.patchDHTerrain(
name,
source.getSource(ShaderType.VERTEX).orElseThrow(RuntimeException::new),
source.getSource(ShaderType.TESS_CTRL).orElse(null),
@@ -144,11 +143,11 @@ public class IrisLodRenderProgram {
source.getSource(ShaderType.GEOM).orElse(null),
source.getSource(ShaderType.FRAGMENT).orElseThrow(RuntimeException::new),
pipeline.getTextureMap());
String vertex = transformed.get(PatchShaderType.VERTEX);
String tessControl = transformed.get(PatchShaderType.TESS_CONTROL);
String tessEval = transformed.get(PatchShaderType.TESS_EVAL);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String tessControl = transformed.get(ShaderType.TESS_CTRL);
String tessEval = transformed.get(ShaderType.TESS_EVALUATE);
String geometry = transformed.get(ShaderType.GEOMETRY);
String fragment = transformed.get(ShaderType.FRAGMENT);
ShaderPrinter.printProgram(name)
.addSources(transformed)
.setName("dh_" + name)
@@ -15,7 +15,6 @@ import net.irisshaders.iris.pipeline.ModernIrisRenderingPipeline;
import net.irisshaders.iris.pipeline.WorldRenderingPipeline;
import net.irisshaders.iris.pipeline.fallback.ShaderSynthesizer;
import net.irisshaders.iris.pipeline.foss_transform.TransformPatcherBridge;
import net.irisshaders.iris.pipeline.transform.PatchShaderType;
import net.irisshaders.iris.pipeline.transform.ShaderPrinter;
import net.irisshaders.iris.shaderpack.loading.ProgramId;
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
@@ -75,11 +74,11 @@ public class ShaderCreator {
alpha, isLines, true, inputs, pipeline.getTextureMap());
}, Util.backgroundExecutor()).thenApplyAsync(transformed -> {
String vertex = transformed.get(PatchShaderType.VERTEX);
String geometry = transformed.get(PatchShaderType.GEOMETRY);
String tessControl = transformed.get(PatchShaderType.TESS_CONTROL);
String tessEval = transformed.get(PatchShaderType.TESS_EVAL);
String fragment = transformed.get(PatchShaderType.FRAGMENT);
String vertex = transformed.get(ShaderType.VERTEX);
String geometry = transformed.get(ShaderType.GEOMETRY);
String tessControl = transformed.get(ShaderType.TESS_CTRL);
String tessEval = transformed.get(ShaderType.TESS_EVALUATE);
String fragment = transformed.get(ShaderType.FRAGMENT);
String shaderJsonString = String.format("""
{
@@ -191,8 +190,8 @@ public class ShaderCreator {
]
}""", name, name);
ShaderPrinter.printProgram(name)
.addSource(PatchShaderType.VERTEX, vertex)
.addSource(PatchShaderType.FRAGMENT, fragment)
.addSource(ShaderType.VERTEX, vertex)
.addSource(ShaderType.FRAGMENT, fragment)
.addJson(shaderJsonString)
.print();