Compare commits
4 Commits
1.16.5-For
...
1.15.2-For
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fae9e9dfa9 | ||
|
|
512cd786f7 | ||
|
|
b96a17fdb9 | ||
|
|
3d78ecce22 |
@@ -4,7 +4,7 @@ org.gradle.daemon=false
|
||||
group = com.github.octarine-noise
|
||||
jarName = BetterFoliage-Forge
|
||||
|
||||
version = 2.6.1
|
||||
version = 2.6.3
|
||||
|
||||
mcVersion = 1.15.2
|
||||
forgeVersion = 31.2.44
|
||||
|
||||
@@ -77,6 +77,13 @@ object CustomColors : ClassRef<Any>("net.optifine.CustomColors") {
|
||||
}
|
||||
|
||||
// Optifine shaders
|
||||
object Shaders : ClassRef<Any>("net.optifine.shaders.Shaders") {
|
||||
val shaderPackLoaded = FieldRef(this, "shaderPackLoaded", boolean)
|
||||
val blockLightLevel05 = FieldRef(this, "blockLightLevel05", float)
|
||||
val blockLightLevel06 = FieldRef(this, "blockLightLevel06", float)
|
||||
val blockLightLevel08 = FieldRef(this, "blockLightLevel08", float)
|
||||
}
|
||||
|
||||
object SVertexBuilder : ClassRef<Any>("net.optifine.shaders.SVertexBuilder") {
|
||||
val pushState = MethodRef(this, "pushEntity", void, long)
|
||||
val popState = MethodRef(this, "popEntity", void)
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
package mods.betterfoliage.integration
|
||||
|
||||
import mods.betterfoliage.config.BlockConfig
|
||||
import mods.betterfoliage.render.pipeline.RenderCtxBase
|
||||
import mods.betterfoliage.render.pipeline.RenderCtxForge
|
||||
import mods.betterfoliage.render.pipeline.RenderCtxVanilla
|
||||
import mods.betterfoliage.resource.discovery.BakeWrapperManager
|
||||
import mods.betterfoliage.util.HasLogger
|
||||
import mods.betterfoliage.util.allAvailable
|
||||
import mods.betterfoliage.util.get
|
||||
import mods.betterfoliage.util.mapArray
|
||||
import mods.octarinecore.*
|
||||
import net.minecraft.block.BlockRenderType
|
||||
import net.minecraft.block.BlockRenderType.MODEL
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.block.Blocks
|
||||
import net.minecraft.client.renderer.BufferBuilder
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Direction.DOWN
|
||||
import net.minecraft.util.Direction.EAST
|
||||
import net.minecraft.util.Direction.NORTH
|
||||
import net.minecraft.util.Direction.SOUTH
|
||||
import net.minecraft.util.Direction.WEST
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.ILightReader
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil
|
||||
import org.apache.logging.log4j.Level.INFO
|
||||
|
||||
/**
|
||||
* Integration for ShadersMod.
|
||||
*/
|
||||
object ShadersModIntegration : HasLogger() {
|
||||
@JvmStatic val isAvailable = allAvailable(SVertexBuilder, SVertexBuilder.pushState, SVertexBuilder.popState, BlockAliases.getAliasBlockId)
|
||||
@JvmStatic val isEffectsAvailable = allAvailable(SVertexBuilder.pushState, SVertexBuilder.popState, BlockAliases.getAliasBlockId)
|
||||
@JvmStatic val isDiffuseAvailable = allAvailable(Shaders.shaderPackLoaded, Shaders.blockLightLevel05, Shaders.blockLightLevel06, Shaders.blockLightLevel08)
|
||||
|
||||
val defaultLeaves = Blocks.OAK_LEAVES.defaultState
|
||||
val defaultGrass = Blocks.GRASS.defaultState
|
||||
@JvmStatic val defaultLeaves = Blocks.OAK_LEAVES.defaultState!!
|
||||
@JvmStatic val defaultGrass = Blocks.GRASS.defaultState!!
|
||||
|
||||
@JvmStatic var diffuseShades = Direction.values().mapArray { LightUtil.diffuseLight(it) }
|
||||
|
||||
/**
|
||||
* Called from transformed ShadersMod code.
|
||||
@@ -37,12 +47,29 @@ object ShadersModIntegration : HasLogger() {
|
||||
}
|
||||
|
||||
init {
|
||||
logger.log(INFO, "ShadersMod integration is ${if (isAvailable) "enabled" else "disabled" }")
|
||||
logger.log(INFO, "ShadersMod diffuse shading integration is ${if (isDiffuseAvailable) "enabled" else "disabled" }")
|
||||
logger.log(INFO, "ShadersMod vertex shader integration is ${if (isEffectsAvailable) "enabled" else "disabled" }")
|
||||
|
||||
// Recalculate the diffsuse shading values used when resources are reloaded
|
||||
if (isDiffuseAvailable) BakeWrapperManager.onInvalidate {
|
||||
if (Shaders.shaderPackLoaded.getStatic()) {
|
||||
diffuseShades = Direction.values().mapArray { face ->
|
||||
when(face) {
|
||||
DOWN -> Shaders.blockLightLevel05.getStatic()
|
||||
WEST, EAST -> Shaders.blockLightLevel06.getStatic()
|
||||
NORTH, SOUTH -> Shaders.blockLightLevel08.getStatic()
|
||||
else -> LightUtil.diffuseLight(face)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
diffuseShades = Direction.values().mapArray { LightUtil.diffuseLight(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Quads rendered inside this block will use the given block entity data in shader programs. */
|
||||
inline fun renderAs(buffer: BufferBuilder, state: BlockState, renderType: BlockRenderType, enabled: Boolean = true, func: ()->Unit) {
|
||||
if (isAvailable && enabled) {
|
||||
if (isEffectsAvailable && enabled) {
|
||||
val aliasBlockId = BlockAliases.getAliasBlockId.invokeStatic(state)
|
||||
val sVertexBuilder = buffer[BufferBuilder_sVertexBuilder]
|
||||
SVertexBuilder.pushState.invoke(sVertexBuilder, aliasBlockId)
|
||||
|
||||
@@ -96,9 +96,9 @@ fun Array<List<Quad>>.bake(applyDiffuseLighting: Boolean) = mapArray { it.bake(a
|
||||
fun BakedQuad.unbake(): HalfBakedQuad {
|
||||
val size = DefaultVertexFormats.BLOCK.integerSize
|
||||
val verts = Array(4) { vIdx ->
|
||||
val x = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 0])
|
||||
val y = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 1])
|
||||
val z = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 2])
|
||||
val x = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 0]) - 0.5f
|
||||
val y = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 1]) - 0.5f
|
||||
val z = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 2]) - 0.5f
|
||||
val color = vertexData[vIdx * size + 3]
|
||||
val u = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 4])
|
||||
val v = java.lang.Float.intBitsToFloat(vertexData[vIdx * size + 5])
|
||||
|
||||
@@ -23,6 +23,10 @@ data class LightingData(
|
||||
}
|
||||
}
|
||||
|
||||
// Vanilla has a very suspicious-looking offset here, which Indigo gets rid of and calls it a fix
|
||||
// Naturally, we're going to believe Indigo, it's a hardcoded option for now
|
||||
const val OCCLUSION_OFFSET_FIX = true
|
||||
|
||||
/**
|
||||
* Replacement for [BlockModelRenderer.AmbientOcclusionFace]
|
||||
* This gets called on a LOT, so object instantiation is avoided.
|
||||
@@ -87,9 +91,9 @@ class VanillaAoCalculator {
|
||||
sideHelper.sides.forEachIndexed { sideIdx, sideDir ->
|
||||
// record light data in the block 1 step to the side
|
||||
probe.position { setPos(lightOrigin).move(sideDir) }.writeTo(sideAo[sideIdx])
|
||||
// side is considered occluded if the block 1 step to that side and
|
||||
// 1 step forward (in the lightface direction) is not fully transparent
|
||||
isOccluded[sideIdx] = probe.position { move(lightFace) }.isNonTransparent
|
||||
// side is considered occluded if the block 1 step to that side is not fully transparent
|
||||
if (!OCCLUSION_OFFSET_FIX) probe.position { move(lightFace) }
|
||||
isOccluded[sideIdx] = probe.isNonTransparent
|
||||
}
|
||||
|
||||
// AO Calculation for the 4 corners
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package mods.betterfoliage.render.lighting
|
||||
|
||||
import mods.betterfoliage.integration.ShadersModIntegration
|
||||
import mods.betterfoliage.model.HalfBakedQuad
|
||||
import mods.betterfoliage.util.Double3
|
||||
import mods.betterfoliage.util.EPSILON_ONE
|
||||
import mods.betterfoliage.util.EPSILON_ZERO
|
||||
import mods.betterfoliage.util.get
|
||||
import mods.betterfoliage.util.minBy
|
||||
import net.minecraft.client.renderer.color.BlockColors
|
||||
import net.minecraft.util.Direction
|
||||
import net.minecraft.util.Direction.*
|
||||
import net.minecraft.util.Direction.Axis
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil
|
||||
import kotlin.math.abs
|
||||
|
||||
class VanillaQuadLighting {
|
||||
@@ -34,7 +34,7 @@ class VanillaQuadLighting {
|
||||
}
|
||||
|
||||
fun applyDiffuseLighting(face: Direction) {
|
||||
val factor = LightUtil.diffuseLight(face)
|
||||
val factor = ShadersModIntegration.diffuseShades[face]
|
||||
tint[0] *= factor; tint[1] *= factor; tint[2] *= factor
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
#public net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace
|
||||
#public net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace <init>
|
||||
#public net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace field_178206_b #vertexColorMultiplier
|
||||
#public net.minecraft.client.renderer.BlockModelRenderer$AmbientOcclusionFace field_178207_c #vertexBrightness
|
||||
|
||||
#public net.minecraft.block.BlockState$Cache
|
||||
|
||||
public net.minecraft.client.renderer.chunk.ChunkRenderCache field_212408_i #world
|
||||
|
||||
#public net.minecraft.client.renderer.texture.AtlasTexture$SheetData field_217808_d # sprites
|
||||
|
||||
public net.minecraft.client.renderer.BlockModelRenderer$Cache
|
||||
public net.minecraft.client.renderer.BlockModelRenderer field_210267_b
|
||||
public net.minecraft.client.renderer.BlockModelRenderer field_187499_a
|
||||
public net.minecraft.client.renderer.BlockModelRenderer field_187499_a
|
||||
|
||||
Reference in New Issue
Block a user