Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/UniversalCraft.api
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,11 @@ public final class gg/essential/universal/render/URenderPipeline$DepthTest : jav
public static final field Disabled Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field Equal Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field Greater Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field GreaterOrEqual Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field Less Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field LessOrEqual Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field Never Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static final field NotEqual Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lgg/essential/universal/render/URenderPipeline$DepthTest;
public static fun values ()[Lgg/essential/universal/render/URenderPipeline$DepthTest;
Expand Down
38 changes: 28 additions & 10 deletions src/main/kotlin/gg/essential/universal/render/URenderPipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,25 @@ class URenderPipeline private constructor(
LessOrEqual,
Less,
Greater,
GreaterOrEqual,
NotEqual,
Never,
;

//#if MC < 26.1 || STANDALONE
internal val glConst: Int
get() = when (this) {
Disabled -> GL11.GL_LESS
Always -> GL11.GL_ALWAYS
Equal -> GL11.GL_EQUAL
LessOrEqual -> GL11.GL_LEQUAL
Less -> GL11.GL_LESS
Greater -> GL11.GL_GREATER
GreaterOrEqual -> GL11.GL_GEQUAL
NotEqual -> GL11.GL_NOTEQUAL
Never -> GL11.GL_NEVER
}
//#endif
}

enum class ColorLogic {
Expand Down Expand Up @@ -444,11 +463,17 @@ class URenderPipeline private constructor(
//$$ DepthTest.LessOrEqual -> CompareOp.LESS_THAN_OR_EQUAL
//$$ DepthTest.Less -> CompareOp.LESS_THAN
//$$ DepthTest.Greater -> CompareOp.GREATER_THAN
//$$ DepthTest.GreaterOrEqual -> CompareOp.GREATER_THAN_OR_EQUAL
//$$ DepthTest.NotEqual -> CompareOp.NOT_EQUAL
//$$ DepthTest.Never -> CompareOp.NEVER_PASS
//$$ }, depthMask, polygonOffset.first, polygonOffset.second))
//$$ }
//#else
//$$ withDepthTestFunction(when (depthTest) {
//$$ DepthTest.Disabled -> DepthTestFunction.NO_DEPTH_TEST
//$$ DepthTest.Never,
//$$ DepthTest.NotEqual,
//$$ DepthTest.GreaterOrEqual,
//$$ DepthTest.Always -> DepthTestFunction.NO_DEPTH_TEST // implemented via raw GlStateManager below
//$$ DepthTest.Equal -> DepthTestFunction.EQUAL_DEPTH_TEST
//$$ DepthTest.LessOrEqual -> DepthTestFunction.LEQUAL_DEPTH_TEST
Expand Down Expand Up @@ -500,7 +525,7 @@ class URenderPipeline private constructor(
//$$ }.build()
//$$
//#if MC < 26.1
//$$ if (depthTest == DepthTest.Always) {
//$$ if (depthTest == DepthTest.Always || depthTest == DepthTest.Never || depthTest == DepthTest.NotEqual || depthTest == DepthTest.GreaterOrEqual) {
//$$ abstract class CustomRenderPipeline(inner: RenderPipeline) : RenderPipeline(
//$$ inner.location, inner.vertexShader, inner.fragmentShader, inner.shaderDefines, inner.samplers, inner.uniforms, inner.blendFunction, inner.depthTestFunction, inner.polygonMode, inner.isCull, inner.isWriteColor, inner.isWriteAlpha, inner.isWriteDepth, inner.colorLogic, inner.vertexFormat, inner.vertexFormatMode, inner.depthBiasScaleFactor, inner.depthBiasConstant,
//#if MC>=12106
Expand All @@ -512,7 +537,7 @@ class URenderPipeline private constructor(
//$$ override fun isCull(): Boolean {
//$$ if (stackWalker.callerClass == GlResourceManager::class.java) {
//$$ GlStateManager._enableDepthTest()
//$$ GlStateManager._depthFunc(GL11.GL_ALWAYS)
//$$ GlStateManager._depthFunc(depthTest.glConst)
//$$ }
//$$ return super.isCull()
//$$ }
Expand All @@ -536,14 +561,7 @@ class URenderPipeline private constructor(
shader,
ManagedGlState(
depthTest = depthTest != DepthTest.Disabled,
depthFunc = when (depthTest) {
DepthTest.Disabled -> GL11.GL_LESS
DepthTest.Always -> GL11.GL_ALWAYS
DepthTest.Equal -> GL11.GL_EQUAL
DepthTest.LessOrEqual -> GL11.GL_LEQUAL
DepthTest.Less -> GL11.GL_LESS
DepthTest.Greater -> GL11.GL_GREATER
},
depthFunc = depthTest.glConst,
culling = culling,
colorLogicOp = @Suppress("DEPRECATION") colorLogic != ColorLogic.None,
colorLogicOpMode = @Suppress("DEPRECATION") when (colorLogic) {
Expand Down
Loading