From d1480ed3be8552bd191639b7f893920eb6007646 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Sat, 30 Jan 2016 00:46:15 +0100 Subject: [PATCH 1/4] improved Log block axis detection --- .../betterfoliage/client/render/AbstractRenderColumn.kt | 6 +++--- .../kotlin/mods/betterfoliage/client/render/RenderLog.kt | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt index 4df4e03..a605633 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/AbstractRenderColumn.kt @@ -116,7 +116,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl inline fun continous(q1: QuadrantType, q2: QuadrantType) = q1 == q2 || ((q1 == SQUARE || q1 == INVISIBLE) && (q2 == SQUARE || q2 == INVISIBLE)) - abstract val axisFunc: (IBlockState)->EnumFacing.Axis + abstract val axisFunc: (IBlockState)->EnumFacing.Axis? abstract val blockPredicate: (IBlockState)->Boolean abstract val sideTexture: (ShadingContext, Int, Quad)->TextureAtlasSprite? @@ -131,7 +131,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl modelRenderer.updateShading(Int3.zero, allFaces) // check log neighborhood - val logAxis = ctx.blockAxis + val logAxis = ctx.blockAxis ?: return renderWorldBlockBase(ctx, dispatcher, renderer, layer) val baseRotation = rotationFromUp[(logAxis to AxisDirection.POSITIVE).face.ordinal] val upType = ctx.blockType(baseRotation, logAxis, Int3(0, 1, 0)) @@ -314,7 +314,7 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl } /** Get the axis of the block */ - val BlockContext.blockAxis: Axis get() = axisFunc(blockState(Int3.zero)) + val BlockContext.blockAxis: Axis? get() = axisFunc(blockState(Int3.zero)) /** * Get the type of the block at the given offset in a rotated reference frame. diff --git a/src/main/kotlin/mods/betterfoliage/client/render/RenderLog.kt b/src/main/kotlin/mods/betterfoliage/client/render/RenderLog.kt index f0d1bf4..e78d04c 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/RenderLog.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/RenderLog.kt @@ -22,11 +22,13 @@ class RenderLog : AbstractRenderColumn(BetterFoliageMod.MOD_ID) { Config.blocks.logs.matchesID(ctx.block) override var axisFunc = { state: IBlockState -> - val axis = tryDefault("none") { state.getValue(BlockLog.LOG_AXIS).toString() } + val axis = tryDefault(null) { state.getValue(BlockLog.LOG_AXIS).toString() } ?: + state.properties.entries.find { it.key.getName().toLowerCase() == "axis" }?.let { it.value.toString() } when (axis) { "x" -> Axis.X + "y" -> Axis.Y "z" -> Axis.Z - else -> Axis.Y + else -> null } } From 5616a68f5a7662cb6cdff3596fb9d5a24ef776f9 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Sat, 30 Jan 2016 00:49:59 +0100 Subject: [PATCH 2/4] changed Kotlin version --- .gitignore | 1 + build.gradle | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fc6f264..ac0dc65 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ run/ .gradle/ build/ +classes/ diff --git a/build.gradle b/build.gradle index 1fac089..b17aada 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ version = "2.0.3" archivesBaseName = rootProject.name + '-MC1.8' buildscript { - ext.kotlin_version = '1.0.0-beta-4584' + ext.kotlin_version = '1.0.0-beta-4589' repositories { mavenCentral() maven { @@ -34,6 +34,7 @@ dependencies { minecraft { version = '1.8-11.14.4.1563' mappings = 'stable_18' + runDir = 'run' } processResources { From 4720667f53bfd62e142adc45a5b4fd36a93785a9 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Sat, 30 Jan 2016 00:52:35 +0100 Subject: [PATCH 3/4] updated Thaumcraft Log block class --- src/main/resources/assets/betterfoliage/LogDefault.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/betterfoliage/LogDefault.cfg b/src/main/resources/assets/betterfoliage/LogDefault.cfg index 14c2403..c060056 100644 --- a/src/main/resources/assets/betterfoliage/LogDefault.cfg +++ b/src/main/resources/assets/betterfoliage/LogDefault.cfg @@ -10,7 +10,7 @@ mods.natura.blocks.trees.LogTwoxTwo mods.natura.blocks.trees.SimpleLog // Thaumcraft -thaumcraft.common.blocks.BlockMagicalLog +thaumcraft.common.blocks.world.plants.BlockLogsTC // Forestry forestry.arboriculture.gadgets.BlockLog From 3e6f98885f2b4d2f71553a49dee7a39b168f7063 Mon Sep 17 00:00:00 2001 From: octarine-noise Date: Sat, 30 Jan 2016 00:56:33 +0100 Subject: [PATCH 4/4] fixed & improved Round Log shading --- .../mods/betterfoliage/client/render/ModelColumn.kt | 6 ++++-- .../mods/octarinecore/client/render/PixelFormat.kt | 13 +++++++++++++ .../mods/octarinecore/client/render/Shading.kt | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/mods/betterfoliage/client/render/ModelColumn.kt b/src/main/kotlin/mods/betterfoliage/client/render/ModelColumn.kt index 4030e1c..7ff2bdc 100644 --- a/src/main/kotlin/mods/betterfoliage/client/render/ModelColumn.kt +++ b/src/main/kotlin/mods/betterfoliage/client/render/ModelColumn.kt @@ -18,7 +18,8 @@ fun Model.columnSide(radius: Double, yBottom: Double, yTop: Double, transform: ( listOf( 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) - .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) .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) .clampUV(minU = radius - 0.5, maxU = 0.0) .setAoShader(faceOrientedInterpolate(overrideFace = EAST)) + .setAoShader(faceOrientedAuto(corner = cornerAo(Axis.Y)), predicate = { v, vi -> vi == 0 || vi == 3}) ).forEach { transform(it.setFlatShader(FaceFlat(EAST))).add() } 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) .clampUV(maxU = 0.0) .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 { transform(it.setFlatShader(faceOrientedAuto(corner = cornerFlat))).add() } diff --git a/src/main/kotlin/mods/octarinecore/client/render/PixelFormat.kt b/src/main/kotlin/mods/octarinecore/client/render/PixelFormat.kt index bc4e58a..6ad2024 100644 --- a/src/main/kotlin/mods/octarinecore/client/render/PixelFormat.kt +++ b/src/main/kotlin/mods/octarinecore/client/render/PixelFormat.kt @@ -45,6 +45,19 @@ fun brSum(multiplier: Float?, vararg brightness: Int): Int { 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) { companion object { fun fromColor(color: Int): HSB { diff --git a/src/main/kotlin/mods/octarinecore/client/render/Shading.kt b/src/main/kotlin/mods/octarinecore/client/render/Shading.kt index c08fa15..e3e1e4b 100644 --- a/src/main/kotlin/mods/octarinecore/client/render/Shading.kt +++ b/src/main/kotlin/mods/octarinecore/client/render/Shading.kt @@ -106,7 +106,7 @@ interface Shader { red = min(shading1.red * weight1 + shading2.red * weight2, 1.0f) green = min(shading1.green * weight1 + shading2.green * 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) } /**