diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index df837ec614..4fbf4843a5 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -69,6 +69,7 @@ dependencies {
sourceSets {
val main = getByName("main")
val headers = create("headers")
+ val api = create("api")
val vendored = create("vendored")
val desktop = getByName("desktop")
@@ -84,6 +85,12 @@ sourceSets {
}
}
+ api.apply {
+ java {
+ compileClasspath += main.compileClasspath
+ }
+ }
+
desktop.apply {
java {
srcDir("src/desktop/java")
@@ -93,7 +100,9 @@ sourceSets {
main.apply {
java {
compileClasspath += headers.output
+ compileClasspath += api.output
compileClasspath += vendored.output
+ runtimeClasspath += api.output
runtimeClasspath += vendored.output
}
}
@@ -128,6 +137,10 @@ tasks {
from(vendored.output.classesDirs)
from(vendored.output.resourcesDir)
+ val api = sourceSets.getByName("api")
+ from(api.output.classesDirs)
+ from(api.output.resourcesDir)
+
val desktop = sourceSets.getByName("desktop")
from(desktop.output.classesDirs)
from(desktop.output.resourcesDir)
diff --git a/common/src/main/java/net/irisshaders/iris/api/v0/IrisApi.java b/common/src/api/java/net/irisshaders/iris/api/v0/IrisApi.java
similarity index 97%
rename from common/src/main/java/net/irisshaders/iris/api/v0/IrisApi.java
rename to common/src/api/java/net/irisshaders/iris/api/v0/IrisApi.java
index 1764a24a7a..2140a9d613 100644
--- a/common/src/main/java/net/irisshaders/iris/api/v0/IrisApi.java
+++ b/common/src/api/java/net/irisshaders/iris/api/v0/IrisApi.java
@@ -1,7 +1,5 @@
package net.irisshaders.iris.api.v0;
-import net.irisshaders.iris.apiimpl.IrisApiV0Impl;
-
import java.nio.ByteBuffer;
import java.util.function.IntFunction;
@@ -16,7 +14,7 @@ public interface IrisApi {
* @since API v0.0
*/
static IrisApi getInstance() {
- return IrisApiV0Impl.INSTANCE;
+ return IrisApiInternal.INSTANCE;
}
/**
diff --git a/common/src/main/java/net/irisshaders/iris/api/v0/IrisApiConfig.java b/common/src/api/java/net/irisshaders/iris/api/v0/IrisApiConfig.java
similarity index 100%
rename from common/src/main/java/net/irisshaders/iris/api/v0/IrisApiConfig.java
rename to common/src/api/java/net/irisshaders/iris/api/v0/IrisApiConfig.java
diff --git a/common/src/api/java/net/irisshaders/iris/api/v0/IrisApiInternal.java b/common/src/api/java/net/irisshaders/iris/api/v0/IrisApiInternal.java
new file mode 100644
index 0000000000..aac357e755
--- /dev/null
+++ b/common/src/api/java/net/irisshaders/iris/api/v0/IrisApiInternal.java
@@ -0,0 +1,16 @@
+package net.irisshaders.iris.api.v0;
+
+import org.jetbrains.annotations.ApiStatus;
+
+@ApiStatus.Internal
+public class IrisApiInternal {
+ static final IrisApi INSTANCE;
+
+ static {
+ try {
+ INSTANCE = (IrisApi) Class.forName("net.irisshaders.iris.apiimpl.IrisApiV0Impl").getField("INSTANCE").get(null);
+ } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/common/src/main/java/net/irisshaders/iris/api/v0/IrisTextVertexSink.java b/common/src/api/java/net/irisshaders/iris/api/v0/IrisTextVertexSink.java
similarity index 100%
rename from common/src/main/java/net/irisshaders/iris/api/v0/IrisTextVertexSink.java
rename to common/src/api/java/net/irisshaders/iris/api/v0/IrisTextVertexSink.java
diff --git a/common/src/main/java/net/irisshaders/iris/api/v0/item/IrisItemLightProvider.java b/common/src/api/java/net/irisshaders/iris/api/v0/item/IrisItemLightProvider.java
similarity index 100%
rename from common/src/main/java/net/irisshaders/iris/api/v0/item/IrisItemLightProvider.java
rename to common/src/api/java/net/irisshaders/iris/api/v0/item/IrisItemLightProvider.java
diff --git a/common/src/main/java/net/irisshaders/iris/mixin/vertices/MixinBufferBuilder.java b/common/src/main/java/net/irisshaders/iris/mixin/vertices/MixinBufferBuilder.java
index 0ad4b56394..488263ca9f 100644
--- a/common/src/main/java/net/irisshaders/iris/mixin/vertices/MixinBufferBuilder.java
+++ b/common/src/main/java/net/irisshaders/iris/mixin/vertices/MixinBufferBuilder.java
@@ -163,7 +163,7 @@ private void injectMidBlock(float x, float y, float z, CallbackInfoReturnable
*
*/
- private final Vector4f[] planes = new Vector4f[MAX_CLIPPING_PLANES];
+ private final float[][] planes = new float[MAX_CLIPPING_PLANES][4];
private final Vector3f shadowLightVectorFromOrigin;
private final Vector3d position = new Vector3d();
// The center coordinates of this frustum.
@@ -74,13 +74,20 @@ public class AdvancedShadowCullingFrustum extends Frustum implements net.caffein
public double z;
private int planeCount = 0;
- public AdvancedShadowCullingFrustum(Matrix4fc playerView, Matrix4fc playerProjection, Vector3f shadowLightVectorFromOrigin,
+ public AdvancedShadowCullingFrustum(Matrix4fc modelViewProjection, Matrix4fc shadowProjection, 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());
+
+ /*
+ testing code, please ignore
+ System.out.println(shadowProjection.toString(NumberFormat.getNumberInstance()));
+ System.out.println(modelViewProjection.toString(NumberFormat.getNumberInstance()));
+ */
+
this.shadowLightVectorFromOrigin = shadowLightVectorFromOrigin;
- BaseClippingPlanes baseClippingPlanes = new BaseClippingPlanes(playerView, playerProjection);
+ BaseClippingPlanes baseClippingPlanes = new BaseClippingPlanes(modelViewProjection);
boolean[] isBack = addBackPlanes(baseClippingPlanes);
addEdgePlanes(baseClippingPlanes, isBack);
@@ -88,7 +95,7 @@ public AdvancedShadowCullingFrustum(Matrix4fc playerView, Matrix4fc playerProjec
this.boxCuller = boxCuller;
}
- private void addPlane(Vector4f plane) {
+ private void addPlane(float[] plane) {
planes[planeCount] = plane;
planeCount += 1;
}
@@ -121,7 +128,7 @@ private boolean[] addBackPlanes(BaseClippingPlanes baseClippingPlanes) {
isBack[planeIndex] = back;
if (back || edge) {
- addPlane(plane);
+ addPlane(new float[] { plane.x, plane.y, plane.z, plane.w });
}
}
@@ -267,7 +274,7 @@ private void addEdgePlane(Vector4f backPlane4, Vector4f frontPlane4) {
}
}*/
- addPlane(plane);
+ addPlane(new float[] { plane.x, plane.y, plane.z, plane.w });
}
// Note: These functions are copied & modified from the vanilla Frustum class.
@@ -347,29 +354,39 @@ private static float safeFMA(float a, float b, float c) {
* @return 0 if nothing is visible, 1 if everything is visible, 2 if only some corners are visible.
*/
protected int checkCornerVisibility(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
+ boolean inside = true;
+
for (int i = 0; i < planeCount; ++i) {
- Vector4f plane = this.planes[i];
+ float[] plane = this.planes[i];
// Check if plane is inside or intersecting.
// This is ported from JOML's FrustumIntersection.
- float outsideBoundX = (plane.x < 0) ? minX : maxX;
- float outsideBoundY = (plane.y < 0) ? minY : maxY;
- float outsideBoundZ = (plane.z < 0) ? minZ : maxZ;
+ float outsideBoundX = (plane[0] < 0) ? minX : maxX;
+ float outsideBoundY = (plane[1] < 0) ? minY : maxY;
+ float outsideBoundZ = (plane[2] < 0) ? minZ : maxZ;
// Use Math.fma for the dot product calculation to get vectorization (sorry old Intel users)
if (FMA_SUPPORT) {
- if (Math.fma(plane.x, outsideBoundX, Math.fma(plane.y, outsideBoundY, plane.z * outsideBoundZ)) < -plane.w) {
+ if (Math.fma(plane[0], outsideBoundX, Math.fma(plane[1], outsideBoundY, plane[2] * outsideBoundZ)) >= -plane[3]) {
+ inside &= Math.fma(plane[0], (plane[0] < 0 ? maxX : minX),
+ Math.fma(plane[1], (plane[1] < 0 ? maxY : minY),
+ Math.fma(plane[2], (plane[2] < 0 ? maxZ : minZ), plane[3]))) >= 0;
+ } else {
return 0;
}
} else {
- if (safeFMA(plane.x, outsideBoundX, safeFMA(plane.y, outsideBoundY, plane.z * outsideBoundZ)) < -plane.w) {
+ if (safeFMA(plane[0], outsideBoundX, safeFMA(plane[1], outsideBoundY, plane[2] * outsideBoundZ)) >= -plane[3]) {
+ inside &= safeFMA(plane[0], (plane[0] < 0 ? maxX : minX),
+ safeFMA(plane[1], (plane[1] < 0 ? maxY : minY),
+ safeFMA(plane[2], (plane[2] < 0 ? maxZ : minZ), plane[3]))) >= 0;
+ } else {
return 0;
}
}
}
- return 2;
+ return inside ? 1 : 2;
}
/**
@@ -385,7 +402,13 @@ protected int checkCornerVisibility(float minX, float minY, float minZ, float ma
*/
public boolean checkCornerVisibilityBool(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
for (int i = 0; i < planeCount; ++i) {
- if (planes[i].x * (planes[i].x < 0 ? minX : maxX) + planes[i].y * (planes[i].y < 0 ? minY : maxY) + planes[i].z * (planes[i].z < 0 ? minZ : maxZ) < -planes[i].w) {
+ float[] plane = planes[i];
+
+ float outsideBoundX = (plane[0] < 0) ? minX : maxX;
+ float outsideBoundY = (plane[1] < 0) ? minY : maxY;
+ float outsideBoundZ = (plane[2] < 0) ? minZ : maxZ;
+
+ if (Math.fma(plane[0], outsideBoundX, Math.fma(plane[1], outsideBoundY, plane[2] * outsideBoundZ)) < -plane[3]) {
return false;
}
}
diff --git a/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/BaseClippingPlanes.java b/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/BaseClippingPlanes.java
index c21d105f8f..88a07023a5 100644
--- a/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/BaseClippingPlanes.java
+++ b/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/BaseClippingPlanes.java
@@ -7,8 +7,8 @@
public class BaseClippingPlanes {
private final Vector4f[] planes = new Vector4f[6];
- public BaseClippingPlanes(Matrix4fc playerView, Matrix4fc playerProjection) {
- this.init(playerView, playerProjection);
+ public BaseClippingPlanes(Matrix4fc modelViewProjection) {
+ this.init(modelViewProjection);
}
private static Vector4f transform(Matrix4fc transform, float x, float y, float z) {
@@ -19,11 +19,10 @@ private static Vector4f transform(Matrix4fc transform, float x, float y, float z
return vector4f;
}
- private void init(Matrix4fc view, Matrix4fc projection) {
+ private void init(Matrix4fc modelViewProjection) {
// Transform = Transpose(Projection x View)
- Matrix4f transform = new Matrix4f(projection);
- transform.mul(view);
+ Matrix4f transform = new Matrix4f(modelViewProjection);
transform.transpose();
planes[0] = transform(transform, -1, 0, 0);
diff --git a/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java b/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java
index 6ebee41a5c..2b4907d362 100644
--- a/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java
+++ b/common/src/main/java/net/irisshaders/iris/shadows/frustum/advanced/ReversedAdvancedShadowCullingFrustum.java
@@ -9,8 +9,8 @@
public class ReversedAdvancedShadowCullingFrustum extends AdvancedShadowCullingFrustum implements Frustum {
private final BoxCuller distanceCuller;
- public ReversedAdvancedShadowCullingFrustum(Matrix4fc playerView, Matrix4fc playerProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller voxelCuller, BoxCuller distanceCuller) {
- super(playerView, playerProjection, shadowLightVectorFromOrigin, voxelCuller);
+ public ReversedAdvancedShadowCullingFrustum(Matrix4fc modelViewProjection, Matrix4fc shadowProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller voxelCuller, BoxCuller distanceCuller) {
+ super(modelViewProjection, shadowProjection, shadowLightVectorFromOrigin, voxelCuller);
this.distanceCuller = distanceCuller;
}
diff --git a/common/src/main/java/net/irisshaders/iris/vertices/NormalHelper.java b/common/src/main/java/net/irisshaders/iris/vertices/NormalHelper.java
index 327cc2526a..b503a1dae3 100644
--- a/common/src/main/java/net/irisshaders/iris/vertices/NormalHelper.java
+++ b/common/src/main/java/net/irisshaders/iris/vertices/NormalHelper.java
@@ -387,6 +387,12 @@ public static int computeTangent(float normalX, float normalY, float normalZ, Tr
return NormI8.pack(tangentx, tangenty, tangentz, tangentW);
}
+ public static int computeTangent(float normalX, float normalY, float normalZ, float x0, float y0, float z0, float u0, float v0,
+ float x1, float y1, float z1, float u1, float v1,
+ float x2, float y2, float z2, float u2, float v2) {
+ return computeTangent(null, normalX, normalY, normalZ, x0, y0, z0, u0, v0, x1, y1, z1, u1, v1, x2, y2, z2, u2, v2);
+ }
+
public static int computeTangent(Vector4f output, float normalX, float normalY, float normalZ, float x0, float y0, float z0, float u0, float v0,
float x1, float y1, float z1, float u1, float v1,
float x2, float y2, float z2, float u2, float v2) {
diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts
index 34606ecfd9..a0f9b4a70a 100644
--- a/fabric/build.gradle.kts
+++ b/fabric/build.gradle.kts
@@ -69,6 +69,7 @@ dependencies {
implementAndInclude("org.anarres:jcpp:1.4.14")
implementation(project.project(":common").sourceSets.getByName("vendored").output)
+ implementation(project.project(":common").sourceSets.getByName("api").output)
compileOnly(project.project(":common").sourceSets.getByName("headers").output)
implementation(project.project(":common").sourceSets.getByName("main").output)
diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts
index 1e44614a4e..75931828b0 100644
--- a/neoforge/build.gradle.kts
+++ b/neoforge/build.gradle.kts
@@ -34,19 +34,6 @@ repositories {
}
tasks.jar {
- val vendored = project.project(":common").sourceSets.getByName("vendored")
- from(vendored.output.classesDirs)
- from(vendored.output.resourcesDir)
-
- val desktop = project.project(":common").sourceSets.getByName("desktop")
- from(desktop.output.classesDirs)
- from(desktop.output.resourcesDir)
-
- val main = project.project(":common").sourceSets.getByName("main")
- from(main.output.classesDirs) {
- exclude("/iris.refmap.json")
- }
- from(main.output.resourcesDir)
from(rootDir.resolve("LICENSE.md"))
@@ -57,6 +44,24 @@ tasks.jar {
manifest.attributes["Main-Class"] = "net.irisshaders.iris.LaunchWarn"
}
+// NeoGradle compiles the game, but we don't want to add our common code to the game's code
+val notNeoTask: (Task) -> Boolean = { it: Task -> !it.name.startsWith("neo") && !it.name.startsWith("compileService") }
+
+tasks.withType().matching(notNeoTask).configureEach {
+ source(project(":common").sourceSets.main.get().allSource)
+ source(project(":common").sourceSets.getByName("vendored").allSource)
+ source(project(":common").sourceSets.getByName("api").allSource)
+ source(project(":common").sourceSets.getByName("desktop").allSource)
+}
+
+tasks.withType().matching(notNeoTask).configureEach {
+ source(project(":common").sourceSets.main.get().allJava)
+}
+
+tasks.withType().matching(notNeoTask).configureEach {
+ from(project(":common").sourceSets.main.get().resources)
+}
+
tasks.jar.get().destinationDirectory = rootDir.resolve("build").resolve("libs")
neoForge {
@@ -79,8 +84,6 @@ neoForge {
mods {
create("sodium") {
sourceSet(sourceSets.main.get())
- sourceSet(project.project(":common").sourceSets.main.get())
- sourceSet(project.project(":common").sourceSets.getByName("vendored"))
}
}
}
@@ -105,9 +108,12 @@ tasks.named("compileTestJava").configure {
}
dependencies {
+ compileOnly(files(rootDir.resolve("DHApi.jar")))
+
compileOnly(project.project(":common").sourceSets.main.get().output)
compileOnly(project.project(":common").sourceSets.getByName("vendored").output)
compileOnly(project.project(":common").sourceSets.getByName("headers").output)
+ compileOnly(project.project(":common").sourceSets.getByName("api").output)
includeDep("org.sinytra.forgified-fabric-api:fabric-api-base:0.4.42+d1308ded19")
includeDep("org.sinytra.forgified-fabric-api:fabric-renderer-api-v1:3.4.0+acb05a3919")
includeDep("org.sinytra.forgified-fabric-api:fabric-rendering-data-attachment-v1:0.3.48+73761d2e19")