Skip to content

Commit 7a24ded

Browse files
committed
Merge branch '1.18.2' into 1.19.1
# Conflicts: # README.md
2 parents 23edd63 + 8a6cdbb commit 7a24ded

File tree

10 files changed

+77
-37
lines changed

10 files changed

+77
-37
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
## Links
66

7-
* **Visit [our website](https://irisshaders.net) for downloads and pretty screenshots!**\
8-
* **Visit [Modrinth](https://modrinth.com/shaders) to find shader packs!**
7+
* **Visit [our website](https://irisshaders.dev) for downloads and pretty screenshots!**
8+
* * **Visit [Modrinth](https://modrinth.com/shaders) to find shader packs!**
99
* Visit [our Discord server](https://discord.gg/jQJnav2jPu) to chat about the mod and get support! It's also a great place to get development updates right as they're happening.
1010
* Visit [the developer documentation](https://github.com/IrisShaders/Iris/tree/trunk/docs/development) for information on developing, building, and contributing to Iris!
1111

src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class MixinGameRenderer {
5656
itemInHandRenderer.renderHandsWithItems(tickDelta, poseStack, bufferSource, localPlayer, light);
5757
}
5858

59+
@Inject(method = "renderLevel", at = @At("TAIL"))
60+
private void iris$runColorSpace(float pGameRenderer0, long pLong1, PoseStack pPoseStack2, CallbackInfo ci) {
61+
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::finalizeGameRendering);
62+
}
63+
5964
@Redirect(method = "reloadShaders", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/Lists;newArrayList()Ljava/util/ArrayList;"))
6065
private ArrayList<Program> iris$reloadGeometryShaders() {
6166
ArrayList<Program> programs = Lists.newArrayList();

src/main/java/net/coderbot/iris/pipeline/DeferredWorldRenderingPipeline.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ public void finalizeLevelRendering() {
12881288
isRenderingFullScreenPass = false;
12891289
}
12901290

1291+
@Override
1292+
public void finalizeGameRendering() {
1293+
1294+
}
1295+
12911296
@Override
12921297
public SodiumTerrainPipeline getSodiumTerrainPipeline() {
12931298
return sodiumTerrainPipeline;

src/main/java/net/coderbot/iris/pipeline/FixedFunctionWorldRenderingPipeline.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ public void finalizeLevelRendering() {
140140
// stub: nothing to do here
141141
}
142142

143+
@Override
144+
public void finalizeGameRendering() {
145+
// stub: nothing to do here
146+
}
147+
143148
@Override
144149
public void destroy() {
145150
// stub: nothing to do here

src/main/java/net/coderbot/iris/pipeline/WorldRenderingPipeline.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public interface WorldRenderingPipeline {
4545

4646
void beginTranslucents();
4747
void finalizeLevelRendering();
48+
void finalizeGameRendering();
4849
void destroy();
4950

5051
SodiumTerrainPipeline getSodiumTerrainPipeline();

src/main/java/net/coderbot/iris/pipeline/newshader/NewWorldRenderingPipeline.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,10 @@ public void finalizeLevelRendering() {
10941094
isRenderingWorld = false;
10951095
compositeRenderer.renderAll();
10961096
finalPassRenderer.renderFinalPass();
1097+
}
1098+
1099+
@Override
1100+
public void finalizeGameRendering() {
10971101
colorSpaceConverter.process(Minecraft.getInstance().getMainRenderTarget().getColorTextureId());
10981102
}
10991103

src/main/java/net/coderbot/iris/shaderpack/ShaderPack.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@
4545
import java.nio.file.Files;
4646
import java.nio.file.NoSuchFileException;
4747
import java.nio.file.Path;
48-
import java.util.*;
48+
import java.util.ArrayList;
49+
import java.util.Collections;
50+
import java.util.EnumMap;
51+
import java.util.HashMap;
52+
import java.util.HashSet;
53+
import java.util.List;
54+
import java.util.Map;
55+
import java.util.Objects;
56+
import java.util.Optional;
57+
import java.util.Properties;
58+
import java.util.Set;
4959
import java.util.function.Function;
5060
import java.util.stream.Collectors;
5161
import java.util.stream.Stream;
@@ -73,7 +83,7 @@ public class ShaderPack {
7383
private List<String> dimensionIds;
7484
private Map<NamespacedId, String> dimensionMap;
7585

76-
public ShaderPack(Path root, Iterable<StringPair> environmentDefines) throws IOException, IllegalStateException {
86+
public ShaderPack(Path root, ImmutableList<StringPair> environmentDefines) throws IOException, IllegalStateException {
7787
this(root, Collections.emptyMap(), environmentDefines);
7888
}
7989

@@ -87,11 +97,13 @@ public ShaderPack(Path root, Iterable<StringPair> environmentDefines) throws IOE
8797
* have completed, and there is no need to hold on to the path for that reason.
8898
* @throws IOException if there are any IO errors during shader pack loading.
8999
*/
90-
public ShaderPack(Path root, Map<String, String> changedConfigs, Iterable<StringPair> environmentDefines) throws IOException, IllegalStateException {
100+
public ShaderPack(Path root, Map<String, String> changedConfigs, ImmutableList<StringPair> environmentDefines) throws IOException, IllegalStateException {
91101
// A null path is not allowed.
92102
Objects.requireNonNull(root);
93103

94-
104+
ArrayList<StringPair> envDefines1 = new ArrayList<>(environmentDefines);
105+
envDefines1.addAll(IrisDefines.createIrisReplacements());
106+
environmentDefines = ImmutableList.copyOf(envDefines1);
95107
ImmutableList.Builder<AbsolutePackPath> starts = ImmutableList.builder();
96108
ImmutableList<String> potentialFileNames = ShaderPackSourceNames.POTENTIAL_STARTS;
97109

@@ -151,10 +163,9 @@ public ShaderPack(Path root, Map<String, String> changedConfigs, Iterable<String
151163
this.shaderPackOptions = new ShaderPackOptions(graph, changedConfigs);
152164
graph = this.shaderPackOptions.getIncludes();
153165

154-
Iterable<StringPair> replacements = IrisDefines.createIrisReplacements();
155166
Iterable<StringPair> finalEnvironmentDefines = environmentDefines;
156167
this.shaderProperties = loadProperties(root, "shaders.properties")
157-
.map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines, replacements))
168+
.map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines))
158169
.orElseGet(ShaderProperties::empty);
159170

160171
activeFeatures = new HashSet<>();
@@ -199,7 +210,7 @@ public ShaderPack(Path root, Map<String, String> changedConfigs, Iterable<String
199210
List<String> optionalFeatureFlags = shaderProperties.getOptionalFeatureFlags().stream().filter(flag -> !FeatureFlags.isInvalid(flag)).collect(Collectors.toList());
200211

201212
if (!optionalFeatureFlags.isEmpty()) {
202-
213+
optionalFeatureFlags.forEach(flag -> Iris.logger.warn("Found flag " + flag));
203214
optionalFeatureFlags.forEach(flag -> newEnvDefines.add(new StringPair("IRIS_FEATURE_" + flag, "")));
204215

205216
}
@@ -239,8 +250,7 @@ public ShaderPack(Path root, Map<String, String> changedConfigs, Iterable<String
239250
IncludeProcessor includeProcessor = new IncludeProcessor(graph);
240251

241252
// Set up our source provider for creating ProgramSets
242-
ArrayList<StringPair> finalEnvironmentDefines1 = new ArrayList<>((Collection) finalEnvironmentDefines);
243-
finalEnvironmentDefines1.addAll(IrisDefines.createIrisReplacements());
253+
Iterable<StringPair> finalEnvironmentDefines1 = environmentDefines;
244254
this.sourceProvider = (path) -> {
245255
String pathString = path.getPathString();
246256
// Removes the first "/" in the path if present, and the file

src/main/java/net/coderbot/iris/shaderpack/ShaderProperties.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor;
3030
import net.coderbot.iris.shaderpack.texture.TextureStage;
3131
import net.coderbot.iris.uniforms.custom.CustomUniforms;
32+
import net.fabricmc.loader.api.FabricLoader;
3233

3334
import java.io.IOException;
3435
import java.io.StringReader;
36+
import java.nio.file.Files;
3537
import java.util.ArrayList;
3638
import java.util.Arrays;
3739
import java.util.EnumMap;
@@ -111,13 +113,18 @@ private ShaderProperties() {
111113
}
112114

113115
// TODO: Is there a better solution than having ShaderPack pass a root path to ShaderProperties to be able to read textures?
114-
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines, Iterable<StringPair> replacements) {
115-
for (StringPair pair : replacements) {
116-
contents = contents.replaceAll("\\b" + pair.getKey() + "\\b", pair.getValue());
117-
}
118-
116+
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
119117
String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines);
120118

119+
if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
120+
try {
121+
Files.writeString(FabricLoader.getInstance().getGameDir().resolve("preprocessed.properties"), preprocessedContents);
122+
Files.writeString(FabricLoader.getInstance().getGameDir().resolve("original.properties"), contents);
123+
} catch (IOException e) {
124+
throw new RuntimeException(e);
125+
}
126+
}
127+
121128
Properties preprocessed = new OrderBackedProperties();
122129
Properties original = new OrderBackedProperties();
123130
try {
@@ -524,10 +531,6 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
524531
customUniforms.addVariable(parts[0], parts[1], value, true);
525532
});
526533

527-
528-
handleWhitespacedListDirective(key, value, "iris.features.required", options -> requiredFeatureFlags = options);
529-
handleWhitespacedListDirective(key, value, "iris.features.optional", options -> optionalFeatureFlags = options);
530-
531534
// TODO: Buffer size directives
532535
// TODO: Conditional program enabling directives
533536
});
@@ -537,6 +540,9 @@ public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, It
537540
String key = (String) keyObject;
538541
String value = (String) valueObject;
539542

543+
handleWhitespacedListDirective(key, value, "iris.features.required", options -> requiredFeatureFlags = options);
544+
handleWhitespacedListDirective(key, value, "iris.features.optional", options -> optionalFeatureFlags = options);
545+
540546
// Defining "sliders" multiple times in the properties file will only result in
541547
// the last definition being used, should be tested if behavior matches OptiFine
542548
handleWhitespacedListDirective(key, value, "sliders", sliders -> sliderOptions = sliders);

src/main/java/net/coderbot/iris/shaderpack/preprocessor/PropertiesPreprocessor.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.anarres.cpp.Feature;
77
import org.anarres.cpp.LexerException;
88
import org.anarres.cpp.Preprocessor;
9+
import org.anarres.cpp.PreprocessorCommand;
910
import org.anarres.cpp.StringLexerSource;
1011
import org.anarres.cpp.Token;
1112

@@ -14,6 +15,7 @@
1415
import java.util.Arrays;
1516
import java.util.HashMap;
1617
import java.util.List;
18+
import java.util.Locale;
1719
import java.util.Map;
1820
import java.util.stream.Collectors;
1921

@@ -78,19 +80,21 @@ private static String process(Preprocessor preprocessor, String source) {
7880
// Not super efficient, but this removes trailing whitespace on lines, fixing an issue with whitespace after
7981
// line continuations (see PreprocessorTest#testWeirdPropertiesLineContinuation)
8082
// Required for Voyager Shader
81-
source = Arrays.stream(source.split("\\R")).map(String::trim)
82-
.map(line -> {
83-
if (line.startsWith("#")) {
83+
source = Arrays.stream(source.split("\\R")).map(String::trim)
84+
.map(line -> {
85+
if (line.startsWith("#")) {
86+
for (PreprocessorCommand command : PreprocessorCommand.values()) {
87+
if (line.startsWith("#" + (command.name().replace("PP_", "").toLowerCase(Locale.ROOT)))) {
88+
return line;
89+
}
90+
}
91+
return "";
92+
}
8493
// In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and
8594
// assume the line to be a comment, since in .properties files `#` also functions as a comment
8695
// marker.
87-
return line;
88-
} else {
89-
// This is a hack to ensure that non-macro lines don't have any preprocessing applied...
90-
// In properties files, we don't substitute #define values except on macro lines.
91-
return "#warning IRIS_PASSTHROUGH " + line;
92-
}
93-
}).collect(Collectors.joining("\n")) + "\n";
96+
return line.replace("#", "");
97+
}).collect(Collectors.joining("\n")) + "\n";
9498
// TODO: This is a horrible fix to trick the preprocessor into not seeing the backslashes during processing. We need a better way to do this.
9599
source = source.replace("\\", "IRIS_PASSTHROUGHBACKSLASH");
96100

src/main/resources/colorSpace.csh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ layout(rgba8) uniform image2D readImage;
1010
#else
1111
uniform sampler2D readImage;
1212
in vec2 uv;
13-
out vec3 outColor;
13+
out vec4 outColor;
1414
#endif
1515

1616
// https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics
@@ -107,13 +107,13 @@ void main() {
107107
#if CURRENT_COLOR_SPACE != SRGB
108108
#ifdef COMPUTE
109109
ivec2 PixelIndex = ivec2(gl_GlobalInvocationID.xy);
110-
vec3 SourceColor = imageLoad(readImage, PixelIndex).rgb;
110+
vec4 SourceColor = imageLoad(readImage, PixelIndex);
111111
#else
112-
vec3 SourceColor = texture(readImage, uv).rgb;
112+
vec4 SourceColor = texture(readImage, uv);
113113
#endif
114-
SourceColor = InverseEOTF_IEC61966(SourceColor);
114+
SourceColor.rgb = InverseEOTF_IEC61966(SourceColor.rgb);
115115
116-
vec3 TargetColor = SourceColor;
116+
vec3 TargetColor = SourceColor.rgb;
117117
118118
#if CURRENT_COLOR_SPACE == DCI_P3
119119
// https://en.wikipedia.org/wiki/DCI-P3
@@ -137,9 +137,9 @@ void main() {
137137
138138
#endif
139139
#ifdef COMPUTE
140-
imageStore(readImage, PixelIndex, vec4(TargetColor, 1.0));
140+
imageStore(readImage, PixelIndex, vec4(TargetColor, SourceColor.a));
141141
#else
142-
outColor = TargetColor;
142+
outColor = vec4(TargetColor, SourceColor.a);
143143
#endif
144144
#endif
145145
}

0 commit comments

Comments
 (0)