fix round log texture glitch on non-nVidia cards
This commit is contained in:
@@ -6,6 +6,7 @@ import mods.octarinecore.client.render.*
|
|||||||
import mods.octarinecore.common.Double3
|
import mods.octarinecore.common.Double3
|
||||||
import mods.octarinecore.exchange
|
import mods.octarinecore.exchange
|
||||||
import net.minecraft.util.EnumFacing.*
|
import net.minecraft.util.EnumFacing.*
|
||||||
|
import org.lwjgl.opengl.GL11
|
||||||
|
|
||||||
/** Weight of the same-side AO values on the outer edges of the 45deg chamfered column faces. */
|
/** Weight of the same-side AO values on the outer edges of the 45deg chamfered column faces. */
|
||||||
const val chamferAffinity = 0.9f
|
const val chamferAffinity = 0.9f
|
||||||
@@ -13,6 +14,9 @@ const val chamferAffinity = 0.9f
|
|||||||
/** Amount to shrink column extension bits to stop Z-fighting. */
|
/** Amount to shrink column extension bits to stop Z-fighting. */
|
||||||
val zProtectionScale: Double3 get() = Double3(Config.roundLogs.zProtection, 1.0, Config.roundLogs.zProtection)
|
val zProtectionScale: Double3 get() = Double3(Config.roundLogs.zProtection, 1.0, Config.roundLogs.zProtection)
|
||||||
|
|
||||||
|
/** nVidia does it different... */
|
||||||
|
val nVidia = GL11.glGetString(GL11.GL_VENDOR).toLowerCase().contains("nvidia")
|
||||||
|
|
||||||
fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (Quad) -> Quad = { it }) {
|
fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (Quad) -> Quad = { it }) {
|
||||||
val halfRadius = radius * 0.5
|
val halfRadius = radius * 0.5
|
||||||
listOf(
|
listOf(
|
||||||
@@ -92,12 +96,14 @@ fun Model.columnLid(radius: Double, transform: (Quad)->Quad = { it }) {
|
|||||||
1 -> EdgeInterpolateFallback(UP, SOUTH, 0.0)
|
1 -> EdgeInterpolateFallback(UP, SOUTH, 0.0)
|
||||||
else -> vertex.aoShader
|
else -> vertex.aoShader
|
||||||
})}
|
})}
|
||||||
|
.cycleVertices(if (nVidia) 0 else 1)
|
||||||
val q2 = Quad(v1, v4, v5, v6).setAoShader(faceOrientedAuto(overrideFace = UP, corner = cornerAo(Axis.Y)))
|
val q2 = Quad(v1, v4, v5, v6).setAoShader(faceOrientedAuto(overrideFace = UP, corner = cornerAo(Axis.Y)))
|
||||||
.transformVI { vertex, idx -> vertex.copy(aoShader = when(idx) {
|
.transformVI { vertex, idx -> vertex.copy(aoShader = when(idx) {
|
||||||
0 -> FaceCenter(UP)
|
0 -> FaceCenter(UP)
|
||||||
3 -> EdgeInterpolateFallback(UP, EAST, 0.0)
|
3 -> EdgeInterpolateFallback(UP, EAST, 0.0)
|
||||||
else -> vertex.aoShader
|
else -> vertex.aoShader
|
||||||
})}
|
})}
|
||||||
|
.cycleVertices(if (nVidia) 0 else 1)
|
||||||
listOf(q1, q2).forEach { transform(it.setFlatShader(FaceFlat(UP))).add() }
|
listOf(q1, q2).forEach { transform(it.setFlatShader(FaceFlat(UP))).add() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ data class Quad(val v1: Vertex, val v2: Vertex, val v3: Vertex, val v4: Vertex)
|
|||||||
fun setFlatShader(shader: Shader) = transformVI { vertex, idx -> vertex.copy(flatShader = shader) }
|
fun setFlatShader(shader: Shader) = transformVI { vertex, idx -> vertex.copy(flatShader = shader) }
|
||||||
val flipped: Quad get() = Quad(v4, v3, v2, v1)
|
val flipped: Quad get() = Quad(v4, v3, v2, v1)
|
||||||
|
|
||||||
|
fun cycleVertices(n: Int) = when(n % 4) {
|
||||||
|
1 -> Quad(v2, v3, v4, v1)
|
||||||
|
2 -> Quad(v3, v4, v1, v2)
|
||||||
|
3 -> Quad(v4, v1, v2, v3)
|
||||||
|
else -> this.copy()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user