forge170-shaders #13
No files matched your search
File renamed without changes.
+2
-2
@@ -15,7 +15,7 @@ import net.irisshaders.iris.shaderpack.properties.PackRenderTargetDirectives;
|
||||
import net.irisshaders.iris.shadows.ShadowRenderTargets;
|
||||
import net.irisshaders.iris.targets.RenderTarget;
|
||||
import net.irisshaders.iris.targets.RenderTargets;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
@@ -178,7 +178,7 @@ public class IrisSamplers {
|
||||
return samplers.hasSampler("normals") || samplers.hasSampler("specular");
|
||||
}
|
||||
|
||||
public static void addLevelSamplers(SamplerHolder samplers, WorldRenderingPipeline pipeline, AbstractTexture whitePixel, boolean hasTexture, boolean hasLightmap, boolean hasOverlay) {
|
||||
public static void addLevelSamplers(SamplerHolder samplers, WorldRenderingPipeline pipeline, MCAbstractTexture whitePixel, boolean hasTexture, boolean hasLightmap, boolean hasOverlay) {
|
||||
if (hasTexture) {
|
||||
samplers.addExternalSampler(ALBEDO_TEXTURE_UNIT, "tex", "texture", "gtexture");
|
||||
} else {
|
||||
+146
-1
@@ -1,10 +1,27 @@
|
||||
package net.irisshaders.iris.shadows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
||||
import net.irisshaders.iris.shaderpack.properties.ShadowCullState;
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustumHolder;
|
||||
import net.irisshaders.iris.uniforms.CelestialUniforms;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.ARBTextureSwizzle;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.lwjgl.opengl.GL30C;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public abstract class CommonShadowRenderer {
|
||||
public static boolean ACTIVE = false;
|
||||
@@ -36,9 +53,13 @@ public abstract class CommonShadowRenderer {
|
||||
protected String debugStringTerrain = "(unavailable)";
|
||||
protected int renderedShadowEntities = 0;
|
||||
protected int renderedShadowBlockEntities = 0;
|
||||
private final List<MipmapPass> mipmapPasses = new ArrayList<>();
|
||||
|
||||
protected CommonFrustumHolder terrainFrustumHolder;
|
||||
protected CommonFrustumHolder entityFrustumHolder;
|
||||
|
||||
public CommonShadowRenderer(ProgramSource shadow, PackDirectives directives, ShadowRenderTargets shadowRenderTargets, boolean separateHardwareSamplers) {
|
||||
|
||||
initFrustumHolders();
|
||||
this.separateHardwareSamplers = separateHardwareSamplers;
|
||||
final PackShadowDirectives shadowDirectives = directives.getShadowDirectives();
|
||||
this.halfPlaneLength = shadowDirectives.getDistance();
|
||||
@@ -78,7 +99,131 @@ public abstract class CommonShadowRenderer {
|
||||
this.targets = shadowRenderTargets;
|
||||
}
|
||||
|
||||
protected abstract void initFrustumHolders();
|
||||
|
||||
protected static float getSkyAngle() {
|
||||
return MINECRAFT_SHIM.getSkyAngle();
|
||||
}
|
||||
|
||||
protected static float getSunAngle() {
|
||||
float skyAngle = getSkyAngle();
|
||||
|
||||
if (skyAngle < 0.75F) {
|
||||
return skyAngle + 0.25F;
|
||||
} else {
|
||||
return skyAngle - 0.75F;
|
||||
}
|
||||
}
|
||||
|
||||
protected static float getShadowAngle() {
|
||||
float shadowAngle = getSunAngle();
|
||||
|
||||
if (!CelestialUniforms.isDay()) {
|
||||
shadowAngle -= 0.5F;
|
||||
}
|
||||
|
||||
return shadowAngle;
|
||||
}
|
||||
|
||||
protected void configureSamplingSettings(PackShadowDirectives shadowDirectives) {
|
||||
final ImmutableList<PackShadowDirectives.DepthSamplingSettings> depthSamplingSettings =
|
||||
shadowDirectives.getDepthSamplingSettings();
|
||||
|
||||
final Int2ObjectMap<PackShadowDirectives.SamplingSettings> colorSamplingSettings =
|
||||
shadowDirectives.getColorSamplingSettings();
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE4);
|
||||
|
||||
configureDepthSampler(targets.getDepthTexture().getTextureId(), depthSamplingSettings.get(0));
|
||||
|
||||
configureDepthSampler(targets.getDepthTextureNoTranslucents().getTextureId(), depthSamplingSettings.get(1));
|
||||
|
||||
for (int i = 0; i < targets.getNumColorTextures(); i++) {
|
||||
if (targets.get(i) != null) {
|
||||
int glTextureId = targets.get(i).getMainTexture();
|
||||
|
||||
configureSampler(glTextureId, colorSamplingSettings.computeIfAbsent(i, a -> new PackShadowDirectives.SamplingSettings()));
|
||||
}
|
||||
}
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
private void configureDepthSampler(int glTextureId, PackShadowDirectives.DepthSamplingSettings settings) {
|
||||
if (settings.getHardwareFiltering() && !separateHardwareSamplers) {
|
||||
// We have to do this or else shadow hardware filtering breaks entirely!
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_COMPARE_MODE, GL30C.GL_COMPARE_REF_TO_TEXTURE);
|
||||
}
|
||||
|
||||
// Workaround for issues with old shader packs like Chocapic v4.
|
||||
// They expected the driver to put the depth value in z, but it's supposed to only
|
||||
// be available in r. So we set up the swizzle to fix that.
|
||||
IrisRenderSystem.texParameteriv(glTextureId, GL20C.GL_TEXTURE_2D, ARBTextureSwizzle.GL_TEXTURE_SWIZZLE_RGBA,
|
||||
new int[]{GL30C.GL_RED, GL30C.GL_RED, GL30C.GL_RED, GL30C.GL_ONE});
|
||||
|
||||
configureSampler(glTextureId, settings);
|
||||
}
|
||||
|
||||
private void configureSampler(int glTextureId, PackShadowDirectives.SamplingSettings settings) {
|
||||
if (settings.getMipmap()) {
|
||||
int filteringMode = settings.getNearest() ? GL20C.GL_NEAREST_MIPMAP_NEAREST : GL20C.GL_LINEAR_MIPMAP_LINEAR;
|
||||
mipmapPasses.add(new MipmapPass(glTextureId, filteringMode));
|
||||
}
|
||||
|
||||
if (!settings.getNearest()) {
|
||||
// Make sure that things are smoothed
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, GL20C.GL_LINEAR);
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MAG_FILTER, GL20C.GL_LINEAR);
|
||||
} else {
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, GL20C.GL_NEAREST);
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MAG_FILTER, GL20C.GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateMipmaps() {
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE4);
|
||||
|
||||
for (MipmapPass mipmapPass : mipmapPasses) {
|
||||
setupMipmappingForTexture(mipmapPass.texture(), mipmapPass.targetFilteringMode());
|
||||
}
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
protected void setupMipmappingForTexture(int texture, int filteringMode) {
|
||||
IrisRenderSystem.generateMipmaps(texture, GL20C.GL_TEXTURE_2D);
|
||||
IrisRenderSystem.texParameteri(texture, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, filteringMode);
|
||||
}
|
||||
|
||||
public void addDebugText(List<String> messages) {
|
||||
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: off, shadow distance 0");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: " + debugStringOverall);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Distance Terrain: " + terrainFrustumHolder.getDistanceInfo() + " Entity: " + entityFrustumHolder.getDistanceInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Culling Terrain: " + terrainFrustumHolder.getCullingInfo() + " Entity: " + entityFrustumHolder.getCullingInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Terrain: " + debugStringTerrain
|
||||
+ (shouldRenderTerrain ? "" : " (no terrain) ") + (shouldRenderTranslucent ? "" : "(no translucent)"));
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Entities: " + getEntitiesDebugString());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Block Entities: " + getBlockEntitiesDebugString());
|
||||
|
||||
addBuffersDebugText(messages);
|
||||
} else {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow info: " + debugStringTerrain);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] E: " + renderedShadowEntities);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] BE: " + renderedShadowBlockEntities);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getEntitiesDebugString();
|
||||
protected abstract String getBlockEntitiesDebugString();
|
||||
protected abstract void addBuffersDebugText(List<String> messages);
|
||||
|
||||
protected record MipmapPass(int texture, int targetFilteringMode) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -1,7 +1,5 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
public class BoxCuller {
|
||||
private final double maxDistance;
|
||||
|
||||
@@ -25,9 +23,9 @@ public class BoxCuller {
|
||||
this.maxAllowedZ = cameraZ + maxDistance;
|
||||
}
|
||||
|
||||
public boolean isCulled(AABB aabb) {
|
||||
return isCulled((float) aabb.minX, (float) aabb.minY, (float) aabb.minZ,
|
||||
(float) aabb.maxX, (float) aabb.maxY, (float) aabb.maxZ);
|
||||
public boolean isCulled(MCAABB aabb) {
|
||||
return isCulled(aabb.minX(), aabb.minY(), aabb.minZ(),
|
||||
aabb.maxX(), aabb.maxY(), aabb.maxZ());
|
||||
}
|
||||
|
||||
public boolean isCulled(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
public abstract class CommonFrustum {
|
||||
public void prepare(double camX, double camY, double camZ) {
|
||||
// Do nothing by default
|
||||
}
|
||||
abstract public boolean isVisible(MCAABB aabb);
|
||||
}
|
||||
+10
-2
@@ -1,6 +1,8 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
public abstract class CommonFrustumHolder {
|
||||
|
||||
public class CommonFrustumHolder {
|
||||
protected CommonFrustum frustum;
|
||||
protected String distanceInfo = "(unavailable)";
|
||||
protected String cullingInfo = "(unavailable)";
|
||||
|
||||
@@ -12,8 +14,14 @@ public abstract class CommonFrustumHolder {
|
||||
return cullingInfo;
|
||||
}
|
||||
|
||||
protected void setInfo(String distanceInfo, String cullingInfo) {
|
||||
public CommonFrustumHolder setInfo(CommonFrustum frustum, String distanceInfo, String cullingInfo) {
|
||||
this.frustum = frustum;
|
||||
this.distanceInfo = distanceInfo;
|
||||
this.cullingInfo = cullingInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonFrustum getFrustum() {
|
||||
return frustum;
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -1,15 +1,11 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
public class CullEverythingFrustum extends Frustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
public class CullEverythingFrustum extends CommonFrustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
public CullEverythingFrustum() {
|
||||
super(new Matrix4f(), new Matrix4f());
|
||||
}
|
||||
|
||||
// For Immersive Portals
|
||||
@@ -18,7 +14,7 @@ public class CullEverythingFrustum extends Frustum implements ViewportProvider,
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVisible(AABB box) {
|
||||
public boolean isVisible(MCAABB box) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
public interface MCAABB {
|
||||
float minX();
|
||||
float minY();
|
||||
float minZ();
|
||||
|
||||
float maxX();
|
||||
float maxY();
|
||||
float maxZ();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
public interface MCFrustum {
|
||||
void prepare(double camX, double camY, double camZ);
|
||||
boolean isVisible(MCAABB aabb);
|
||||
}
|
||||
+5
-8
@@ -1,8 +1,8 @@
|
||||
package net.irisshaders.iris.shadows.frustum.advanced;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.BoxCuller;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.joml.*;
|
||||
@@ -28,7 +28,7 @@ import org.joml.Math;
|
||||
* are not sensitive to the specific internal ordering of planes and corners, in order to avoid potential bugs at the
|
||||
* cost of slightly more computations.</p>
|
||||
*/
|
||||
public class AdvancedShadowCullingFrustum extends Frustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
public class AdvancedShadowCullingFrustum extends CommonFrustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
private static final int MAX_CLIPPING_PLANES = 13;
|
||||
protected final BoxCuller boxCuller;
|
||||
/**
|
||||
@@ -71,9 +71,6 @@ public class AdvancedShadowCullingFrustum extends Frustum implements ViewportPro
|
||||
|
||||
public AdvancedShadowCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVectorFromOrigin,
|
||||
BoxCuller boxCuller) {
|
||||
// We're overriding all of the methods, don't pass any matrices down.
|
||||
super(new org.joml.Matrix4f(), new org.joml.Matrix4f());
|
||||
|
||||
this.shadowLightVectorFromOrigin = shadowLightVectorFromOrigin;
|
||||
BaseClippingPlanes baseClippingPlanes = new BaseClippingPlanes(playerView, playerProjection);
|
||||
|
||||
@@ -278,12 +275,12 @@ public class AdvancedShadowCullingFrustum extends Frustum implements ViewportPro
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(AABB aabb) {
|
||||
public boolean isVisible(MCAABB aabb) {
|
||||
if (boxCuller != null && boxCuller.isCulled(aabb)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.isVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ) != 0;
|
||||
return this.isVisible(aabb.minX(), aabb.minY(), aabb.minZ(), aabb.maxX(), aabb.maxY(), aabb.maxZ()) != 0;
|
||||
}
|
||||
|
||||
// For Sodium
|
||||
File renamed without changes.
File renamed without changes.
+3
-3
@@ -1,7 +1,7 @@
|
||||
package net.irisshaders.iris.shadows.frustum.advanced;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.BoxCuller;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ReversedAdvancedShadowCullingFrustum extends AdvancedShadowCullingF
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(AABB aabb) {
|
||||
public boolean isVisible(MCAABB aabb) {
|
||||
if (distanceCuller != null && distanceCuller.isCulled(aabb)) {
|
||||
return false;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class ReversedAdvancedShadowCullingFrustum extends AdvancedShadowCullingF
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.isVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ) != 0;
|
||||
return this.isVisible(aabb.minX(), aabb.minY(), aabb.minZ(), aabb.maxX(), aabb.maxY(), aabb.maxZ()) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
+4
-7
@@ -1,22 +1,19 @@
|
||||
package net.irisshaders.iris.shadows.frustum.fallback;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.BoxCuller;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
public class BoxCullingFrustum extends Frustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
public class BoxCullingFrustum extends CommonFrustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
private final BoxCuller boxCuller;
|
||||
private double x, y, z;
|
||||
private int worldMinYDH;
|
||||
private int worldMaxYDH;
|
||||
|
||||
public BoxCullingFrustum(BoxCuller boxCuller) {
|
||||
super(new Matrix4f(), new Matrix4f());
|
||||
|
||||
this.boxCuller = boxCuller;
|
||||
}
|
||||
|
||||
@@ -35,7 +32,7 @@ public class BoxCullingFrustum extends Frustum implements ViewportProvider, org.
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVisible(AABB box) {
|
||||
public boolean isVisible(MCAABB box) {
|
||||
return !boxCuller.isCulled(box);
|
||||
}
|
||||
|
||||
+8
-9
@@ -1,16 +1,15 @@
|
||||
package net.irisshaders.iris.shadows.frustum.fallback;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
public class NonCullingFrustum extends Frustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
|
||||
|
||||
public class NonCullingFrustum extends CommonFrustum implements ViewportProvider, org.embeddedt.embeddium.impl.render.viewport.frustum.Frustum {
|
||||
public NonCullingFrustum() {
|
||||
super(new Matrix4f(), new Matrix4f());
|
||||
}
|
||||
|
||||
// For Immersive Portals
|
||||
@@ -21,7 +20,8 @@ public class NonCullingFrustum extends Frustum implements ViewportProvider, org.
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVisible(AABB box) {
|
||||
@Override
|
||||
public boolean isVisible(MCAABB box) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ public class NonCullingFrustum extends Frustum implements ViewportProvider, org.
|
||||
|
||||
@Override
|
||||
public Viewport sodium$createViewport() {
|
||||
var camPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
return new Viewport(this, pos.set(camPos.x, camPos.y, camPos.z));
|
||||
return new Viewport(this, pos.set(MINECRAFT_SHIM.getUnshiftedCameraPosition()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.irisshaders.iris.compat.mc;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import net.irisshaders.iris.shadows.frustum.MCFrustum;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public class FrustumWrapper extends Frustrum implements MCFrustum {
|
||||
@Override
|
||||
public void prepare(double camX, double camY, double camZ) {
|
||||
setPosition(camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(MCAABB aabb) {
|
||||
return isBoundingBoxInFrustum((AxisAlignedBB) aabb);
|
||||
}
|
||||
}
|
||||
+10
-33
@@ -1,52 +1,24 @@
|
||||
package net.irisshaders.iris.shadows;
|
||||
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.gui.option.IrisVideoSettings;
|
||||
import net.irisshaders.iris.shaderpack.programs.ProgramSource;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.shadows.frustum.FrustumHolder;
|
||||
import net.irisshaders.iris.shadows.frustum.ArchaicFrustumHolder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArchaicShadowRenderer extends CommonShadowRenderer {
|
||||
private FrustumHolder terrainFrustumHolder;
|
||||
private FrustumHolder entityFrustumHolder;
|
||||
|
||||
|
||||
public ArchaicShadowRenderer(ProgramSource shadow, PackDirectives directives, ShadowRenderTargets shadowRenderTargets, boolean separateHardwareSamplers) {
|
||||
super(shadow, directives, shadowRenderTargets, separateHardwareSamplers);
|
||||
|
||||
this.terrainFrustumHolder = new FrustumHolder();
|
||||
this.entityFrustumHolder = new FrustumHolder();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addDebugText(List<String> messages) {
|
||||
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: off, shadow distance 0");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: " + debugStringOverall);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Distance Terrain: " + terrainFrustumHolder.getDistanceInfo() + " Entity: " + entityFrustumHolder.getDistanceInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Culling Terrain: " + terrainFrustumHolder.getCullingInfo() + " Entity: " + entityFrustumHolder.getCullingInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Terrain: " + debugStringTerrain
|
||||
+ (shouldRenderTerrain ? "" : " (no terrain) ") + (shouldRenderTranslucent ? "" : "(no translucent)"));
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Entities: " + getEntitiesDebugString());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Block Entities: " + getBlockEntitiesDebugString());
|
||||
|
||||
// if (buffers instanceof DrawCallTrackingRenderBuffers drawCallTracker && (shouldRenderEntities || shouldRenderPlayer)) {
|
||||
// messages.add("[" + IrisConstants.MODNAME + "] Shadow Entity Batching: " + BatchingDebugMessageHelper.getDebugMessage(drawCallTracker));
|
||||
// }
|
||||
} else {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow info: " + debugStringTerrain);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] E: " + renderedShadowEntities);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] BE: " + renderedShadowBlockEntities);
|
||||
}
|
||||
@Override
|
||||
protected void initFrustumHolders() {
|
||||
this.terrainFrustumHolder = new ArchaicFrustumHolder();
|
||||
this.entityFrustumHolder = new ArchaicFrustumHolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,4 +30,9 @@ public class ArchaicShadowRenderer extends CommonShadowRenderer {
|
||||
protected String getBlockEntitiesDebugString() {
|
||||
return (shouldRenderBlockEntities || shouldRenderLightBlockEntities) ? renderedShadowBlockEntities + "" : "disabled by pack"; // TODO: + "/" + MinecraftClient.getInstance().world.blockEntities.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addBuffersDebugText(List<String> messages) {
|
||||
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
public class ArchaicFrustumHolder extends CommonFrustumHolder {
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
|
||||
public class FrustumHolder extends CommonFrustumHolder {
|
||||
private Frustrum frustum;
|
||||
|
||||
public FrustumHolder setInfo(Frustrum frustum, String distanceInfo, String cullingInfo) {
|
||||
super.setInfo(distanceInfo, cullingInfo);
|
||||
this.frustum = frustum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Frustrum getFrustum() {
|
||||
return frustum;
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.taumc.celeritas.mixin.shaders;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(AxisAlignedBB.class)
|
||||
public class MixinAxisAlignedBB_Shaders implements MCAABB {
|
||||
@Shadow public double minX;
|
||||
@Shadow public double minY;
|
||||
@Shadow public double minZ;
|
||||
@Shadow public double maxX;
|
||||
@Shadow public double maxY;
|
||||
@Shadow public double maxZ;
|
||||
|
||||
@Override
|
||||
public float minX() {
|
||||
return (float)minX;
|
||||
}
|
||||
@Override
|
||||
public float minY() {
|
||||
return (float)minY;
|
||||
}
|
||||
@Override
|
||||
public float minZ() {
|
||||
return (float)minZ;
|
||||
}
|
||||
@Override
|
||||
public float maxX() {
|
||||
return (float)maxX;
|
||||
}
|
||||
@Override
|
||||
public float maxY() {
|
||||
return (float)maxY;
|
||||
}
|
||||
@Override
|
||||
public float maxZ() {
|
||||
return (float)maxZ;
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package org.taumc.celeritas.mixin.shaders;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import net.irisshaders.iris.shadows.frustum.MCFrustum;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Frustrum.class)
|
||||
public class MixinFrustrum_Shaders implements MCFrustum {
|
||||
@Shadow public void setPosition(double camX, double camY, double camZ) {
|
||||
throw new IllegalStateException("Mixin shadow method should not be called");
|
||||
}
|
||||
|
||||
@Shadow public boolean isBoundingBoxInFrustum(AxisAlignedBB aabb) {
|
||||
throw new IllegalStateException("Mixin shadow method should not be called");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(double camX, double camY, double camZ) {
|
||||
setPosition(camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(MCAABB aabb) {
|
||||
return isBoundingBoxInFrustum((AxisAlignedBB) aabb);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.irisshaders.iris.compat.mc;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import net.irisshaders.iris.shadows.frustum.MCFrustum;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class FrustumWrapper extends Frustum implements MCFrustum {
|
||||
private static final Matrix4f emptyProjection = new Matrix4f();
|
||||
private static final Matrix4f emptyFrustum = new Matrix4f();
|
||||
|
||||
protected CommonFrustum frustum;
|
||||
|
||||
public FrustumWrapper(CommonFrustum mcFrustum) {
|
||||
super(emptyProjection.identity(), emptyFrustum.identity());
|
||||
this.frustum = mcFrustum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(double camX, double camY, double camZ) {
|
||||
super.prepare(camX, camY, camZ);
|
||||
this.frustum.prepare(camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(MCAABB aabb) {
|
||||
return this.frustum.isVisible(aabb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible(AABB aabb) {
|
||||
return isVisible((MCAABB) aabb);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.MCAABB;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(AABB.class)
|
||||
public class MixinAABB implements MCAABB {
|
||||
@Final @Shadow public double minX;
|
||||
@Final @Shadow public double minY;
|
||||
@Final @Shadow public double minZ;
|
||||
@Final @Shadow public double maxX;
|
||||
@Final @Shadow public double maxY;
|
||||
@Final @Shadow public double maxZ;
|
||||
|
||||
@Override
|
||||
public float minX() {
|
||||
return (float)minX;
|
||||
}
|
||||
@Override
|
||||
public float minY() {
|
||||
return (float)minY;
|
||||
}
|
||||
@Override
|
||||
public float minZ() {
|
||||
return (float)minZ;
|
||||
}
|
||||
@Override
|
||||
public float maxX() {
|
||||
return (float)maxX;
|
||||
}
|
||||
@Override
|
||||
public float maxY() {
|
||||
return (float)maxY;
|
||||
}
|
||||
@Override
|
||||
public float maxZ() {
|
||||
return (float)maxZ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.irisshaders.iris.mixin;
|
||||
|
||||
import net.irisshaders.iris.shadows.frustum.MCFrustum;
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Frustum.class)
|
||||
public abstract class MixinFrustum implements MCFrustum {
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import net.irisshaders.iris.Iris;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.compat.mc.FrustumWrapper;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
import net.irisshaders.iris.layer.IsOutlineRenderStateShard;
|
||||
import net.irisshaders.iris.layer.OuterWrappedRenderType;
|
||||
@@ -121,7 +122,7 @@ public class MixinLevelRenderer {
|
||||
pipeline = Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimension());
|
||||
|
||||
if (pipeline.shouldDisableFrustumCulling()) {
|
||||
this.cullingFrustum = new NonCullingFrustum();
|
||||
this.cullingFrustum = new FrustumWrapper(new NonCullingFrustum());
|
||||
}
|
||||
|
||||
IrisRenderSystem.backupAndDisableCullingState(pipeline.shouldDisableOcclusionCulling());
|
||||
|
||||
+5
-4
@@ -92,6 +92,7 @@ import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import org.embeddedt.embeddium.compat.mc.ICamera;
|
||||
import org.embeddedt.embeddium.compat.mc.ILevelRenderer;
|
||||
import org.embeddedt.embeddium.compat.mc.MCAbstractTexture;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Vector3d;
|
||||
@@ -240,7 +241,7 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
||||
shouldBindPBR = IrisSamplers.hasPBRSamplers(customTextureSamplerInterceptor);
|
||||
}
|
||||
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, true, true, false);
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, (MCAbstractTexture) whitePixel, true, true, false);
|
||||
IrisSamplers.addWorldDepthSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
@@ -283,7 +284,7 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
||||
shouldBindPBR = IrisSamplers.hasPBRSamplers(customTextureSamplerInterceptor);
|
||||
}
|
||||
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, true, true, false);
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, (MCAbstractTexture) whitePixel, true, true, false);
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
|
||||
@@ -496,7 +497,7 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
||||
IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, true, true, false);
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, (MCAbstractTexture) whitePixel, true, true, false);
|
||||
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
|
||||
|
||||
@@ -683,7 +684,7 @@ public class ModernIrisRenderingPipeline extends CommonIrisRenderingPipeline imp
|
||||
shouldBindPBR = IrisSamplers.hasPBRSamplers(samplerHolder);
|
||||
}
|
||||
|
||||
IrisSamplers.addLevelSamplers(samplers, this, whitePixel, hasTexture, hasLightmap, hasOverlay);
|
||||
IrisSamplers.addLevelSamplers(samplers, this, (MCAbstractTexture) whitePixel, hasTexture, hasLightmap, hasOverlay);
|
||||
IrisSamplers.addWorldDepthSamplers(samplerHolder, this.renderTargets);
|
||||
IrisSamplers.addNoiseSampler(samplerHolder, this.customTextureManager.getNoiseTexture());
|
||||
IrisSamplers.addCustomImages(samplerHolder, customImages);
|
||||
|
||||
+28
-141
@@ -8,12 +8,9 @@ import java.util.function.Predicate;
|
||||
|
||||
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
|
||||
import net.irisshaders.batchedentityrendering.impl.*;
|
||||
import net.irisshaders.iris.IrisCommon;
|
||||
import net.irisshaders.iris.IrisConstants;
|
||||
import net.irisshaders.iris.compat.dh.DHCompat;
|
||||
import net.irisshaders.iris.gl.IrisRenderSystem;
|
||||
@@ -25,8 +22,9 @@ import net.irisshaders.iris.shaderpack.properties.PackDirectives;
|
||||
import net.irisshaders.iris.shaderpack.properties.PackShadowDirectives;
|
||||
import net.irisshaders.iris.shaderpack.properties.ShadowCullState;
|
||||
import net.irisshaders.iris.shadows.frustum.BoxCuller;
|
||||
import net.irisshaders.iris.shadows.frustum.CommonFrustumHolder;
|
||||
import net.irisshaders.iris.shadows.frustum.CullEverythingFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.FrustumHolder;
|
||||
import net.irisshaders.iris.shadows.frustum.ModernFrustumHolder;
|
||||
import net.irisshaders.iris.shadows.frustum.advanced.AdvancedShadowCullingFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.advanced.ReversedAdvancedShadowCullingFrustum;
|
||||
import net.irisshaders.iris.shadows.frustum.fallback.BoxCullingFrustum;
|
||||
@@ -57,9 +55,6 @@ import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
import org.lwjgl.opengl.ARBTextureSwizzle;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
import org.lwjgl.opengl.GL30C;
|
||||
|
||||
public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
public static List<BlockEntity> visibleBlockEntities;
|
||||
@@ -68,10 +63,6 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
private final ModernIrisRenderingPipeline pipeline;
|
||||
private final RenderBuffers buffers;
|
||||
private final RenderBuffersExt renderBuffersExt;
|
||||
private final List<MipmapPass> mipmapPasses = new ArrayList<>();
|
||||
|
||||
private FrustumHolder terrainFrustumHolder;
|
||||
private FrustumHolder entityFrustumHolder;
|
||||
|
||||
public ModernShadowRenderer(ModernIrisRenderingPipeline pipeline, ProgramSource shadow, PackDirectives directives,
|
||||
ShadowRenderTargets shadowRenderTargets, ShadowCompositeRenderer compositeRenderer, CustomUniforms customUniforms, boolean separateHardwareSamplers) {
|
||||
@@ -84,9 +75,6 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
this.compositeRenderer = compositeRenderer;
|
||||
|
||||
|
||||
this.terrainFrustumHolder = new FrustumHolder();
|
||||
this.entityFrustumHolder = new FrustumHolder();
|
||||
|
||||
int processors = Runtime.getRuntime().availableProcessors();
|
||||
int threads = processors;
|
||||
this.buffers = new RenderBuffers(/*? if >=1.20.4 {*//*threads*//*?}*/);
|
||||
@@ -100,6 +88,20 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
configureSamplingSettings(shadowDirectives);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initFrustumHolders() {
|
||||
this.terrainFrustumHolder = new ModernFrustumHolder();
|
||||
this.entityFrustumHolder = new ModernFrustumHolder();
|
||||
}
|
||||
|
||||
ModernFrustumHolder getTerrainFrustumHolder() {
|
||||
return (ModernFrustumHolder) this.terrainFrustumHolder;
|
||||
}
|
||||
|
||||
ModernFrustumHolder getEntityFrustumHolder() {
|
||||
return (ModernFrustumHolder) this.entityFrustumHolder;
|
||||
}
|
||||
|
||||
public static PoseStack createShadowModelView(float sunPathRotation, float intervalSize) {
|
||||
// Determine the camera position
|
||||
Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
@@ -119,105 +121,11 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
return Objects.requireNonNull(Minecraft.getInstance().level);
|
||||
}
|
||||
|
||||
private static float getSkyAngle() {
|
||||
return getLevel().getTimeOfDay(CapturedRenderingState.INSTANCE.getTickDelta());
|
||||
}
|
||||
|
||||
private static float getSunAngle() {
|
||||
float skyAngle = getSkyAngle();
|
||||
|
||||
if (skyAngle < 0.75F) {
|
||||
return skyAngle + 0.25F;
|
||||
} else {
|
||||
return skyAngle - 0.75F;
|
||||
}
|
||||
}
|
||||
|
||||
private static float getShadowAngle() {
|
||||
float shadowAngle = getSunAngle();
|
||||
|
||||
if (!CelestialUniforms.isDay()) {
|
||||
shadowAngle -= 0.5F;
|
||||
}
|
||||
|
||||
return shadowAngle;
|
||||
}
|
||||
|
||||
public void setUsesImages(boolean usesImages) {
|
||||
this.packHasVoxelization = packHasVoxelization || usesImages;
|
||||
}
|
||||
|
||||
private void configureSamplingSettings(PackShadowDirectives shadowDirectives) {
|
||||
final ImmutableList<PackShadowDirectives.DepthSamplingSettings> depthSamplingSettings =
|
||||
shadowDirectives.getDepthSamplingSettings();
|
||||
|
||||
final Int2ObjectMap<PackShadowDirectives.SamplingSettings> colorSamplingSettings =
|
||||
shadowDirectives.getColorSamplingSettings();
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE4);
|
||||
|
||||
configureDepthSampler(targets.getDepthTexture().getTextureId(), depthSamplingSettings.get(0));
|
||||
|
||||
configureDepthSampler(targets.getDepthTextureNoTranslucents().getTextureId(), depthSamplingSettings.get(1));
|
||||
|
||||
for (int i = 0; i < targets.getNumColorTextures(); i++) {
|
||||
if (targets.get(i) != null) {
|
||||
int glTextureId = targets.get(i).getMainTexture();
|
||||
|
||||
configureSampler(glTextureId, colorSamplingSettings.computeIfAbsent(i, a -> new PackShadowDirectives.SamplingSettings()));
|
||||
}
|
||||
}
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
private void configureDepthSampler(int glTextureId, PackShadowDirectives.DepthSamplingSettings settings) {
|
||||
if (settings.getHardwareFiltering() && !separateHardwareSamplers) {
|
||||
// We have to do this or else shadow hardware filtering breaks entirely!
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_COMPARE_MODE, GL30C.GL_COMPARE_REF_TO_TEXTURE);
|
||||
}
|
||||
|
||||
// Workaround for issues with old shader packs like Chocapic v4.
|
||||
// They expected the driver to put the depth value in z, but it's supposed to only
|
||||
// be available in r. So we set up the swizzle to fix that.
|
||||
IrisRenderSystem.texParameteriv(glTextureId, GL20C.GL_TEXTURE_2D, ARBTextureSwizzle.GL_TEXTURE_SWIZZLE_RGBA,
|
||||
new int[]{GL30C.GL_RED, GL30C.GL_RED, GL30C.GL_RED, GL30C.GL_ONE});
|
||||
|
||||
configureSampler(glTextureId, settings);
|
||||
}
|
||||
|
||||
private void configureSampler(int glTextureId, PackShadowDirectives.SamplingSettings settings) {
|
||||
if (settings.getMipmap()) {
|
||||
int filteringMode = settings.getNearest() ? GL20C.GL_NEAREST_MIPMAP_NEAREST : GL20C.GL_LINEAR_MIPMAP_LINEAR;
|
||||
mipmapPasses.add(new MipmapPass(glTextureId, filteringMode));
|
||||
}
|
||||
|
||||
if (!settings.getNearest()) {
|
||||
// Make sure that things are smoothed
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, GL20C.GL_LINEAR);
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MAG_FILTER, GL20C.GL_LINEAR);
|
||||
} else {
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, GL20C.GL_NEAREST);
|
||||
IrisRenderSystem.texParameteri(glTextureId, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MAG_FILTER, GL20C.GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateMipmaps() {
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE4);
|
||||
|
||||
for (MipmapPass mipmapPass : mipmapPasses) {
|
||||
setupMipmappingForTexture(mipmapPass.texture(), mipmapPass.targetFilteringMode());
|
||||
}
|
||||
|
||||
RENDER_SYSTEM.glActiveTexture(GL20C.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
private void setupMipmappingForTexture(int texture, int filteringMode) {
|
||||
IrisRenderSystem.generateMipmaps(texture, GL20C.GL_TEXTURE_2D);
|
||||
IrisRenderSystem.texParameteri(texture, GL20C.GL_TEXTURE_2D, GL20C.GL_TEXTURE_MIN_FILTER, filteringMode);
|
||||
}
|
||||
|
||||
private FrustumHolder createShadowFrustum(float renderMultiplier, FrustumHolder holder) {
|
||||
private CommonFrustumHolder createShadowFrustum(float renderMultiplier, CommonFrustumHolder holder) {
|
||||
// TODO: Cull entities / block entities with Advanced Frustum Culling even if voxelization is detected.
|
||||
String distanceInfo;
|
||||
String cullingInfo;
|
||||
@@ -339,7 +247,7 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
|
||||
terrainFrustumHolder = createShadowFrustum(renderDistanceMultiplier, terrainFrustumHolder);
|
||||
|
||||
FRUSTUM = terrainFrustumHolder.getFrustum();
|
||||
FRUSTUM = getTerrainFrustumHolder().getWrapper();
|
||||
|
||||
// Determine the player camera position
|
||||
Vector3d cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
@@ -349,7 +257,7 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
double cameraZ = cameraPos.z();
|
||||
|
||||
// Center the frustum on the player camera position
|
||||
terrainFrustumHolder.getFrustum().prepare(cameraX, cameraY, cameraZ);
|
||||
getTerrainFrustumHolder().getWrapper().prepare(cameraX, cameraY, cameraZ);
|
||||
|
||||
levelRenderer.getLevel().getProfiler().pop();
|
||||
|
||||
@@ -369,7 +277,7 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
levelRenderer.setShouldRegenerateClouds(regenerateClouds);
|
||||
|
||||
// Execute the vanilla terrain setup / culling routines using our shadow frustum.
|
||||
levelRenderer.invokeSetupRender((Camera) playerCamera, terrainFrustumHolder.getFrustum(), false, false);
|
||||
levelRenderer.invokeSetupRender((Camera) playerCamera, getTerrainFrustumHolder().getWrapper(), false, false);
|
||||
|
||||
// Don't forget to increment the frame counter! This variable is arbitrary and only used in terrain setup,
|
||||
// and if it's not incremented, the vanilla culling code will get confused and think that it's already seen
|
||||
@@ -436,7 +344,7 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
entityFrustumHolder = createShadowFrustum(renderDistanceMultiplier * entityShadowDistanceMultiplier, entityFrustumHolder);
|
||||
}
|
||||
|
||||
Frustum entityShadowFrustum = entityFrustumHolder.getFrustum();
|
||||
Frustum entityShadowFrustum = getEntityFrustumHolder().getWrapper();
|
||||
entityShadowFrustum.prepare(cameraX, cameraY, cameraZ);
|
||||
|
||||
var celeritasRenderer = ((WorldRendererExtended)levelRenderer).sodium$getWorldRenderer();
|
||||
@@ -652,30 +560,6 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
targets.copyPreTranslucentDepth();
|
||||
}
|
||||
|
||||
public void addDebugText(List<String> messages) {
|
||||
if (IrisVideoSettings.getOverriddenShadowDistance(IrisVideoSettings.shadowDistance) == 0) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: off, shadow distance 0");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IrisCommon.getIrisConfig().areDebugOptionsEnabled()) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Maps: " + debugStringOverall);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Distance Terrain: " + terrainFrustumHolder.getDistanceInfo() + " Entity: " + entityFrustumHolder.getDistanceInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Culling Terrain: " + terrainFrustumHolder.getCullingInfo() + " Entity: " + entityFrustumHolder.getCullingInfo());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Terrain: " + debugStringTerrain
|
||||
+ (shouldRenderTerrain ? "" : " (no terrain) ") + (shouldRenderTranslucent ? "" : "(no translucent)"));
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Entities: " + getEntitiesDebugString());
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Block Entities: " + getBlockEntitiesDebugString());
|
||||
|
||||
if (buffers instanceof DrawCallTrackingRenderBuffers drawCallTracker && (shouldRenderEntities || shouldRenderPlayer)) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Entity Batching: " + BatchingDebugMessageHelper.getDebugMessage(drawCallTracker));
|
||||
}
|
||||
} else {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow info: " + debugStringTerrain);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] E: " + renderedShadowEntities);
|
||||
messages.add("[" + IrisConstants.MODNAME + "] BE: " + renderedShadowBlockEntities);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEntitiesDebugString() {
|
||||
@@ -687,13 +571,16 @@ public class ModernShadowRenderer extends CommonShadowRenderer {
|
||||
return (shouldRenderBlockEntities || shouldRenderLightBlockEntities) ? renderedShadowBlockEntities + "" : "disabled by pack"; // TODO: + "/" + MinecraftClient.getInstance().world.blockEntities.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addBuffersDebugText(List<String> messages) {
|
||||
if (buffers instanceof DrawCallTrackingRenderBuffers drawCallTracker && (shouldRenderEntities || shouldRenderPlayer)) {
|
||||
messages.add("[" + IrisConstants.MODNAME + "] Shadow Entity Batching: " + BatchingDebugMessageHelper.getDebugMessage(drawCallTracker));
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
targets.destroy();
|
||||
((MemoryTrackingRenderBuffers) buffers).freeAndDeleteBuffers();
|
||||
}
|
||||
|
||||
private record MipmapPass(int texture, int targetFilteringMode) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
import net.minecraft.client.renderer.culling.Frustum;
|
||||
|
||||
public class FrustumHolder extends CommonFrustumHolder {
|
||||
private Frustum frustum;
|
||||
|
||||
public FrustumHolder setInfo(Frustum frustum, String distanceInfo, String cullingInfo) {
|
||||
super.setInfo(distanceInfo, cullingInfo);
|
||||
this.frustum = frustum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Frustum getFrustum() {
|
||||
return frustum;
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package net.irisshaders.iris.shadows.frustum;
|
||||
|
||||
import net.irisshaders.iris.compat.mc.FrustumWrapper;
|
||||
|
||||
public class ModernFrustumHolder extends CommonFrustumHolder {
|
||||
private FrustumWrapper wrapper;
|
||||
|
||||
@Override
|
||||
public CommonFrustumHolder setInfo(CommonFrustum frustum, String distanceInfo, String cullingInfo) {
|
||||
super.setInfo(frustum, distanceInfo, cullingInfo);
|
||||
this.wrapper = new FrustumWrapper(frustum);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FrustumWrapper getWrapper() {
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user