diff --git a/overviewer_core/src/primitives/cave.c b/overviewer_core/src/primitives/cave.c index a93b8ce..e899777 100644 --- a/overviewer_core/src/primitives/cave.c +++ b/overviewer_core/src/primitives/cave.c @@ -82,7 +82,7 @@ cave_hidden(void *data, RenderState *state, int x, int y, int z) { if ((getArrayShort3D(state->blocks, x, y, z) == 9) || (get_data(state, BLOCKS, x, y+1, z) == 9)) { - for (dy = y+1; dy < SECTIONS_PER_CHUNK * 16; dy++) { + for (dy = y+1; dy < (SECTIONS_PER_CHUNK - state->chunky) * 16; dy++) { /* go up and check for skylight */ if (get_data(state, SKYLIGHT, x, dy, z) != 0) { return 1; diff --git a/overviewer_core/src/primitives/depth-tinting.c b/overviewer_core/src/primitives/depth-tinting.c index 80d5226..99d068a 100644 --- a/overviewer_core/src/primitives/depth-tinting.c +++ b/overviewer_core/src/primitives/depth-tinting.c @@ -46,16 +46,19 @@ depth_tinting_finish(void *data, RenderState *state) { static void depth_tinting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) { RenderPrimitiveDepthTinting* self; - int z, r, g, b; + int y, r, g, b; self = (RenderPrimitiveDepthTinting *)data; - z = state->z; + y = state->chunky * 16 + state->y; r = 0, g = 0, b = 0; + + /* the colors array assumes y is between 0 and 127, so we scale it */ + y = (y * 128) / (16 * SECTIONS_PER_CHUNK); /* get the colors and tint and tint */ - r = PyInt_AsLong(PyList_GetItem(self->depth_colors, 0 + z*3)); - g = PyInt_AsLong(PyList_GetItem(self->depth_colors, 1 + z*3)); - b = PyInt_AsLong(PyList_GetItem(self->depth_colors, 2 + z*3)); + r = PyInt_AsLong(PyList_GetItem(self->depth_colors, 0 + y*3)); + g = PyInt_AsLong(PyList_GetItem(self->depth_colors, 1 + y*3)); + b = PyInt_AsLong(PyList_GetItem(self->depth_colors, 2 + y*3)); tint_with_mask(state->img, r, g, b, 255, mask, state->imgx, state->imgy, 0, 0); } diff --git a/overviewer_core/src/primitives/depth.c b/overviewer_core/src/primitives/depth.c index 87a14a6..26e6e71 100644 --- a/overviewer_core/src/primitives/depth.c +++ b/overviewer_core/src/primitives/depth.c @@ -37,7 +37,8 @@ depth_start(void *data, RenderState *state, PyObject *support) { static int depth_hidden(void *data, RenderState *state, int x, int y, int z) { PrimitiveDepth *self = (PrimitiveDepth *)data; - if (z > self->max || z < self->min) { + y += 16 * state->chunky; + if (y > self->max || y < self->min) { return 1; } return 0; diff --git a/overviewer_core/src/primitives/height-fading.c b/overviewer_core/src/primitives/height-fading.c index 589111e..2930d0a 100644 --- a/overviewer_core/src/primitives/height-fading.c +++ b/overviewer_core/src/primitives/height-fading.c @@ -43,12 +43,16 @@ height_fading_finish(void *data, RenderState *state) { static void height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) { PrimitiveHeightFading *self = (PrimitiveHeightFading *)data; + int y = 16 * state->chunky + state->y; /* do some height fading */ PyObject *height_color = self->white_color; + /* current formula requires y to be between 0 and 127, so scale it */ + y = (y * 128) / (16 * SECTIONS_PER_CHUNK); + /* negative alpha => darkness, positive => light */ - float alpha = (1.0 / (1 + expf((70 - state->z) / 11.0))) * 0.6 - 0.55; + float alpha = (1.0 / (1 + expf((70 - y) / 11.0))) * 0.6 - 0.55; if (alpha < 0.0) { alpha *= -1;