fixed & improved Round Log shading
This commit is contained in:
@@ -18,7 +18,8 @@ fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (
|
|||||||
listOf(
|
listOf(
|
||||||
verticalRectangle(x1 = 0.0, z1 = 0.5, x2 = 0.5 - radius, z2 = 0.5, yBottom = yBottom, yTop = yTop)
|
verticalRectangle(x1 = 0.0, z1 = 0.5, x2 = 0.5 - radius, z2 = 0.5, yBottom = yBottom, yTop = yTop)
|
||||||
.clampUV(minU = 0.0, maxU = 0.5 - radius)
|
.clampUV(minU = 0.0, maxU = 0.5 - radius)
|
||||||
.setAoShader(faceOrientedInterpolate(overrideFace = SOUTH)),
|
.setAoShader(faceOrientedInterpolate(overrideFace = SOUTH))
|
||||||
|
.setAoShader(faceOrientedAuto(corner = cornerAo(Axis.Y)), predicate = { v, vi -> vi == 1 || vi == 2}),
|
||||||
|
|
||||||
verticalRectangle(x1 = 0.5 - radius, z1 = 0.5, x2 = 0.5 - halfRadius, z2 = 0.5 - halfRadius, yBottom = yBottom, yTop = yTop)
|
verticalRectangle(x1 = 0.5 - radius, z1 = 0.5, x2 = 0.5 - halfRadius, z2 = 0.5 - halfRadius, yBottom = yBottom, yTop = yTop)
|
||||||
.clampUV(minU = 0.5 - radius)
|
.clampUV(minU = 0.5 - radius)
|
||||||
@@ -44,6 +45,7 @@ fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: (
|
|||||||
verticalRectangle(x1 = 0.5, z1 = 0.5 - radius, x2 = 0.5, z2 = 0.0, yBottom = yBottom, yTop = yTop)
|
verticalRectangle(x1 = 0.5, z1 = 0.5 - radius, x2 = 0.5, z2 = 0.0, yBottom = yBottom, yTop = yTop)
|
||||||
.clampUV(minU = radius - 0.5, maxU = 0.0)
|
.clampUV(minU = radius - 0.5, maxU = 0.0)
|
||||||
.setAoShader(faceOrientedInterpolate(overrideFace = EAST))
|
.setAoShader(faceOrientedInterpolate(overrideFace = EAST))
|
||||||
|
.setAoShader(faceOrientedAuto(corner = cornerAo(Axis.Y)), predicate = { v, vi -> vi == 0 || vi == 3})
|
||||||
).forEach { transform(it.setFlatShader(FaceFlat(EAST))).add() }
|
).forEach { transform(it.setFlatShader(FaceFlat(EAST))).add() }
|
||||||
|
|
||||||
quads.exchange(1, 2)
|
quads.exchange(1, 2)
|
||||||
@@ -64,7 +66,7 @@ fun Model.columnSideSquare(yBottom: Double, yTop: Double, transform: (Quad) -> Q
|
|||||||
verticalRectangle(x1 = 0.5, z1 = 0.5, x2 = 0.5, z2 = 0.0, yBottom = yBottom, yTop = yTop)
|
verticalRectangle(x1 = 0.5, z1 = 0.5, x2 = 0.5, z2 = 0.0, yBottom = yBottom, yTop = yTop)
|
||||||
.clampUV(maxU = 0.0)
|
.clampUV(maxU = 0.0)
|
||||||
.setAoShader(faceOrientedInterpolate(overrideFace = EAST))
|
.setAoShader(faceOrientedInterpolate(overrideFace = EAST))
|
||||||
.setAoShader(faceOrientedAuto(corner = cornerAo(Axis.Y)), predicate = { v, vi -> vi == 1 || vi == 2})
|
.setAoShader(faceOrientedAuto(corner = cornerAo(Axis.Y)), predicate = { v, vi -> vi == 0 || vi == 3})
|
||||||
).forEach {
|
).forEach {
|
||||||
transform(it.setFlatShader(faceOrientedAuto(corner = cornerFlat))).add()
|
transform(it.setFlatShader(faceOrientedAuto(corner = cornerFlat))).add()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,19 @@ fun brSum(multiplier: Float?, vararg brightness: Int): Int {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun brWeighted(br1: Int, weight1: Float, br2: Int, weight2: Float): Int {
|
||||||
|
val w1int = (weight1 * 256.0f + 0.5f).toInt()
|
||||||
|
val w2int = (weight2 * 256.0f + 0.5f).toInt()
|
||||||
|
var result = 0
|
||||||
|
brightnessComponents.forEachIndexed { idx, shift ->
|
||||||
|
val comp1 = (br1 shr shift) and 15
|
||||||
|
val comp2 = (br2 shr shift) and 15
|
||||||
|
val compWeighted = (comp1 * w1int + comp2 * w2int) / 256
|
||||||
|
result = result or ((compWeighted and 15) shl shift)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
data class HSB(var hue: Float, var saturation: Float, var brightness: Float) {
|
data class HSB(var hue: Float, var saturation: Float, var brightness: Float) {
|
||||||
companion object {
|
companion object {
|
||||||
fun fromColor(color: Int): HSB {
|
fun fromColor(color: Int): HSB {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ interface Shader {
|
|||||||
red = min(shading1.red * weight1 + shading2.red * weight2, 1.0f)
|
red = min(shading1.red * weight1 + shading2.red * weight2, 1.0f)
|
||||||
green = min(shading1.green * weight1 + shading2.green * weight2, 1.0f)
|
green = min(shading1.green * weight1 + shading2.green * weight2, 1.0f)
|
||||||
blue = min(shading1.blue * weight1 + shading2.blue * weight2, 1.0f)
|
blue = min(shading1.blue * weight1 + shading2.blue * weight2, 1.0f)
|
||||||
brightness = brSum(null, shading1.brightness brMul weight1, shading2.brightness brMul weight2)
|
brightness = brWeighted(shading1.brightness, weight1, shading2.brightness, weight2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user