mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-24 06:04:27 +00:00
Shadow Compute Shaders (#1333)
This commit is contained in:
1 parent
b75a5d8f7d
commit
bee9541797
37 files changed
+1111
-252
No files matched your search
@@ -21,6 +21,7 @@ public class ProgramDirectives {
|
||||
private static final ImmutableList<String> LEGACY_RENDER_TARGETS = PackRenderTargetDirectives.LEGACY_RENDER_TARGETS;
|
||||
|
||||
private final int[] drawBuffers;
|
||||
private boolean unknownDrawBuffers;
|
||||
private final ViewportData viewportScale;
|
||||
@Nullable
|
||||
private final AlphaTestOverride alphaTestOverride;
|
||||
@@ -40,6 +41,7 @@ public class ProgramDirectives {
|
||||
this.bufferBlendInformations = bufferBlendInformations;
|
||||
this.mipmappedBuffers = mipmappedBuffers;
|
||||
this.explicitFlips = explicitFlips;
|
||||
this.unknownDrawBuffers = false;
|
||||
}
|
||||
|
||||
ProgramDirectives(ProgramSource source, ShaderProperties properties, Set<Integer> supportedRenderTargets, @Nullable BlendModeOverride defaultBlendOverride) {
|
||||
@@ -53,7 +55,7 @@ public class ProgramDirectives {
|
||||
final Optional<CommentDirective> optionalDrawbuffersDirective = findDrawbuffersDirective(source.getFragmentSource());
|
||||
final Optional<CommentDirective> optionalRendertargetsDirective = findRendertargetsDirective(source.getFragmentSource());
|
||||
|
||||
final Optional<CommentDirective> optionalCommentDirective = getAppliedDirective(optionalDrawbuffersDirective, optionalRendertargetsDirective);
|
||||
Optional<CommentDirective> optionalCommentDirective = getAppliedDirective(optionalDrawbuffersDirective, optionalRendertargetsDirective);
|
||||
drawBuffers = optionalCommentDirective.map(commentDirective -> {
|
||||
if (commentDirective.getType() == CommentDirective.Type.DRAWBUFFERS) {
|
||||
return parseDigits(commentDirective.getDirective().toCharArray());
|
||||
@@ -62,7 +64,10 @@ public class ProgramDirectives {
|
||||
} else {
|
||||
throw new IllegalStateException("Unhandled comment directive type!");
|
||||
}
|
||||
}).orElse(new int[] { 0 });
|
||||
}).orElseGet(() -> {
|
||||
unknownDrawBuffers = true;
|
||||
return new int[]{0};
|
||||
});
|
||||
|
||||
if (properties != null) {
|
||||
viewportScale = properties.getViewportScaleOverrides().getOrDefault(source.getName(), ViewportData.defaultValue());
|
||||
@@ -160,6 +165,10 @@ public class ProgramDirectives {
|
||||
return drawBuffers;
|
||||
}
|
||||
|
||||
public boolean hasUnknownDrawBuffers() {
|
||||
return unknownDrawBuffers;
|
||||
}
|
||||
|
||||
public ViewportData getViewportScale() {
|
||||
return viewportScale;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ public class ShaderPack {
|
||||
public final CustomUniforms.Builder customUniforms;
|
||||
|
||||
private final ProgramSet base;
|
||||
private final Set<FeatureFlags> activeFeatures;
|
||||
|
||||
private final Map<String, String> dimensionMap;
|
||||
private final Map<String, ProgramSet> dimensionProgramSets;
|
||||
@@ -211,15 +212,29 @@ public class ShaderPack {
|
||||
List<StringPair> finalEnvironmentDefines = new ArrayList<>();
|
||||
environmentDefines.forEach(finalEnvironmentDefines::add);
|
||||
for (FeatureFlags flag : FeatureFlags.values()) {
|
||||
if (flag.isUsable()) {
|
||||
boolean usable = flag.isUsable();
|
||||
Iris.logger.info("FeatureFlag {} usable: {}", flag.name(), usable);
|
||||
if (usable) {
|
||||
finalEnvironmentDefines.add(new StringPair("IRIS_FEATURE_" + flag.name(), ""));
|
||||
}
|
||||
}
|
||||
Iris.logger.info("Environment defines: {}", finalEnvironmentDefines.stream()
|
||||
.map(p -> p.getKey() + "=" + p.getValue())
|
||||
.collect(java.util.stream.Collectors.joining(", ")));
|
||||
|
||||
this.shaderProperties = Optional.ofNullable(readProperties(root, "shaders.properties"))
|
||||
.map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines))
|
||||
.orElseGet(ShaderProperties::empty);
|
||||
|
||||
// Build the set of active feature flags from required and optional flags
|
||||
this.activeFeatures = new HashSet<>();
|
||||
for (String flag : shaderProperties.getRequiredFeatureFlags()) {
|
||||
activeFeatures.add(FeatureFlags.getValue(flag));
|
||||
}
|
||||
for (String flag : shaderProperties.getOptionalFeatureFlags()) {
|
||||
activeFeatures.add(FeatureFlags.getValue(flag));
|
||||
}
|
||||
|
||||
List<FeatureFlags> invalidFlagList = shaderProperties.getRequiredFeatureFlags().stream().filter(FeatureFlags::isInvalid).map(FeatureFlags::getValue).collect(Collectors.toList());
|
||||
List<String> invalidFeatureFlags = invalidFlagList.stream().map(FeatureFlags::getHumanReadableName).collect(Collectors.toList());
|
||||
|
||||
@@ -717,4 +732,11 @@ public class ShaderPack {
|
||||
return Optional.ofNullable(customNoiseTexture);
|
||||
}
|
||||
|
||||
public Set<FeatureFlags> getActiveFeatures() {
|
||||
return activeFeatures;
|
||||
}
|
||||
|
||||
public boolean hasFeature(FeatureFlags feature) {
|
||||
return activeFeatures.contains(feature);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user