mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-25 22:54:28 +00:00
Shadow Compute Shaders (#1333)
This commit is contained in:
1 parent
b75a5d8f7d
commit
bee9541797
37 files changed
+1111
-252
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package net.coderbot.iris.gl.blending;
|
||||
|
||||
public class AlphaTest {
|
||||
public static final AlphaTest ALWAYS = new AlphaTest(AlphaTestFunction.ALWAYS, 0.0f);
|
||||
|
||||
private final AlphaTestFunction function;
|
||||
private final float reference;
|
||||
|
||||
@@ -16,4 +18,45 @@ public class AlphaTest {
|
||||
public float getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public String toExpression(String indentation) {
|
||||
return toExpression("gl_FragData[0].a", "iris_currentAlphaTest", indentation);
|
||||
}
|
||||
|
||||
public String toExpression(String alphaAccessor, String alphaThreshold, String indentation) {
|
||||
String expr = function.getExpression();
|
||||
|
||||
if (function == AlphaTestFunction.ALWAYS) {
|
||||
return "// alpha test disabled\n";
|
||||
} else if (function == AlphaTestFunction.NEVER) {
|
||||
return "discard;\n";
|
||||
}
|
||||
|
||||
return indentation + "if (!(" + alphaAccessor + " " + expr + " " + alphaThreshold + ")) {\n" +
|
||||
indentation + " discard;\n" +
|
||||
indentation + "}\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((function == null) ? 0 : function.hashCode());
|
||||
result = prime * result + Float.floatToIntBits(reference);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AlphaTest other = (AlphaTest) obj;
|
||||
if (function != other.function)
|
||||
return false;
|
||||
return Float.floatToIntBits(reference) == Float.floatToIntBits(other.reference);
|
||||
}
|
||||
}
|
||||
@@ -5,33 +5,35 @@ import org.lwjgl.opengl.GL11;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum AlphaTestFunction {
|
||||
NEVER(GL11.GL_NEVER),
|
||||
LESS(GL11.GL_LESS),
|
||||
EQUAL(GL11.GL_EQUAL),
|
||||
LEQUAL(GL11.GL_LEQUAL),
|
||||
GREATER(GL11.GL_GREATER),
|
||||
NOTEQUAL(GL11.GL_NOTEQUAL),
|
||||
GEQUAL(GL11.GL_GEQUAL),
|
||||
ALWAYS(GL11.GL_ALWAYS);
|
||||
NEVER(GL11.GL_NEVER, null),
|
||||
LESS(GL11.GL_LESS, "<"),
|
||||
EQUAL(GL11.GL_EQUAL, "=="),
|
||||
LEQUAL(GL11.GL_LEQUAL, "<="),
|
||||
GREATER(GL11.GL_GREATER, ">"),
|
||||
NOTEQUAL(GL11.GL_NOTEQUAL, "!="),
|
||||
GEQUAL(GL11.GL_GEQUAL, ">="),
|
||||
ALWAYS(GL11.GL_ALWAYS, null);
|
||||
|
||||
private final int glId;
|
||||
private final String expression;
|
||||
|
||||
AlphaTestFunction(int glFormat) {
|
||||
AlphaTestFunction(int glFormat, String expression) {
|
||||
this.glId = glFormat;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public static Optional<AlphaTestFunction> fromGlId(int glId) {
|
||||
return switch (glId) {
|
||||
case GL11.GL_NEVER -> Optional.of(NEVER);
|
||||
case GL11.GL_LESS -> Optional.of(LESS);
|
||||
case GL11.GL_EQUAL -> Optional.of(EQUAL);
|
||||
case GL11.GL_LEQUAL -> Optional.of(LEQUAL);
|
||||
case GL11.GL_GREATER -> Optional.of(GREATER);
|
||||
case GL11.GL_NOTEQUAL -> Optional.of(NOTEQUAL);
|
||||
case GL11.GL_GEQUAL -> Optional.of(GEQUAL);
|
||||
case GL11.GL_ALWAYS -> Optional.of(ALWAYS);
|
||||
default -> Optional.empty();
|
||||
};
|
||||
return switch (glId) {
|
||||
case GL11.GL_NEVER -> Optional.of(NEVER);
|
||||
case GL11.GL_LESS -> Optional.of(LESS);
|
||||
case GL11.GL_EQUAL -> Optional.of(EQUAL);
|
||||
case GL11.GL_LEQUAL -> Optional.of(LEQUAL);
|
||||
case GL11.GL_GREATER -> Optional.of(GREATER);
|
||||
case GL11.GL_NOTEQUAL -> Optional.of(NOTEQUAL);
|
||||
case GL11.GL_GEQUAL -> Optional.of(GEQUAL);
|
||||
case GL11.GL_ALWAYS -> Optional.of(ALWAYS);
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
public static Optional<AlphaTestFunction> fromString(String name) {
|
||||
@@ -54,4 +56,8 @@ public enum AlphaTestFunction {
|
||||
public int getGlId() {
|
||||
return glId;
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ public class ImageBinding {
|
||||
public void update() {
|
||||
// We can assume that image bindings are supported here as either the EXT extension or 4.2 core, as otherwise ImageLimits
|
||||
// would report that zero image units are supported.
|
||||
RenderSystem.bindImageTexture(imageUnit, textureID.getAsInt(), 0, false, 0, GL15.GL_READ_WRITE, internalFormat);
|
||||
RenderSystem.bindImageTexture(imageUnit, textureID.getAsInt(), 0, true, 0, GL15.GL_READ_WRITE, internalFormat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.coderbot.iris.gl.state;
|
||||
|
||||
public enum FogMode {
|
||||
/**
|
||||
* Fog is disabled.
|
||||
*/
|
||||
OFF,
|
||||
|
||||
/**
|
||||
* Per-vertex fog, applicable to most geometry.
|
||||
*/
|
||||
PER_VERTEX,
|
||||
|
||||
/**
|
||||
* Per-fragment fog, for extra-long geometry like beacon beams.
|
||||
*/
|
||||
PER_FRAGMENT
|
||||
}
|
||||
Reference in new issue
Block a user