Incredibly brutal fix for blocks (e.g. slabs, stairs) with useNeighborBrightness

What this flag does is make the block report its brightest neighbor's light as its own for rendering purposes, since these blocks are technically opaque but still expose that face of their neighbors.

Next, fix up face culling
This commit is contained in:
David Vierra 2015-07-14 22:10:15 -10:00
parent 79354dd690
commit 7c05881a8e
2 changed files with 43 additions and 15 deletions

View File

@ -385,49 +385,72 @@ class SectionUpdate(object):
chunkWidth, chunkLength, chunkHeight = self.Blocks.shape
areaLights = numpy.empty((chunkWidth + 2, chunkLength + 2, chunkHeight + 2), numpy.uint8)
areaLights = numpy.empty((chunkWidth + 4, chunkLength + 4, chunkHeight + 4), numpy.uint8)
if lightName == "SkyLight":
default = 15
else:
default = 0
areaLights[(0, -1), :, :] = default
areaLights[:, (0, -1), :] = default
areaLights[:, :, (0, -1)] = default
areaLights[(0, 1, -2, -1), :, :] = default
areaLights[:, (0, 1, -2, -1), :] = default
areaLights[:, :, (0, 1, -2, -1)] = default
areaLights[1:-1, 1:-1, 1:-1] = Light(chunkSection)
areaLights[2:-2, 2:-2, 2:-2] = Light(chunkSection)
y = chunkSection.Y
if faces.FaceXDecreasing in neighboringChunks:
ncs = neighboringChunks[faces.FaceXDecreasing].getSection(y)
if ncs:
areaLights[1:-1, 1:-1, :1] = Light(ncs)[:, :, -1:]
areaLights[2:-2, 2:-2, :2] = Light(ncs)[:, :, -2:]
if faces.FaceXIncreasing in neighboringChunks:
ncs = neighboringChunks[faces.FaceXIncreasing].getSection(y)
if ncs:
areaLights[1:-1, 1:-1, -1:] = Light(ncs)[:, :, :1]
areaLights[2:-2, 2:-2, -2:] = Light(ncs)[:, :, :2]
if faces.FaceZDecreasing in neighboringChunks:
ncs = neighboringChunks[faces.FaceZDecreasing].getSection(y)
if ncs:
areaLights[1:-1, :1, 1:-1] = Light(ncs)[:, -1:, :]
areaLights[2:-2, :2, 2:-2] = Light(ncs)[:, -2:, :]
if faces.FaceZIncreasing in neighboringChunks:
ncs = neighboringChunks[faces.FaceZIncreasing].getSection(y)
if ncs:
areaLights[1:-1, -1:, 1:-1] = Light(ncs)[:, :1, :]
areaLights[2:-2, -2:, 2:-2] = Light(ncs)[:, :2, :]
above = self.chunkUpdate.chunk.getSection(y + 1)
above = self.chunkUpdate.chunk.getSection(y + 2)
if above:
areaLights[-1:, 1:-1, 1:-1] = Light(above)[:1, :, :]
areaLights[-2:, 2:-2, 2:-2] = Light(above)[:2, :, :]
below = self.chunkUpdate.chunk.getSection(y + 1)
below = self.chunkUpdate.chunk.getSection(y + 2)
if below:
areaLights[:1, 1:-1, 1:-1, ] = Light(below)[-1:, :, :]
areaLights[:2, 2:-2, 2:-2, ] = Light(below)[-2:, :, :]
return areaLights
nx, ny, nz = self.blocktypes.useNeighborBrightness[self.areaBlocks].nonzero()
nxd = nx
nx = nx + 1
nxi = nx + 1
nyd = ny
ny = ny + 1
nyi = ny + 1
nzd = nz
nz = nz + 1
nzi = nz + 1
neighborBrightness = [
areaLights[nxi, ny, nz],
areaLights[nxd, ny, nz],
areaLights[nx, nyi, nz],
areaLights[nx, nyd, nz],
areaLights[nx, ny, nzi],
areaLights[nx, ny, nzd],
]
neighborBrightness = numpy.amax(neighborBrightness, 0)
areaLights[nx, ny, nz] = neighborBrightness
return areaLights[1:-1, 1:-1, 1:-1]
@lazyprop
def areaBlockLights(self):

View File

@ -92,10 +92,15 @@ class BlockTypeSet(object):
'unknown': False, # False for blocks loaded from builtin .json, True for FML IDs, False for blocks configured in editor
'color': 0xffffff,
'biomeTintType': None, # "grass", "leaves", or None
'useNeighborBrightness': False,
}
self.aka = defaultdict(lambda: "")
self.useNeighborBrightness = numpy.zeros(id_limit, dtype='uint8')
self.useNeighborBrightness[:] = self.defaults['useNeighborBrightness']
self.brightness = numpy.zeros(id_limit, dtype='uint8')
self.brightness[:] = self.defaults['brightness']
self.opacity = numpy.zeros(id_limit, dtype='uint8')
@ -300,11 +305,11 @@ class BlockTypeSet(object):
if blockJson.get("defaultState"):
self.defaultBlockstates[internalName] = blockState
for key in [
'opaqueCube',
'brightness',
'opacity',
'useNeighborBrightness',
]: # does not have data axis
if key in blockJson:
array = getattr(self, key)