mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-27 15:43:02 +00:00
Distant Horizons shader support (#1553)
This commit is contained in:
1 parent
3ea47c8385
commit
057ea8035c
52 files changed
+2270
-135
No files matched your search
@@ -28,7 +28,7 @@ public class PackDirectives {
|
||||
@Getter private float eyeBrightnessHalfLife;
|
||||
@Getter private float centerDepthHalfLife;
|
||||
@Getter private CloudSetting cloudSetting;
|
||||
@Getter private CloudSetting dhCloudSetting;
|
||||
private CloudSetting dhCloudSetting;
|
||||
private boolean underwaterOverlay;
|
||||
private boolean vignette;
|
||||
private boolean sun;
|
||||
@@ -181,6 +181,10 @@ public class PackDirectives {
|
||||
return concurrentCompute;
|
||||
}
|
||||
|
||||
public CloudSetting getDHCloudSetting() {
|
||||
return dhCloudSetting;
|
||||
}
|
||||
|
||||
private static float clamp(float val, float lo, float hi) {
|
||||
return Math.max(lo, Math.min(hi, val));
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public class PackShadowDirectives {
|
||||
private final boolean shouldRenderPlayer;
|
||||
private final boolean shouldRenderBlockEntities;
|
||||
@Getter private final ShadowCullState cullingState;
|
||||
private final OptionalBoolean dhShadowEnabled;
|
||||
private float nearPlane, farPlane;
|
||||
|
||||
private final ImmutableList<DepthSamplingSettings> depthSamplingSettings;
|
||||
private final ImmutableList<SamplingSettings> colorSamplingSettings;
|
||||
@@ -53,6 +55,8 @@ public class PackShadowDirectives {
|
||||
// shadowRenderDistanceMul to a nonzero value, since having a high shadow render distance will impact
|
||||
// performance quite heavily on most systems.
|
||||
this.distance = 160.0f;
|
||||
this.nearPlane = 0.05f;
|
||||
this.farPlane = 256.0f;
|
||||
this.voxelDistance = 0.0f;
|
||||
|
||||
// By default, shadows are not culled based on distance from the player. However, pack authors may
|
||||
@@ -81,6 +85,7 @@ public class PackShadowDirectives {
|
||||
this.shouldRenderBlockEntities = properties.getShadowBlockEntities().orElse(true);
|
||||
this.cullingState = properties.getShadowCulling();
|
||||
this.shadowEnabled = properties.getShadowEnabled();
|
||||
this.dhShadowEnabled = properties.getDhShadowEnabled();
|
||||
|
||||
this.depthSamplingSettings = ImmutableList.of(new DepthSamplingSettings(), new DepthSamplingSettings());
|
||||
|
||||
@@ -97,6 +102,8 @@ public class PackShadowDirectives {
|
||||
this.resolution = shadowDirectives.resolution;
|
||||
this.fov = shadowDirectives.fov;
|
||||
this.distance = shadowDirectives.distance;
|
||||
this.nearPlane = shadowDirectives.nearPlane;
|
||||
this.farPlane = shadowDirectives.farPlane;
|
||||
this.voxelDistance = shadowDirectives.voxelDistance;
|
||||
this.distanceRenderMul = shadowDirectives.distanceRenderMul;
|
||||
this.entityShadowDistanceMul = shadowDirectives.entityShadowDistanceMul;
|
||||
@@ -111,6 +118,7 @@ public class PackShadowDirectives {
|
||||
this.depthSamplingSettings = shadowDirectives.depthSamplingSettings;
|
||||
this.colorSamplingSettings = shadowDirectives.colorSamplingSettings;
|
||||
this.shadowEnabled = shadowDirectives.shadowEnabled;
|
||||
this.dhShadowEnabled = shadowDirectives.dhShadowEnabled;
|
||||
}
|
||||
|
||||
public int getResolution() {
|
||||
@@ -125,6 +133,18 @@ public class PackShadowDirectives {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public float getNearPlane() {
|
||||
return nearPlane;
|
||||
}
|
||||
|
||||
public float getFarPlane() {
|
||||
return farPlane;
|
||||
}
|
||||
|
||||
public OptionalBoolean isDhShadowEnabled() {
|
||||
return dhShadowEnabled;
|
||||
}
|
||||
|
||||
public float getVoxelDistance() {
|
||||
return voxelDistance;
|
||||
}
|
||||
@@ -186,7 +206,8 @@ public class PackShadowDirectives {
|
||||
|
||||
directives.acceptCommentFloatDirective("SHADOWHPL", distance -> this.distance = distance);
|
||||
directives.acceptConstFloatDirective("shadowDistance", distance -> this.distance = distance);
|
||||
|
||||
directives.acceptConstFloatDirective("shadowNearPlane", nearPlane -> this.nearPlane = nearPlane);
|
||||
directives.acceptConstFloatDirective("shadowFarPlane", farPlane -> this.farPlane = farPlane);
|
||||
directives.acceptConstFloatDirective("entityShadowDistanceMul", distance -> this.entityShadowDistanceMul = distance);
|
||||
|
||||
directives.acceptConstFloatDirective("shadowDistanceRenderMul", distanceRenderMul -> {
|
||||
|
||||
@@ -56,7 +56,10 @@ public class ProgramSet {
|
||||
private final ComputeSource[][] compositeCompute;
|
||||
private final ProgramSource compositeFinal;
|
||||
private final ComputeSource[] finalCompute;
|
||||
|
||||
private final ProgramSource dhTerrain;
|
||||
private final ProgramSource dhGeneric;
|
||||
private final ProgramSource dhWater;
|
||||
private final ProgramSource dhShadow;
|
||||
|
||||
private final ShaderPack pack;
|
||||
|
||||
@@ -119,6 +122,10 @@ public class ProgramSet {
|
||||
this.gbuffersBlock = readProgramSource(directory, sourceProvider, "gbuffers_block", this, shaderProperties);
|
||||
this.gbuffersBlockTrans = readProgramSource(directory, sourceProvider, "gbuffers_block_translucent", this, shaderProperties);
|
||||
this.gbuffersHand = readProgramSource(directory, sourceProvider, "gbuffers_hand", this, shaderProperties);
|
||||
this.dhTerrain = readProgramSource(directory, sourceProvider, "dh_terrain", this, shaderProperties);
|
||||
this.dhGeneric = readProgramSource(directory, sourceProvider, "dh_generic", this, shaderProperties);
|
||||
this.dhWater = readProgramSource(directory, sourceProvider, "dh_water", this, shaderProperties);
|
||||
this.dhShadow = readProgramSource(directory, sourceProvider, "dh_shadow", this, shaderProperties);
|
||||
|
||||
this.deferred = readProgramArray(directory, sourceProvider, "deferred", shaderProperties);
|
||||
this.deferredCompute = new ComputeSource[deferred.length][];
|
||||
@@ -219,7 +226,7 @@ public class ProgramSet {
|
||||
gbuffersBasic, gbuffersBeaconBeam, gbuffersTextured, gbuffersTexturedLit, gbuffersTerrain,
|
||||
gbuffersDamagedBlock, gbuffersSkyBasic, gbuffersSkyTextured, gbuffersClouds, gbuffersWeather,
|
||||
gbuffersEntities, gbuffersEntitiesTrans, gbuffersEntitiesGlowing, gbuffersGlint, gbuffersEntityEyes, gbuffersBlock, gbuffersBlockTrans,
|
||||
gbuffersHand
|
||||
gbuffersHand, dhShadow, dhTerrain, dhGeneric, dhWater
|
||||
));
|
||||
|
||||
for (ComputeSource[] computeSources : compositeCompute) {
|
||||
@@ -387,33 +394,53 @@ public class ProgramSet {
|
||||
return gbuffersHand.requireValid();
|
||||
}
|
||||
|
||||
public Optional<ProgramSource> getDhTerrain() {
|
||||
return dhTerrain.requireValid();
|
||||
}
|
||||
|
||||
public Optional<ProgramSource> getDhGeneric() {
|
||||
return dhGeneric.requireValid();
|
||||
}
|
||||
|
||||
public Optional<ProgramSource> getDhWater() {
|
||||
return dhWater.requireValid();
|
||||
}
|
||||
|
||||
public Optional<ProgramSource> getDhShadow() {
|
||||
return dhShadow.requireValid();
|
||||
}
|
||||
|
||||
public Optional<ProgramSource> get(ProgramId programId) {
|
||||
return switch (programId) {
|
||||
case Shadow -> getShadow();
|
||||
case Basic -> getGbuffersBasic();
|
||||
case Line -> gbuffersLine.requireValid();
|
||||
case Textured -> getGbuffersTextured();
|
||||
case TexturedLit -> getGbuffersTexturedLit();
|
||||
case SkyBasic -> getGbuffersSkyBasic();
|
||||
case SkyTextured -> getGbuffersSkyTextured();
|
||||
case Clouds -> getGbuffersClouds();
|
||||
case Terrain -> getGbuffersTerrain();
|
||||
case DamagedBlock -> getGbuffersDamagedBlock();
|
||||
case Block -> getGbuffersBlock();
|
||||
return switch (programId) {
|
||||
case Shadow -> getShadow();
|
||||
case Basic -> getGbuffersBasic();
|
||||
case Line -> gbuffersLine.requireValid();
|
||||
case Textured -> getGbuffersTextured();
|
||||
case TexturedLit -> getGbuffersTexturedLit();
|
||||
case SkyBasic -> getGbuffersSkyBasic();
|
||||
case SkyTextured -> getGbuffersSkyTextured();
|
||||
case Clouds -> getGbuffersClouds();
|
||||
case Terrain -> getGbuffersTerrain();
|
||||
case DamagedBlock -> getGbuffersDamagedBlock();
|
||||
case Block -> getGbuffersBlock();
|
||||
case BlockTrans -> getGbuffersBlockTrans();
|
||||
case BeaconBeam -> getGbuffersBeaconBeam();
|
||||
case Entities -> getGbuffersEntities();
|
||||
case EntitiesTrans -> getGbuffersEntitiesTrans();
|
||||
case EntitiesGlowing -> getGbuffersEntitiesGlowing();
|
||||
case ArmorGlint -> getGbuffersGlint();
|
||||
case SpiderEyes -> getGbuffersEntityEyes();
|
||||
case Hand -> getGbuffersHand();
|
||||
case Weather -> getGbuffersWeather();
|
||||
case Water -> getGbuffersWater();
|
||||
case HandWater -> getGbuffersHandWater();
|
||||
case Final -> getCompositeFinal();
|
||||
default -> Optional.empty();
|
||||
};
|
||||
case BeaconBeam -> getGbuffersBeaconBeam();
|
||||
case Entities -> getGbuffersEntities();
|
||||
case EntitiesTrans -> getGbuffersEntitiesTrans();
|
||||
case EntitiesGlowing -> getGbuffersEntitiesGlowing();
|
||||
case ArmorGlint -> getGbuffersGlint();
|
||||
case SpiderEyes -> getGbuffersEntityEyes();
|
||||
case Hand -> getGbuffersHand();
|
||||
case Weather -> getGbuffersWeather();
|
||||
case Water -> getGbuffersWater();
|
||||
case HandWater -> getGbuffersHandWater();
|
||||
case Final -> getCompositeFinal();
|
||||
case DhTerrain -> getDhTerrain();
|
||||
case DhGeneric -> getDhGeneric();
|
||||
case DhWater -> getDhWater();
|
||||
case DhShadow -> getDhShadow();
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
public ProgramSource[] getDeferred() {
|
||||
|
||||
@@ -495,15 +495,15 @@ public class ShaderProperties {
|
||||
customUniforms.addVariable(parts[0], parts[1], value, false);
|
||||
});
|
||||
|
||||
handlePassDirective("uniform.", key, value, pass -> {
|
||||
String[] parts = pass.split("\\.");
|
||||
if (parts.length != 2) {
|
||||
Iris.logger.warn("Custom uniforms sould take the form of `uniform.<type>.<name> = <expression>. Ignoring " + key);
|
||||
return;
|
||||
}
|
||||
handlePassDirective("uniform.", key, value, pass -> {
|
||||
String[] parts = pass.split("\\.");
|
||||
if (parts.length != 2) {
|
||||
Iris.logger.warn("Custom uniforms sould take the form of `uniform.<type>.<name> = <expression>. Ignoring " + key);
|
||||
return;
|
||||
}
|
||||
|
||||
customUniforms.addVariable(parts[0], parts[1], value, true);
|
||||
});
|
||||
customUniforms.addVariable(parts[0], parts[1], value, true);
|
||||
});
|
||||
|
||||
// TODO: Buffer size directives
|
||||
// TODO: Conditional program enabling directives
|
||||
|
||||
@@ -7,7 +7,8 @@ public enum ProgramGroup {
|
||||
Gbuffers("gbuffers"),
|
||||
Deferred("deferred"),
|
||||
Composite("composite"),
|
||||
Final("final")
|
||||
Final("final"),
|
||||
Dh("dh")
|
||||
;
|
||||
|
||||
private final String baseName;
|
||||
|
||||
@@ -47,6 +47,10 @@ public enum ProgramId {
|
||||
Weather(ProgramGroup.Gbuffers, "weather", TexturedLit),
|
||||
Water(ProgramGroup.Gbuffers, "water", Terrain),
|
||||
HandWater(ProgramGroup.Gbuffers, "hand_water", Hand),
|
||||
DhTerrain(ProgramGroup.Dh, "terrain"),
|
||||
DhWater(ProgramGroup.Dh, "water", DhTerrain),
|
||||
DhGeneric(ProgramGroup.Dh, "generic", DhTerrain),
|
||||
DhShadow(ProgramGroup.Dh, "shadow"),
|
||||
|
||||
Final(ProgramGroup.Final, ""),
|
||||
;
|
||||
|
||||
Reference in new issue
Block a user