depth-tinting, depth, and height-fading render primitives fixed for anvil
This commit is contained in:
@@ -82,7 +82,7 @@ cave_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||||||
if ((getArrayShort3D(state->blocks, x, y, z) == 9) ||
|
if ((getArrayShort3D(state->blocks, x, y, z) == 9) ||
|
||||||
(get_data(state, BLOCKS, x, y+1, 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 */
|
/* go up and check for skylight */
|
||||||
if (get_data(state, SKYLIGHT, x, dy, z) != 0) {
|
if (get_data(state, SKYLIGHT, x, dy, z) != 0) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -46,16 +46,19 @@ depth_tinting_finish(void *data, RenderState *state) {
|
|||||||
static void
|
static void
|
||||||
depth_tinting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
depth_tinting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
||||||
RenderPrimitiveDepthTinting* self;
|
RenderPrimitiveDepthTinting* self;
|
||||||
int z, r, g, b;
|
int y, r, g, b;
|
||||||
self = (RenderPrimitiveDepthTinting *)data;
|
self = (RenderPrimitiveDepthTinting *)data;
|
||||||
|
|
||||||
z = state->z;
|
y = state->chunky * 16 + state->y;
|
||||||
r = 0, g = 0, b = 0;
|
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 */
|
/* get the colors and tint and tint */
|
||||||
r = PyInt_AsLong(PyList_GetItem(self->depth_colors, 0 + z*3));
|
r = PyInt_AsLong(PyList_GetItem(self->depth_colors, 0 + y*3));
|
||||||
g = PyInt_AsLong(PyList_GetItem(self->depth_colors, 1 + z*3));
|
g = PyInt_AsLong(PyList_GetItem(self->depth_colors, 1 + y*3));
|
||||||
b = PyInt_AsLong(PyList_GetItem(self->depth_colors, 2 + z*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);
|
tint_with_mask(state->img, r, g, b, 255, mask, state->imgx, state->imgy, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ depth_start(void *data, RenderState *state, PyObject *support) {
|
|||||||
static int
|
static int
|
||||||
depth_hidden(void *data, RenderState *state, int x, int y, int z) {
|
depth_hidden(void *data, RenderState *state, int x, int y, int z) {
|
||||||
PrimitiveDepth *self = (PrimitiveDepth *)data;
|
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 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -43,12 +43,16 @@ height_fading_finish(void *data, RenderState *state) {
|
|||||||
static void
|
static void
|
||||||
height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
||||||
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
||||||
|
int y = 16 * state->chunky + state->y;
|
||||||
|
|
||||||
/* do some height fading */
|
/* do some height fading */
|
||||||
PyObject *height_color = self->white_color;
|
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 */
|
/* 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) {
|
if (alpha < 0.0) {
|
||||||
alpha *= -1;
|
alpha *= -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user