always push shader metadata for block models
This commit is contained in:
@@ -46,11 +46,11 @@ object ShadersModIntegration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Quads rendered inside this block will behave as tallgrass blocks in shader programs. */
|
/** Quads rendered inside this block will use the given block entity data in shader programs. */
|
||||||
inline fun grass(renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) {
|
inline fun renderAs(blockEntityData: Long, renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) {
|
||||||
if ((isPresent && enabled)) {
|
if ((isPresent && enabled)) {
|
||||||
val vertexBuilder = Refs.sVertexBuilder.get(renderer)!!
|
val vertexBuilder = Refs.sVertexBuilder.get(renderer)!!
|
||||||
Refs.pushEntity_num.invoke(vertexBuilder, tallGrassEntityData)
|
Refs.pushEntity_num.invoke(vertexBuilder, blockEntityData)
|
||||||
func()
|
func()
|
||||||
Refs.popEntity.invoke(vertexBuilder)
|
Refs.popEntity.invoke(vertexBuilder)
|
||||||
} else {
|
} else {
|
||||||
@@ -58,15 +58,15 @@ object ShadersModIntegration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Quads rendered inside this block will use the given block entity data in shader programs. */
|
||||||
|
inline fun renderAs(state: IBlockState, renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) =
|
||||||
|
renderAs(entityDataFor(state), renderer, enabled, func)
|
||||||
|
|
||||||
|
/** Quads rendered inside this block will behave as tallgrass blocks in shader programs. */
|
||||||
|
inline fun grass(renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) =
|
||||||
|
renderAs(tallGrassEntityData, renderer, enabled, func)
|
||||||
|
|
||||||
/** Quads rendered inside this block will behave as leaf blocks in shader programs. */
|
/** Quads rendered inside this block will behave as leaf blocks in shader programs. */
|
||||||
inline fun leaves(renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) {
|
inline fun leaves(renderer: VertexBuffer, enabled: Boolean = true, func: ()->Unit) =
|
||||||
if ((isPresent && enabled)) {
|
renderAs(leavesEntityData, renderer, enabled, func)
|
||||||
val vertexBuilder = Refs.sVertexBuilder.get(renderer)!!
|
|
||||||
Refs.pushEntity_num.invoke(vertexBuilder, leavesEntityData.toLong())
|
|
||||||
func()
|
|
||||||
Refs.popEntity.invoke(vertexBuilder)
|
|
||||||
} else {
|
|
||||||
func()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mods.betterfoliage.client.render
|
|||||||
|
|
||||||
import mods.betterfoliage.client.config.BlockMatcher
|
import mods.betterfoliage.client.config.BlockMatcher
|
||||||
import mods.betterfoliage.client.integration.OptifineCTM
|
import mods.betterfoliage.client.integration.OptifineCTM
|
||||||
|
import mods.betterfoliage.client.integration.ShadersModIntegration
|
||||||
import mods.betterfoliage.client.render.AbstractRenderColumn.BlockType.*
|
import mods.betterfoliage.client.render.AbstractRenderColumn.BlockType.*
|
||||||
import mods.betterfoliage.client.render.AbstractRenderColumn.QuadrantType.*
|
import mods.betterfoliage.client.render.AbstractRenderColumn.QuadrantType.*
|
||||||
import mods.octarinecore.client.render.*
|
import mods.octarinecore.client.render.*
|
||||||
@@ -158,110 +159,111 @@ abstract class AbstractRenderColumn(modId: String) : AbstractBlockRenderingHandl
|
|||||||
val quadrantsBottom = Array(4) { SMALL_RADIUS }
|
val quadrantsBottom = Array(4) { SMALL_RADIUS }
|
||||||
if (downType == PARALLEL) quadrantsBottom.checkNeighbors(ctx, baseRotation, logAxis, -1)
|
if (downType == PARALLEL) quadrantsBottom.checkNeighbors(ctx, baseRotation, logAxis, -1)
|
||||||
|
|
||||||
quadrantRotations.forEachIndexed { idx, quadrantRotation ->
|
ShadersModIntegration.renderAs(ctx.blockState(Int3.zero), renderer) {
|
||||||
// set rotation for the current quadrant
|
quadrantRotations.forEachIndexed { idx, quadrantRotation ->
|
||||||
val rotation = baseRotation + quadrantRotation
|
// set rotation for the current quadrant
|
||||||
|
val rotation = baseRotation + quadrantRotation
|
||||||
|
|
||||||
// disallow sharp discontinuities in the chamfer radius, or tapering-in where inappropriate
|
// disallow sharp discontinuities in the chamfer radius, or tapering-in where inappropriate
|
||||||
if (quadrants[idx] == LARGE_RADIUS &&
|
if (quadrants[idx] == LARGE_RADIUS &&
|
||||||
upType == PARALLEL && quadrantsTop[idx] != LARGE_RADIUS &&
|
upType == PARALLEL && quadrantsTop[idx] != LARGE_RADIUS &&
|
||||||
downType == PARALLEL && quadrantsBottom[idx] != LARGE_RADIUS) {
|
downType == PARALLEL && quadrantsBottom[idx] != LARGE_RADIUS) {
|
||||||
quadrants[idx] = SMALL_RADIUS
|
quadrants[idx] = SMALL_RADIUS
|
||||||
}
|
}
|
||||||
|
|
||||||
// render side of current quadrant
|
// render side of current quadrant
|
||||||
val sideModel = when (quadrants[idx]) {
|
val sideModel = when (quadrants[idx]) {
|
||||||
SMALL_RADIUS -> sideRoundSmall.model
|
SMALL_RADIUS -> sideRoundSmall.model
|
||||||
LARGE_RADIUS -> if (upType == PARALLEL && quadrantsTop[idx] == SMALL_RADIUS) transitionTop.model
|
LARGE_RADIUS -> if (upType == PARALLEL && quadrantsTop[idx] == SMALL_RADIUS) transitionTop.model
|
||||||
else if (downType == PARALLEL && quadrantsBottom[idx] == SMALL_RADIUS) transitionBottom.model
|
else if (downType == PARALLEL && quadrantsBottom[idx] == SMALL_RADIUS) transitionBottom.model
|
||||||
else sideRoundLarge.model
|
else sideRoundLarge.model
|
||||||
SQUARE -> sideSquare.model
|
SQUARE -> sideSquare.model
|
||||||
else -> null
|
else -> null
|
||||||
}
|
|
||||||
|
|
||||||
if (sideModel != null) modelRenderer.render(
|
|
||||||
renderer,
|
|
||||||
sideModel,
|
|
||||||
rotation,
|
|
||||||
blockContext.blockCenter,
|
|
||||||
icon = columnTextures.side,
|
|
||||||
postProcess = noPost
|
|
||||||
)
|
|
||||||
|
|
||||||
// render top and bottom end of current quadrant
|
|
||||||
var upModel: Model? = null
|
|
||||||
var downModel: Model? = null
|
|
||||||
var upIcon = columnTextures.top
|
|
||||||
var downIcon = columnTextures.bottom
|
|
||||||
var isLidUp = true
|
|
||||||
var isLidDown = true
|
|
||||||
|
|
||||||
when (upType) {
|
|
||||||
NONSOLID -> upModel = flatTop(quadrants[idx])
|
|
||||||
PERPENDICULAR -> {
|
|
||||||
if (!connectPerpendicular) {
|
|
||||||
upModel = flatTop(quadrants[idx])
|
|
||||||
} else {
|
|
||||||
upIcon = columnTextures.side
|
|
||||||
upModel = extendTop(quadrants[idx])
|
|
||||||
isLidUp = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PARALLEL -> {
|
|
||||||
if (!continous(quadrants[idx], quadrantsTop[idx])) {
|
if (sideModel != null) modelRenderer.render(
|
||||||
if (quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE) {
|
renderer,
|
||||||
upModel = topSquare.model
|
sideModel,
|
||||||
|
rotation,
|
||||||
|
blockContext.blockCenter,
|
||||||
|
icon = columnTextures.side,
|
||||||
|
postProcess = noPost
|
||||||
|
)
|
||||||
|
|
||||||
|
// render top and bottom end of current quadrant
|
||||||
|
var upModel: Model? = null
|
||||||
|
var downModel: Model? = null
|
||||||
|
var upIcon = columnTextures.top
|
||||||
|
var downIcon = columnTextures.bottom
|
||||||
|
var isLidUp = true
|
||||||
|
var isLidDown = true
|
||||||
|
|
||||||
|
when (upType) {
|
||||||
|
NONSOLID -> upModel = flatTop(quadrants[idx])
|
||||||
|
PERPENDICULAR -> {
|
||||||
|
if (!connectPerpendicular) {
|
||||||
|
upModel = flatTop(quadrants[idx])
|
||||||
|
} else {
|
||||||
|
upIcon = columnTextures.side
|
||||||
|
upModel = extendTop(quadrants[idx])
|
||||||
|
isLidUp = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PARALLEL -> {
|
||||||
|
if (!continous(quadrants[idx], quadrantsTop[idx])) {
|
||||||
|
if (quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE) {
|
||||||
|
upModel = topSquare.model
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
when (downType) {
|
||||||
when (downType) {
|
NONSOLID -> downModel = flatBottom(quadrants[idx])
|
||||||
NONSOLID -> downModel = flatBottom(quadrants[idx])
|
PERPENDICULAR -> {
|
||||||
PERPENDICULAR -> {
|
if (!connectPerpendicular) {
|
||||||
if (!connectPerpendicular) {
|
downModel = flatBottom(quadrants[idx])
|
||||||
downModel = flatBottom(quadrants[idx])
|
} else {
|
||||||
} else {
|
downIcon = columnTextures.side
|
||||||
downIcon = columnTextures.side
|
downModel = extendBottom(quadrants[idx])
|
||||||
downModel = extendBottom(quadrants[idx])
|
isLidDown = false
|
||||||
isLidDown = false
|
}
|
||||||
|
}
|
||||||
|
PARALLEL -> {
|
||||||
|
if (!continous(quadrants[idx], quadrantsBottom[idx]) &&
|
||||||
|
(quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE)) {
|
||||||
|
downModel = bottomSquare.model
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PARALLEL -> {
|
|
||||||
if (!continous(quadrants[idx], quadrantsBottom[idx]) &&
|
|
||||||
(quadrants[idx] == SQUARE || quadrants[idx] == INVISIBLE)) {
|
|
||||||
downModel = bottomSquare.model
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (upModel != null) modelRenderer.render(
|
if (upModel != null) modelRenderer.render(
|
||||||
renderer,
|
renderer,
|
||||||
upModel,
|
upModel,
|
||||||
rotation,
|
rotation,
|
||||||
blockContext.blockCenter,
|
blockContext.blockCenter,
|
||||||
icon = upIcon,
|
icon = upIcon,
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
postProcess = { ctx, qi, q, vi, v ->
|
||||||
if (isLidUp) {
|
if (isLidUp) {
|
||||||
rotateUV(idx + if (logAxis == Axis.X) 1 else 0)
|
rotateUV(idx + if (logAxis == Axis.X) 1 else 0)
|
||||||
if (logAxis == Axis.X) mirrorUV(true, true)
|
if (logAxis == Axis.X) mirrorUV(true, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
)
|
if (downModel != null) modelRenderer.render(
|
||||||
if (downModel != null) modelRenderer.render(
|
renderer,
|
||||||
renderer,
|
downModel,
|
||||||
downModel,
|
rotation,
|
||||||
rotation,
|
blockContext.blockCenter,
|
||||||
blockContext.blockCenter,
|
icon = downIcon,
|
||||||
icon = downIcon,
|
postProcess = { ctx, qi, q, vi, v ->
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
if (isLidDown) {
|
||||||
if (isLidDown) {
|
rotateUV((if (logAxis == Axis.X) 0 else 3) - idx)
|
||||||
rotateUV((if (logAxis == Axis.X) 0 else 3) - idx)
|
if (logAxis != Axis.Y) mirrorUV(true, true)
|
||||||
if (logAxis != Axis.Y) mirrorUV(true, true)
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,18 +64,21 @@ class RenderGrass : AbstractBlockRenderingHandler(BetterFoliageMod.MOD_ID) {
|
|||||||
modelRenderer.updateShading(Int3.zero, allFaces)
|
modelRenderer.updateShading(Int3.zero, allFaces)
|
||||||
|
|
||||||
// render full grass block
|
// render full grass block
|
||||||
modelRenderer.render(
|
ShadersModIntegration.renderAs(ctx.blockState(Int3.zero), renderer) {
|
||||||
renderer,
|
modelRenderer.render(
|
||||||
fullCube,
|
renderer,
|
||||||
Rotation.identity,
|
fullCube,
|
||||||
ctx.blockCenter,
|
Rotation.identity,
|
||||||
icon = { ctx, qi, q -> grassTopTexture },
|
ctx.blockCenter,
|
||||||
postProcess = { ctx, qi, q, vi, v ->
|
icon = { ctx, qi, q -> grassTopTexture },
|
||||||
rotateUV(2)
|
postProcess = { ctx, qi, q, vi, v ->
|
||||||
if (isSnowed) { if(!ctx.aoEnabled) setGrey(1.4f) }
|
rotateUV(2)
|
||||||
else if (ctx.aoEnabled) multiplyColor(blockColor)
|
if (isSnowed) {
|
||||||
}
|
if (!ctx.aoEnabled) setGrey(1.4f)
|
||||||
)
|
} else if (ctx.aoEnabled) multiplyColor(blockColor)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
renderWorldBlockBase(ctx, dispatcher, renderer, null)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user