Backports tessellation shader support, safe zone shadow culling, and shader pack rendering directives.

This commit is contained in:
Jason Mitchell authored and Jason Mitchell committed 2026-01-30 18:10:27 -08:00
1 parent c5988d29c3
commit 969d2c3710
29 files changed
+418 -121

No files matched your search

@@ -15,6 +15,10 @@ public enum FeatureFlags {
BLOCK_EMISSION_ATTRIBUTE(() -> true, () -> true),
CUSTOM_IMAGES(() -> true, RenderSystem::supportsImageLoadStore),
SSBO(() -> true, RenderSystem::supportsSSBO),
HIGHER_SHADOWCOLOR(() -> true, () -> true),
TESSELLATION_SHADERS(() -> true, RenderSystem::supportsTesselation),
REVERSED_CULLING(() -> true, () -> true),
CAN_DISABLE_WEATHER(() -> true, () -> true),
UNKNOWN(() -> false, () -> false);
private final BooleanSupplier irisRequirement;
@@ -55,16 +59,16 @@ public enum FeatureFlags {
}
public static boolean isInvalid(String name) {
try {
return !FeatureFlags.valueOf(name).isUsable();
} catch (IllegalArgumentException e) {
return true;
}
FeatureFlags flag = getValue(name);
return flag == UNKNOWN || !flag.isUsable();
}
public static FeatureFlags getValue(String value) {
if (value.equalsIgnoreCase("TESSELATION_SHADERS")) {
value = "TESSELLATION_SHADERS";
}
try {
return FeatureFlags.valueOf(value);
return FeatureFlags.valueOf(value.toUpperCase(java.util.Locale.US));
} catch (IllegalArgumentException e) {
return FeatureFlags.UNKNOWN;
}
@@ -34,36 +34,31 @@ public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHo
public static ProgramBuilder begin(String name, @Nullable String vertexSource, @Nullable String geometrySource,
@Nullable String fragmentSource, ImmutableSet<Integer> reservedTextureUnits) {
GlShader vertex;
GlShader geometry;
GlShader fragment;
return begin(name, vertexSource, geometrySource, null, null, fragmentSource, reservedTextureUnits);
}
vertex = buildShader(ShaderType.VERTEX, name + ".vsh", vertexSource);
public static ProgramBuilder begin(String name, @Nullable String vertexSource, @Nullable String geometrySource,
@Nullable String tessControlSource, @Nullable String tessEvalSource,
@Nullable String fragmentSource, ImmutableSet<Integer> reservedTextureUnits) {
GlShader vertex = buildShader(ShaderType.VERTEX, name + ".vsh", vertexSource);
GlShader geometry = geometrySource != null ? buildShader(ShaderType.GEOMETRY, name + ".gsh", geometrySource) : null;
GlShader tessControl = tessControlSource != null ? buildShader(ShaderType.TESSELATION_CONTROL, name + ".tcs", tessControlSource) : null;
GlShader tessEval = tessEvalSource != null ? buildShader(ShaderType.TESSELATION_EVAL, name + ".tes", tessEvalSource) : null;
GlShader fragment = buildShader(ShaderType.FRAGMENT, name + ".fsh", fragmentSource);
if (geometrySource != null) {
geometry = buildShader(ShaderType.GEOMETRY, name + ".gsh", geometrySource);
} else {
geometry = null;
java.util.List<GlShader> shaders = new java.util.ArrayList<>();
shaders.add(vertex);
if (geometry != null) shaders.add(geometry);
if (tessControl != null) shaders.add(tessControl);
if (tessEval != null) shaders.add(tessEval);
shaders.add(fragment);
int programId = ProgramCreator.create(name, shaders.toArray(new GlShader[0]));
for (GlShader shader : shaders) {
shader.destroy();
}
fragment = buildShader(ShaderType.FRAGMENT, name + ".fsh", fragmentSource);
int programId;
if (geometry != null) {
programId = ProgramCreator.create(name, vertex, geometry, fragment);
} else {
programId = ProgramCreator.create(name, vertex, fragment);
}
vertex.destroy();
if (geometry != null) {
geometry.destroy();
}
fragment.destroy();
return new ProgramBuilder(name, programId, reservedTextureUnits);
}
@@ -4,6 +4,7 @@ package net.coderbot.iris.gl.shader;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL32;
import org.lwjgl.opengl.GL40;
import org.lwjgl.opengl.GL43;
/**
@@ -12,6 +13,8 @@ import org.lwjgl.opengl.GL43;
public enum ShaderType {
VERTEX(GL20.GL_VERTEX_SHADER),
GEOMETRY(GL32.GL_GEOMETRY_SHADER),
TESSELATION_CONTROL(GL40.GL_TESS_CONTROL_SHADER),
TESSELATION_EVAL(GL40.GL_TESS_EVALUATION_SHADER),
FRAGMENT(GL20.GL_FRAGMENT_SHADER),
COMPUTE(GL43.GL_COMPUTE_SHADER);
@@ -86,7 +86,7 @@ public class ClearPassCreator {
// Sort buffers by their clear color so we can group up glClear calls.
Map<Vector4f, IntList> clearByColor = new HashMap<>();
for (int i = 0; i < renderTargetDirectives.getColorSamplingSettings().size(); i++) {
for (int i = 0; i < Math.min(renderTargetDirectives.getColorSamplingSettings().size(), renderTargets.getNumColorTextures()); i++) {
// unboxed
PackShadowDirectives.SamplingSettings settings = renderTargetDirectives.getColorSamplingSettings().get(i);
@@ -165,6 +165,10 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private final boolean shouldRenderVignette;
private final boolean shouldRenderSun;
private final boolean shouldRenderMoon;
private final boolean shouldRenderStars;
private final boolean shouldRenderSkyDisc;
private final boolean shouldRenderWeather;
private final boolean shouldRenderWeatherParticles;
private final boolean shouldWriteRainAndSnowToDepthBuffer;
private final boolean shouldRenderParticlesBeforeDeferred;
private final boolean shouldRenderPrepareBeforeShadow;
@@ -217,6 +221,10 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
this.shouldRenderVignette = programs.getPackDirectives().vignette();
this.shouldRenderSun = programs.getPackDirectives().shouldRenderSun();
this.shouldRenderMoon = programs.getPackDirectives().shouldRenderMoon();
this.shouldRenderStars = programs.getPackDirectives().shouldRenderStars();
this.shouldRenderSkyDisc = programs.getPackDirectives().shouldRenderSkyDisc();
this.shouldRenderWeather = programs.getPackDirectives().shouldRenderWeather();
this.shouldRenderWeatherParticles = programs.getPackDirectives().shouldRenderWeatherParticles();
this.shouldWriteRainAndSnowToDepthBuffer = programs.getPackDirectives().rainDepth();
this.shouldRenderParticlesBeforeDeferred = programs.getPackDirectives().getParticleRenderingSettings()
.map(s -> s == net.coderbot.iris.shaderpack.ParticleRenderingSettings.BEFORE || s == net.coderbot.iris.shaderpack.ParticleRenderingSettings.MIXED)
@@ -323,7 +331,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
this.shadowTargetsSupplier = () -> {
if (shadowRenderTargets == null) {
this.shadowRenderTargets = new ShadowRenderTargets(shadowMapResolution, shadowDirectives);
this.shadowRenderTargets = new ShadowRenderTargets(this, shadowMapResolution, shadowDirectives);
}
return shadowRenderTargets;
@@ -440,7 +448,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
});
});
if (shadowRenderTargets == null && shadowDirectives.isShadowEnabled() == OptionalBoolean.TRUE) {
shadowRenderTargets = new ShadowRenderTargets(shadowMapResolution, shadowDirectives);
shadowRenderTargets = new ShadowRenderTargets(this, shadowMapResolution, shadowDirectives);
}
if (shadowRenderTargets != null) {
@@ -631,6 +639,26 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
return shouldRenderMoon;
}
@Override
public boolean shouldRenderStars() {
return shouldRenderStars;
}
@Override
public boolean shouldRenderSkyDisc() {
return shouldRenderSkyDisc;
}
@Override
public boolean shouldRenderWeather() {
return shouldRenderWeather;
}
@Override
public boolean shouldRenderWeatherParticles() {
return shouldRenderWeatherParticles;
}
@Override
public boolean shouldWriteRainAndSnowToDepthBuffer() {
return shouldWriteRainAndSnowToDepthBuffer;
@@ -759,17 +787,21 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
transformed = TransformPatcher.patchAttributes(
source.getVertexSource().orElseThrow(NullPointerException::new),
source.getGeometrySource().orElse(null),
source.getTessControlSource().orElse(null),
source.getTessEvalSource().orElse(null),
source.getFragmentSource().orElseThrow(NullPointerException::new),
availability);
}
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);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, tessControl, tessEval, fragment);
ProgramBuilder builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment,
ProgramBuilder builder = ProgramBuilder.begin(source.getName(), vertex, geometry, tessControl, tessEval, fragment,
IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
return createPassInner(builder, source.getDirectives(), availability, shadow, id);
@@ -1559,7 +1591,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private static final InputAvailability[] INPUT_AVAILABILITIES = { INPUT_NONE, INPUT_TEXTURE, INPUT_TEXTURE_LIGHTMAP };
private static CompletableFuture<Map<PatchShaderType, String>> submitCompositeTransform(ProgramSource source) {
return Iris.ShaderTransformExecutor.submitTracked(() -> TransformPatcher.patchComposite(source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getFragmentSource().orElse(null)));
return Iris.ShaderTransformExecutor.submitTracked(() -> TransformPatcher.patchComposite(source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getTessControlSource().orElse(null), source.getTessEvalSource().orElse(null), source.getFragmentSource().orElse(null)));
}
private static Map<Integer, CompletableFuture<Map<PatchShaderType, String>>> submitCompositeTransforms(ProgramSource[] sources) {
@@ -1587,7 +1619,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
processedSourceNames.add(source.getName());
for (InputAvailability avail : INPUT_AVAILABILITIES) {
Pair<String, InputAvailability> key = Pair.of(source.getName(), avail);
futures.put(key, Iris.ShaderTransformExecutor.submitTracked(() -> TransformPatcher.patchAttributes(source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getFragmentSource().orElse(null), avail)));
futures.put(key, Iris.ShaderTransformExecutor.submitTracked(() -> TransformPatcher.patchAttributes(source.getVertexSource().orElse(null), source.getGeometrySource().orElse(null), source.getTessControlSource().orElse(null), source.getTessEvalSource().orElse(null), source.getFragmentSource().orElse(null), avail)));
}
}
}
@@ -172,6 +172,26 @@ public class FixedFunctionWorldRenderingPipeline implements WorldRenderingPipeli
return true;
}
@Override
public boolean shouldRenderStars() {
return true;
}
@Override
public boolean shouldRenderSkyDisc() {
return true;
}
@Override
public boolean shouldRenderWeather() {
return true;
}
@Override
public boolean shouldRenderWeatherParticles() {
return true;
}
@Override
public boolean shouldWriteRainAndSnowToDepthBuffer() {
return false;
@@ -27,10 +27,18 @@ public class PatchedShaderPrinter {
}
public static void debugPatchedShaders(String name, String vertex, String geometry, String fragment) {
debugPatchedShaders(name, vertex, geometry, fragment, null);
debugPatchedShaders(name, vertex, geometry, null, null, fragment, null);
}
public static void debugPatchedShaders(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment) {
debugPatchedShaders(name, vertex, geometry, tessControl, tessEval, fragment, null);
}
public static void debugPatchedShaders(String name, String vertex, String geometry, String fragment, String compute) {
debugPatchedShaders(name, vertex, geometry, null, null, fragment, compute);
}
public static void debugPatchedShaders(String name, String vertex, String geometry, String tessControl, String tessEval, String fragment, String compute) {
if (prettyPrintShaders) {
final Path debugOutDir = Minecraft.getMinecraft().mcDataDir.toPath().resolve("patched_shaders");
if (!outputLocationCleared) {
@@ -63,6 +71,12 @@ public class PatchedShaderPrinter {
if (geometry != null) {
Files.write(debugOutDir.resolve(prefix + name + ".gsh"), geometry.getBytes(StandardCharsets.UTF_8));
}
if (tessControl != null) {
Files.write(debugOutDir.resolve(prefix + name + ".tcs"), tessControl.getBytes(StandardCharsets.UTF_8));
}
if (tessEval != null) {
Files.write(debugOutDir.resolve(prefix + name + ".tes"), tessEval.getBytes(StandardCharsets.UTF_8));
}
if (fragment != null) {
Files.write(debugOutDir.resolve(prefix + name + ".fsh"), fragment.getBytes(StandardCharsets.UTF_8));
}
@@ -29,6 +29,7 @@ import net.coderbot.iris.shadows.frustum.BoxCuller;
import net.coderbot.iris.shadows.frustum.CullEverythingFrustum;
import net.coderbot.iris.shadows.frustum.FrustumHolder;
import net.coderbot.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum;
import net.coderbot.iris.shadows.frustum.advanced.SafeZoneCullingFrustum;
import net.coderbot.iris.shadows.frustum.fallback.BoxCullingFrustum;
import net.coderbot.iris.shadows.frustum.fallback.NonCullingFrustum;
import net.coderbot.iris.uniforms.CameraUniforms;
@@ -73,6 +74,7 @@ public class ShadowRenderer {
public static ShadowRenderTargets CURRENT_TARGETS = null;
private final float halfPlaneLength;
private final float voxelDistance;
private final float renderDistanceMultiplier;
private final float entityShadowDistanceMultiplier;
private final int resolution;
@@ -117,6 +119,7 @@ public class ShadowRenderer {
final PackShadowDirectives shadowDirectives = directives.getShadowDirectives();
this.halfPlaneLength = shadowDirectives.getDistance();
this.voxelDistance = shadowDirectives.getVoxelDistance();
this.renderDistanceMultiplier = shadowDirectives.getDistanceRenderMul();
this.entityShadowDistanceMultiplier = shadowDirectives.getEntityShadowDistanceMul();
this.resolution = shadowDirectives.getResolution();
@@ -225,7 +228,8 @@ public class ShadowRenderer {
configureDepthSampler(targets.getDepthTextureNoTranslucents().getTextureId(), depthSamplingSettings.get(1));
for (int i = 0; i < colorSamplingSettings.size(); i++) {
for (int i = 0; i < Math.min(colorSamplingSettings.size(), targets.getNumColorTextures()); i++) {
if (targets.get(i) == null) continue;
int glTextureId = targets.get(i).getMainTexture();
configureSampler(glTextureId, colorSamplingSettings.get(i));
@@ -286,7 +290,7 @@ public class ShadowRenderer {
// TODO: Cull entities / block entities with Advanced Frustum Culling even if voxelization is detected.
String distanceInfo;
String cullingInfo;
if ((packCullingState == ShadowCullState.DISTANCE || packHasVoxelization) && packCullingState != ShadowCullState.ADVANCED) {
if ((packCullingState == ShadowCullState.DISTANCE || packHasVoxelization) && packCullingState != ShadowCullState.ADVANCED && packCullingState != ShadowCullState.SAFE_ZONE) {
double distance = halfPlaneLength * renderMultiplier;
String reason;
@@ -308,26 +312,29 @@ public class ShadowRenderer {
holder.setInfo(getOrCreateBoxCullingFrustum(distance), distanceInfo, cullingInfo);
}
} else {
final BoxCuller boxCuller;
BoxCuller boxCuller;
double distance = halfPlaneLength * renderMultiplier;
boolean hasSafeZone = packCullingState == ShadowCullState.SAFE_ZONE;
if (hasSafeZone && renderMultiplier < 0) renderMultiplier = 1.0f;
double distance = (hasSafeZone ? voxelDistance : halfPlaneLength) * renderMultiplier;
String setter = "(set by shader pack)";
if (renderMultiplier < 0) {
// TODO: GUI
distance = IrisVideoSettings.shadowDistance * 16; // can be zero :(
//distance = 32 * 16;
setter = "(set by user)";
}
if (distance >= Minecraft.getMinecraft().gameSettings.renderDistanceChunks * 16) {
if (distance >= Minecraft.getMinecraft().gameSettings.renderDistanceChunks * 16 && !hasSafeZone) {
distanceInfo = Minecraft.getMinecraft().gameSettings.renderDistanceChunks * 16
+ " blocks (capped by normal render distance)";
boxCuller = null;
} else {
distanceInfo = distance + " blocks " + setter;
if (distance == 0.0) {
if (distance == 0.0 && !hasSafeZone) {
cullingInfo = "no shadows rendered";
return holder.setInfo(CULL_EVERYTHING_FRUSTUM, distanceInfo, cullingInfo);
}
@@ -335,15 +342,22 @@ public class ShadowRenderer {
boxCuller = getOrCreateAdvancedBoxCuller(distance);
}
cullingInfo = "Advanced Frustum Culling enabled";
cullingInfo = (hasSafeZone ? "Safe Zone" : "Advanced") + " Frustum Culling enabled";
final Vector4f shadowLightPosition = celestialUniforms.getShadowLightPositionInWorldSpace();
shadowLightVectorCache.set(shadowLightPosition.x(), shadowLightPosition.y(), shadowLightPosition.z());
shadowLightVectorCache.normalize();
cachedAdvancedFrustum.init(RenderingState.INSTANCE.getModelViewMatrix(), RenderingState.INSTANCE.getProjectionMatrix(), shadowLightVectorCache, boxCuller);
return holder.setInfo(cachedAdvancedFrustum, distanceInfo, cullingInfo);
if (hasSafeZone) {
BoxCuller distanceCuller = new BoxCuller(halfPlaneLength * renderMultiplier);
SafeZoneCullingFrustum safeZoneFrustum = new SafeZoneCullingFrustum(
RenderingState.INSTANCE.getModelViewMatrix(), RenderingState.INSTANCE.getProjectionMatrix(),
shadowLightVectorCache, boxCuller, distanceCuller);
return holder.setInfo(safeZoneFrustum, distanceInfo, cullingInfo);
} else {
cachedAdvancedFrustum.init(RenderingState.INSTANCE.getModelViewMatrix(), RenderingState.INSTANCE.getProjectionMatrix(), shadowLightVectorCache, boxCuller);
return holder.setInfo(cachedAdvancedFrustum, distanceInfo, cullingInfo);
}
}
return holder;
@@ -54,6 +54,10 @@ public interface WorldRenderingPipeline {
boolean shouldRenderVignette();
boolean shouldRenderSun();
boolean shouldRenderMoon();
boolean shouldRenderStars();
boolean shouldRenderSkyDisc();
boolean shouldRenderWeather();
boolean shouldRenderWeatherParticles();
boolean shouldWriteRainAndSnowToDepthBuffer();
boolean shouldRenderParticlesBeforeDeferred();
boolean allowConcurrentCompute();
@@ -5,6 +5,8 @@ import net.coderbot.iris.gl.shader.ShaderType;
public enum PatchShaderType {
VERTEX(ShaderType.VERTEX),
GEOMETRY(ShaderType.GEOMETRY),
TESS_CONTROL(ShaderType.TESSELATION_CONTROL),
TESS_EVAL(ShaderType.TESSELATION_EVAL),
FRAGMENT(ShaderType.FRAGMENT),
COMPUTE(ShaderType.COMPUTE);
@@ -20,6 +22,8 @@ public enum PatchShaderType {
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 FRAGMENT -> new PatchShaderType[] { FRAGMENT };
case COMPUTE -> new PatchShaderType[] { COMPUTE };
};
@@ -160,8 +160,8 @@ public class ShaderTransformer {
}
}
public static <P extends Parameters> Map<PatchShaderType, String> transform(String vertex, String geometry, String fragment, P parameters) {
if (vertex == null && geometry == null && fragment == null) {
public static <P extends Parameters> Map<PatchShaderType, String> transform(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;
@@ -171,6 +171,8 @@ public class ShaderTransformer {
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);
var key = new TransformKey<>(patchType, inputs, parameters);
@@ -30,12 +30,16 @@ public class TransformPatcher {
final Parameters parameters;
final String vertex;
final String geometry;
final String tessControl;
final String tessEval;
final String fragment;
public CacheKey(Parameters parameters, String vertex, String geometry, String fragment) {
public CacheKey(Parameters parameters, String vertex, String geometry, String tessControl, String tessEval, String fragment) {
this.parameters = parameters;
this.vertex = vertex;
this.geometry = geometry;
this.tessControl = tessControl;
this.tessEval = tessEval;
this.fragment = fragment;
}
@@ -45,6 +49,8 @@ public class TransformPatcher {
int result = 1;
result = prime * result + ((fragment == null) ? 0 : fragment.hashCode());
result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
result = prime * result + ((tessControl == null) ? 0 : tessControl.hashCode());
result = prime * result + ((tessEval == null) ? 0 : tessEval.hashCode());
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
result = prime * result + ((vertex == null) ? 0 : vertex.hashCode());
return result;
@@ -52,39 +58,20 @@ public class TransformPatcher {
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
final TransformPatcher.CacheKey other = (TransformPatcher.CacheKey) obj;
if (fragment == null) {
if (other.fragment != null)
return false;
} else if (!fragment.equals(other.fragment))
return false;
if (geometry == null) {
if (other.geometry != null)
return false;
} else if (!geometry.equals(other.geometry))
return false;
if (parameters == null) {
if (other.parameters != null)
return false;
} else if (!parameters.equals(other.parameters))
return false;
if (vertex == null) {
if (other.vertex != null)
return false;
} else if (!vertex.equals(other.vertex))
return false;
return true;
return java.util.Objects.equals(fragment, other.fragment)
&& java.util.Objects.equals(geometry, other.geometry)
&& java.util.Objects.equals(tessControl, other.tessControl)
&& java.util.Objects.equals(tessEval, other.tessEval)
&& java.util.Objects.equals(parameters, other.parameters)
&& java.util.Objects.equals(vertex, other.vertex);
}
}
private static Map<PatchShaderType, String> transform(String vertex, String geometry, String fragment, Parameters parameters) {
if (vertex == null && geometry == null && fragment == null) {
private static Map<PatchShaderType, String> transform(String vertex, String geometry, String tessControl, String tessEval, String fragment, Parameters parameters) {
if (vertex == null && geometry == null && tessControl == null && tessEval == null && fragment == null) {
return null;
}
@@ -92,7 +79,7 @@ public class TransformPatcher {
TransformPatcher.CacheKey key = null;
Map<PatchShaderType, String> result = null;
if (useCache) {
key = new TransformPatcher.CacheKey(parameters, vertex, geometry, fragment);
key = new TransformPatcher.CacheKey(parameters, vertex, geometry, tessControl, tessEval, fragment);
synchronized (cache) {
result = cache.get(key);
}
@@ -100,7 +87,7 @@ public class TransformPatcher {
// if there is no cache result, transform the shaders
if (result == null) {
result = ShaderTransformer.transform(vertex, geometry, fragment, parameters);
result = ShaderTransformer.transform(vertex, geometry, tessControl, tessEval, fragment, parameters);
if (useCache) {
synchronized (cache) {
// Double-check in case another thread added it while we were transforming
@@ -116,20 +103,32 @@ public class TransformPatcher {
return result;
}
public static Map<PatchShaderType, String> patchAttributes(String vertex, String geometry, String tessControl, String tessEval, String fragment, InputAvailability inputs) {
return transform(vertex, geometry, tessControl, tessEval, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, inputs));
}
public static Map<PatchShaderType, String> patchAttributes(String vertex, String geometry, String fragment, InputAvailability inputs) {
return transform(vertex, geometry, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, inputs));
return patchAttributes(vertex, geometry, null, null, fragment, inputs);
}
public static Map<PatchShaderType, String> patchCeleritasTerrain(String vertex, String geometry, String fragment) {
return transform(vertex, geometry, fragment, new CeleritasTerrainParameters(Patch.CELERITAS_TERRAIN));
return transform(vertex, geometry, null, null, fragment, new CeleritasTerrainParameters(Patch.CELERITAS_TERRAIN));
}
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String fragment) {
return patchComposite(vertex, geometry, fragment, TextureStage.COMPOSITE_AND_FINAL, null);
return patchComposite(vertex, geometry, null, null, fragment, TextureStage.COMPOSITE_AND_FINAL, null);
}
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String tessControl, String tessEval, String fragment) {
return patchComposite(vertex, geometry, tessControl, tessEval, fragment, TextureStage.COMPOSITE_AND_FINAL, null);
}
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String tessControl, String tessEval, String fragment, TextureStage stage, Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transform(vertex, geometry, tessControl, tessEval, fragment, new TextureStageParameters(Patch.COMPOSITE, stage, textureMap));
}
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String fragment, TextureStage stage, Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
return transform(vertex, geometry, fragment, new TextureStageParameters(Patch.COMPOSITE, stage, textureMap));
return patchComposite(vertex, geometry, null, null, fragment, stage, textureMap);
}
public static String patchCompute(String name, String compute, TextureStage stage, Object2ObjectMap<Tri<String, TextureType, TextureStage>, String> textureMap) {
@@ -189,7 +189,7 @@ public class CompositeRenderer {
}
// Fallback: transform synchronously
return TransformPatcher.patchComposite(source.getVertexSource().orElseThrow(NullPointerException::new), source.getGeometrySource().orElse(null), source.getFragmentSource().orElseThrow(NullPointerException::new), this.textureStage, pipeline != null ? pipeline.getTextureMap() : null);
return TransformPatcher.patchComposite(source.getVertexSource().orElseThrow(NullPointerException::new), source.getGeometrySource().orElse(null), source.getTessControlSource().orElse(null), source.getTessEvalSource().orElse(null), source.getFragmentSource().orElseThrow(NullPointerException::new), this.textureStage, pipeline != null ? pipeline.getTextureMap() : null);
}
public void recalculateSizes() {
@@ -345,14 +345,16 @@ public class CompositeRenderer {
Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
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);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, tessControl, tessEval, fragment);
Objects.requireNonNull(flipped);
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment,
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, tessControl, tessEval, fragment,
IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
@@ -159,7 +159,7 @@ public class FinalPassRenderer {
throw new RuntimeException("Shader transformation failed for '" + source.getName() + "' in stage '" + stageName + "'", e.getCause() != null ? e.getCause() : e);
}
}
return TransformPatcher.patchComposite(source.getVertexSource().orElseThrow(NullPointerException::new), source.getGeometrySource().orElse(null), source.getFragmentSource().orElseThrow(NullPointerException::new));
return TransformPatcher.patchComposite(source.getVertexSource().orElseThrow(NullPointerException::new), source.getGeometrySource().orElse(null), source.getTessControlSource().orElse(null), source.getTessEvalSource().orElse(null), source.getFragmentSource().orElseThrow(NullPointerException::new));
}
private static final class Pass {
@@ -353,14 +353,16 @@ public class FinalPassRenderer {
Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
final String vertex = transformed.get(PatchShaderType.VERTEX);
final String geometry = transformed.get(PatchShaderType.GEOMETRY);
final String tessControl = transformed.get(PatchShaderType.TESS_CONTROL);
final String tessEval = transformed.get(PatchShaderType.TESS_EVAL);
final String fragment = transformed.get(PatchShaderType.FRAGMENT);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, tessControl, tessEval, fragment);
Objects.requireNonNull(flipped);
final ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment,
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, tessControl, tessEval, fragment,
IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
@@ -106,7 +106,7 @@ public class IrisSamplers {
final ImmutableList.Builder<String> shadowSamplers = ImmutableList.<String>builder()
.add("shadowtex0", "shadowtex0HW", "shadowtex0DH", "shadowtex1", "shadowtex1HW", "shadowtex1DH", "shadow", "watershadow", "shadowcolor");
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS; i++) {
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) {
shadowSamplers.add("shadowcolor" + i);
shadowSamplers.add("shadowcolorimg" + i);
}
@@ -33,6 +33,10 @@ public class PackDirectives {
private boolean vignette;
private boolean sun;
private boolean moon;
private boolean stars;
private boolean sky;
private boolean weather;
private boolean weatherParticles;
private boolean rainDepth;
private boolean separateAo;
private boolean voxelizeLightBlocks;
@@ -76,6 +80,10 @@ public class PackDirectives {
vignette = properties.getVignette().orElse(false);
sun = properties.getSun().orElse(true);
moon = properties.getMoon().orElse(true);
stars = properties.getStars().orElse(true);
sky = properties.getSky().orElse(true);
weather = properties.getWeather().orElse(true);
weatherParticles = properties.getWeatherParticles().orElse(true);
rainDepth = properties.getRainDepth().orElse(false);
separateAo = properties.getSeparateAo().orElse(false);
voxelizeLightBlocks = properties.getVoxelizeLightBlocks().orElse(false);
@@ -129,6 +137,22 @@ public class PackDirectives {
return moon;
}
public boolean shouldRenderStars() {
return stars;
}
public boolean shouldRenderSkyDisc() {
return sky;
}
public boolean shouldRenderWeather() {
return weather;
}
public boolean shouldRenderWeatherParticles() {
return weatherParticles;
}
public boolean rainDepth() {
return rainDepth;
}
@@ -9,10 +9,8 @@ import org.joml.Vector4f;
import java.util.Optional;
public class PackShadowDirectives {
// Bump this up if you want more shadow color buffers!
// This is currently set at 2 for ShadersMod / OptiFine parity but can theoretically be bumped up to 8.
// TODO: Make this configurable?
public static final int MAX_SHADOW_COLOR_BUFFERS = 2;
public static final int MAX_SHADOW_COLOR_BUFFERS_IRIS = 8;
public static final int MAX_SHADOW_COLOR_BUFFERS_OF = 2;
private final OptionalBoolean shadowEnabled;
@@ -20,6 +18,7 @@ public class PackShadowDirectives {
// Use a boxed form so we can use null to indicate that there is not an FOV specified.
private Float fov;
private float distance;
private float voxelDistance;
private float distanceRenderMul;
private float entityShadowDistanceMul;
private boolean explicitRenderDistance;
@@ -54,6 +53,7 @@ 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.voxelDistance = 0.0f;
// By default, shadows are not culled based on distance from the player. However, pack authors may
// enable this by setting shadowRenderDistanceMul to a nonzero value.
@@ -86,7 +86,7 @@ public class PackShadowDirectives {
ImmutableList.Builder<SamplingSettings> colorSamplingSettings = ImmutableList.builder();
for (int i = 0; i < MAX_SHADOW_COLOR_BUFFERS; i++) {
for (int i = 0; i < MAX_SHADOW_COLOR_BUFFERS_IRIS; i++) {
colorSamplingSettings.add(new SamplingSettings());
}
@@ -97,6 +97,7 @@ public class PackShadowDirectives {
this.resolution = shadowDirectives.resolution;
this.fov = shadowDirectives.fov;
this.distance = shadowDirectives.distance;
this.voxelDistance = shadowDirectives.voxelDistance;
this.distanceRenderMul = shadowDirectives.distanceRenderMul;
this.entityShadowDistanceMul = shadowDirectives.entityShadowDistanceMul;
this.explicitRenderDistance = shadowDirectives.explicitRenderDistance;
@@ -124,6 +125,10 @@ public class PackShadowDirectives {
return distance;
}
public float getVoxelDistance() {
return voxelDistance;
}
public float getDistanceRenderMul() {
return distanceRenderMul;
}
@@ -192,6 +197,8 @@ public class PackShadowDirectives {
directives.acceptConstFloatDirective("shadowIntervalSize",
intervalSize -> this.intervalSize = intervalSize);
directives.acceptConstFloatDirective("voxelDistance", distance -> this.voxelDistance = distance);
acceptHardwareFilteringSettings(directives, depthSamplingSettings);
acceptDepthMipmapSettings(directives, depthSamplingSettings);
acceptColorMipmapSettings(directives, colorSamplingSettings);
@@ -477,11 +477,21 @@ public class ProgramSet {
AbsolutePackPath geometryPath = directory.resolve(program + ".gsh");
String geometrySource = sourceProvider.apply(geometryPath);
String tessControlSource = null;
String tessEvalSource = null;
if (programSet.pack.hasFeature(net.coderbot.iris.features.FeatureFlags.TESSELLATION_SHADERS)) {
AbsolutePackPath tessControlPath = directory.resolve(program + ".tcs");
tessControlSource = sourceProvider.apply(tessControlPath);
AbsolutePackPath tessEvalPath = directory.resolve(program + ".tes");
tessEvalSource = sourceProvider.apply(tessEvalPath);
}
AbsolutePackPath fragmentPath = directory.resolve(program + ".fsh");
String fragmentSource = sourceProvider.apply(fragmentPath);
return new ProgramSource(program, vertexSource, geometrySource, fragmentSource, programSet, properties,
defaultBlendModeOverride);
return new ProgramSource(program, vertexSource, geometrySource, tessControlSource, tessEvalSource,
fragmentSource, programSet, properties, defaultBlendModeOverride);
}
private static ComputeSource readComputeSource(AbsolutePackPath directory,
@@ -8,25 +8,33 @@ public class ProgramSource {
private final String name;
private final String vertexSource;
private final String geometrySource;
private final String tessControlSource;
private final String tessEvalSource;
private final String fragmentSource;
private final ProgramDirectives directives;
private final ProgramSet parent;
private ProgramSource(String name, String vertexSource, String geometrySource, String fragmentSource,
private ProgramSource(String name, String vertexSource, String geometrySource, String tessControlSource,
String tessEvalSource, String fragmentSource,
ProgramDirectives directives, ProgramSet parent) {
this.name = name;
this.vertexSource = vertexSource;
this.geometrySource = geometrySource;
this.tessControlSource = tessControlSource;
this.tessEvalSource = tessEvalSource;
this.fragmentSource = fragmentSource;
this.directives = directives;
this.parent = parent;
}
public ProgramSource(String name, String vertexSource, String geometrySource, String fragmentSource,
public ProgramSource(String name, String vertexSource, String geometrySource, String tessControlSource,
String tessEvalSource, String fragmentSource,
ProgramSet parent, ShaderProperties properties, BlendModeOverride defaultBlendModeOverride) {
this.name = name;
this.vertexSource = vertexSource;
this.geometrySource = geometrySource;
this.tessControlSource = tessControlSource;
this.tessEvalSource = tessEvalSource;
this.fragmentSource = fragmentSource;
this.parent = parent;
this.directives = new ProgramDirectives(this, properties,
@@ -34,7 +42,7 @@ public class ProgramSource {
}
public ProgramSource withDirectiveOverride(ProgramDirectives overrideDirectives) {
return new ProgramSource(name, vertexSource, geometrySource, fragmentSource, overrideDirectives, parent);
return new ProgramSource(name, vertexSource, geometrySource, tessControlSource, tessEvalSource, fragmentSource, overrideDirectives, parent);
}
public String getName() {
@@ -49,6 +57,14 @@ public class ProgramSource {
return Optional.ofNullable(geometrySource);
}
public Optional<String> getTessControlSource() {
return Optional.ofNullable(tessControlSource);
}
public Optional<String> getTessEvalSource() {
return Optional.ofNullable(tessEvalSource);
}
public Optional<String> getFragmentSource() {
return Optional.ofNullable(fragmentSource);
}
@@ -216,6 +216,9 @@ public class ShaderPack {
Iris.logger.info("FeatureFlag {} usable: {}", flag.name(), usable);
if (usable) {
finalEnvironmentDefines.add(new StringPair("IRIS_FEATURE_" + flag.name(), ""));
if (flag == FeatureFlags.TESSELLATION_SHADERS) {
finalEnvironmentDefines.add(new StringPair("IRIS_FEATURE_TESSELATION_SHADERS", ""));
}
}
}
Iris.logger.info("Environment defines: {}", finalEnvironmentDefines.stream()
@@ -73,6 +73,10 @@ public class ShaderProperties {
@Getter private OptionalBoolean underwaterOverlay = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean sun = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean moon = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean stars = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean sky = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean weather = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean weatherParticles = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean vignette = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean backFaceSolid = OptionalBoolean.DEFAULT;
@Getter private OptionalBoolean backFaceCutout = OptionalBoolean.DEFAULT;
@@ -184,8 +188,8 @@ public class ShaderProperties {
shadowCulling = ShadowCullState.DISTANCE;
} else if ("true".equals(value)) {
shadowCulling = ShadowCullState.ADVANCED;
} else if ("reversed".equals(value)) {
shadowCulling = ShadowCullState.REVERSED;
} else if ("reversed".equals(value) || "safe_zone".equals(value)) {
shadowCulling = ShadowCullState.SAFE_ZONE;
} else {
Iris.logger.error("Unrecognized shadow culling setting: " + value);
}
@@ -203,6 +207,8 @@ public class ShaderProperties {
handleBooleanDirective(key, value, "underwaterOverlay", bool -> underwaterOverlay = bool);
handleBooleanDirective(key, value, "sun", bool -> sun = bool);
handleBooleanDirective(key, value, "moon", bool -> moon = bool);
handleBooleanDirective(key, value, "stars", bool -> stars = bool);
handleBooleanDirective(key, value, "sky", bool -> sky = bool);
handleBooleanDirective(key, value, "vignette", bool -> vignette = bool);
handleBooleanDirective(key, value, "backFace.solid", bool -> backFaceSolid = bool);
handleBooleanDirective(key, value, "backFace.cutout", bool -> backFaceCutout = bool);
@@ -227,6 +233,14 @@ public class ShaderProperties {
handleBooleanDirective(key, value, "supportsColorCorrection", bool -> supportsColorCorrection = bool);
handleIntDirective(key, value, "fallbackTex", val -> fallbackTex = val);
if ("weather".equals(key)) {
String[] parts = value.split(" ");
weather = parts[0].equals("true") ? OptionalBoolean.TRUE : OptionalBoolean.FALSE;
if (parts.length > 1) {
weatherParticles = parts[1].equals("true") ? OptionalBoolean.TRUE : OptionalBoolean.FALSE;
}
}
if (key.startsWith("particles.ordering")) {
Optional<ParticleRenderingSettings> settings = ParticleRenderingSettings.fromString(value.trim().toUpperCase(Locale.ROOT));
if (settings.isPresent()) {
@@ -3,6 +3,6 @@ package net.coderbot.iris.shaderpack;
public enum ShadowCullState {
DEFAULT,
ADVANCED,
REVERSED,
SAFE_ZONE,
DISTANCE
}
@@ -261,17 +261,21 @@ public class ShadowCompositeRenderer {
Map<PatchShaderType, String> transformed = TransformPatcher.patchComposite(
source.getVertexSource().orElseThrow(NullPointerException::new),
source.getGeometrySource().orElse(null),
source.getTessControlSource().orElse(null),
source.getTessEvalSource().orElse(null),
source.getFragmentSource().orElseThrow(NullPointerException::new));
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);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, tessControl, tessEval, fragment);
Objects.requireNonNull(flipped);
ProgramBuilder builder;
try {
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, tessControl, tessEval, fragment, IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
} catch (RuntimeException e) {
// TODO: Better error handling
throw new RuntimeException("Shader compilation failed for shadow composite " + source.getName() + "!", e);
@@ -9,6 +9,8 @@ import net.coderbot.iris.gl.texture.DepthBufferFormat;
import net.coderbot.iris.gl.texture.DepthCopyStrategy;
import net.coderbot.iris.gl.texture.InternalTextureFormat;
import net.coderbot.iris.rendertarget.DepthTexture;
import net.coderbot.iris.features.FeatureFlags;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import net.coderbot.iris.rendertarget.RenderTarget;
import net.coderbot.iris.shaderpack.PackShadowDirectives;
import org.lwjgl.opengl.GL11;
@@ -35,11 +37,11 @@ public class ShadowRenderTargets {
private final InternalTextureFormat[] formats;
private final IntList buffersToBeCleared;
public ShadowRenderTargets(int resolution, PackShadowDirectives shadowDirectives) {
public ShadowRenderTargets(WorldRenderingPipeline pipeline, int resolution, PackShadowDirectives shadowDirectives) {
this.shadowDirectives = shadowDirectives;
this.resolution = resolution;
final int size = shadowDirectives.getColorSamplingSettings().size();
final int size = pipeline.hasFeature(FeatureFlags.HIGHER_SHADOWCOLOR) ? PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_IRIS : PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS_OF;
targets = new RenderTarget[size];
formats = new InternalTextureFormat[size];
flipped = new boolean[size];
@@ -74,7 +74,7 @@ public class AdvancedShadowCullingFrustum extends Frustrum implements ViewportPr
private int planeCount = 0;
private final Vector3f shadowLightVectorFromOrigin = new Vector3f();
private BoxCuller boxCuller;
protected BoxCuller boxCuller;
private final Vector3d position = new Vector3d();
private final BaseClippingPlanes baseClippingPlanes = new BaseClippingPlanes();
@@ -277,13 +277,13 @@ public class AdvancedShadowCullingFrustum extends Frustrum implements ViewportPr
return new Viewport(this, position.set(xPosition, yPosition, zPosition));
}
private boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
protected boolean isVisible(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
return this.checkCornerVisibility((float)(minX - xPosition), (float)(minY - yPosition), (float)(minZ - zPosition),
(float)(maxX - xPosition), (float)(maxY - yPosition), (float)(maxZ - zPosition));
}
// view-relative coordinates.
private boolean checkCornerVisibility(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
protected boolean checkCornerVisibility(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
for (int i = 0; i < planeCount; ++i) {
final Vector4f plane = this.planes[i];
@@ -0,0 +1,55 @@
package net.coderbot.iris.shadows.frustum.advanced;
import net.coderbot.iris.shadows.frustum.BoxCuller;
import net.minecraft.util.AxisAlignedBB;
import org.joml.Matrix4f;
import org.joml.Vector3f;
public class SafeZoneCullingFrustum extends AdvancedShadowCullingFrustum {
private final BoxCuller distanceCuller;
public SafeZoneCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVector, BoxCuller voxelCuller, BoxCuller distanceCuller) {
super();
init(playerView, playerProjection, shadowLightVector, voxelCuller);
this.distanceCuller = distanceCuller;
}
@Override
public void setPosition(double cameraX, double cameraY, double cameraZ) {
if (this.distanceCuller != null) {
this.distanceCuller.setPosition(cameraX, cameraY, cameraZ);
}
super.setPosition(cameraX, cameraY, cameraZ);
}
@Override
public boolean isBoundingBoxInFrustum(AxisAlignedBB aabb) {
// Cull if outside the overall distance limit
if (distanceCuller != null && distanceCuller.isCulled(aabb)) {
return false;
}
// If within the voxel safe zone, always render
if (boxCuller != null && !boxCuller.isCulled(aabb)) {
return true;
}
// Otherwise fall through to advanced frustum culling
return isVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
}
@Override
public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
// Cull if outside the overall distance limit
if (distanceCuller != null && distanceCuller.isCulledViewRelative(minX, minY, minZ, maxX, maxY, maxZ)) {
return false;
}
// If within the voxel safe zone, always render
if (boxCuller != null && !boxCuller.isCulledViewRelative(minX, minY, minZ, maxX, maxY, maxZ)) {
return true;
}
return checkCornerVisibility(minX, minY, minZ, maxX, maxY, maxZ);
}
}