From f7e18675886d664d8ef8574387f3d9986babca07 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 3 Aug 2011 10:43:31 +0200 Subject: [PATCH 1/3] Fix one more time the how water is lit. Added ancildata and pseudo_ancildata to the renderstate. Added special case for water in rendermode_ligting_draw(). --- overviewer_core/src/iterate.c | 4 ++++ overviewer_core/src/overviewer.h | 2 ++ overviewer_core/src/rendermode-lighting.c | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/overviewer_core/src/iterate.c b/overviewer_core/src/iterate.c index 5639ae9..f28b41a 100644 --- a/overviewer_core/src/iterate.c +++ b/overviewer_core/src/iterate.c @@ -412,11 +412,15 @@ chunk_render(PyObject *self, PyObject *args) { PyObject *tmp; unsigned char ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z); + state.block_data = ancilData; if ((state.block == 2) || (state.block == 9) || (state.block == 20) || (state.block == 54) || (state.block == 55) || (state.block == 85) || (state.block == 90)) { ancilData = generate_pseudo_data(&state, ancilData); + state.block_pdata = ancilData; + } else { + state.block_pdata = 0; } tmp = PyTuple_New(2); diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index a0c5316..e7057e7 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -70,6 +70,8 @@ typedef struct { /* the block position and type, and the block array */ int x, y, z; unsigned char block; + unsigned char block_data; + unsigned char block_pdata; PyObject *blockdata_expanded; PyObject *blocks; PyObject *up_left_blocks; diff --git a/overviewer_core/src/rendermode-lighting.c b/overviewer_core/src/rendermode-lighting.c index c515db5..8e073ec 100644 --- a/overviewer_core/src/rendermode-lighting.c +++ b/overviewer_core/src/rendermode-lighting.c @@ -293,7 +293,20 @@ rendermode_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject self = (RenderModeLighting *)data; x = state->x, y = state->y, z = state->z; - if (is_transparent(state->block)) { + if (state->block == 9) { /* special case for water */ + /* looks like we need a new case for lighting, there are + * blocks that are transparent and need per-face shading + * if the face is drawn. */ + if ((state->block_pdata & 16) == 16) { + do_shading_with_mask(self, state, x, y, z+1, self->facemasks[0]); + } + if ((state->block_pdata & 2) == 2) { /* bottom left */ + do_shading_with_mask(self, state, x-1, y, z, self->facemasks[1]); + } + if ((state->block_pdata & 4) == 4) { /* bottom right */ + do_shading_with_mask(self, state, x, y+1, z, self->facemasks[2]); + } + } else if (is_transparent(state->block)) { /* transparent: do shading on whole block */ do_shading_with_mask(self, state, x, y, z, mask_light); } else { From a2b156c85f305f4e99024e28f05ce76d6c1bc990 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 3 Aug 2011 11:04:03 +0200 Subject: [PATCH 2/3] Draw ice in the same way is done with water and glass and shade it like water. --- overviewer_core/src/iterate.c | 9 ++++++--- overviewer_core/src/rendermode-lighting.c | 2 +- overviewer_core/textures.py | 17 ++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/overviewer_core/src/iterate.c b/overviewer_core/src/iterate.c index f28b41a..42fac6d 100644 --- a/overviewer_core/src/iterate.c +++ b/overviewer_core/src/iterate.c @@ -174,7 +174,7 @@ generate_pseudo_data(RenderState *state, unsigned char ancilData) { data = (check_adjacent_blocks(state, x, y, z, state->block) ^ 0x0f); return data; } - } else if (state->block == 20) { /* glass */ + } else if ((state->block == 20) || (state->block == 79)) { /* glass and ice */ /* an aditional bit for top is added to the 4 bits of check_adjacent_blocks */ if ((z != 127) && (getArrayByte3D(state->blocks, x, y, z+1) == 20)) { data = 0; @@ -413,10 +413,13 @@ chunk_render(PyObject *self, PyObject *args) { unsigned char ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z); state.block_data = ancilData; + /* block that need pseudo ancildata: + * grass, water, glass, chest, restone wire, + * ice, fence and portal. */ if ((state.block == 2) || (state.block == 9) || (state.block == 20) || (state.block == 54) || - (state.block == 55) || (state.block == 85) || - (state.block == 90)) { + (state.block == 55) || (state.block == 79) || + (state.block == 85) || (state.block == 90)) { ancilData = generate_pseudo_data(&state, ancilData); state.block_pdata = ancilData; } else { diff --git a/overviewer_core/src/rendermode-lighting.c b/overviewer_core/src/rendermode-lighting.c index 8e073ec..37acf03 100644 --- a/overviewer_core/src/rendermode-lighting.c +++ b/overviewer_core/src/rendermode-lighting.c @@ -293,7 +293,7 @@ rendermode_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject self = (RenderModeLighting *)data; x = state->x, y = state->y, z = state->z; - if (state->block == 9) { /* special case for water */ + if ((state->block == 9) || (state->block == 79)) { /* special case for water and ice */ /* looks like we need a new case for lighting, there are * blocks that are transparent and need per-face shading * if the face is drawn. */ diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 77901ef..c6ad4a1 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -431,7 +431,7 @@ def _build_blockimages(): # 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 36, 37, -1, -1, 65, -1, -1, -1, 50, 24, -1, -1, 86, -1, -1, -1, # 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 - -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, 67, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, -1, # 80 81 82 83 84 85 86 87 88 89 90 91 66, 69, 72, 73, 75, -1,102,103,104,105,-1, 102 # clay? ] @@ -448,7 +448,7 @@ def _build_blockimages(): # 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 36, 37, -1, -1, 65, -1, -1,101, 50, 24, -1, -1, 86, -1, -1, -1, # 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 - -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, 67, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, -1, # 80 81 82 83 84 85 86 87 88 89 90 91 66, 70, 72, 73, 74,-1 ,118,103,104,105, -1, 118 ] @@ -551,12 +551,14 @@ def generate_special_texture(blockID, data): return generate_texture_tuple(img, blockID) - if blockID == 9 or blockID == 20: # spring water, flowing water and waterfall water, AND glass - # water and glass share the way to be rendered + if blockID == 9 or blockID == 20 or blockID == 79: # spring water, flowing water and waterfall water, AND glass, AND ice + # water,glass and ice share the way to be rendered if blockID == 9: texture = _load_image("water.png") - else: + elif blockID == 20: texture = terrain_images[49] + else: + texture = terrain_images[67] if (data & 0b10000) == 16: top = texture @@ -1749,8 +1751,8 @@ def getBiomeData(worlddir, chunkX, chunkY): special_blocks = set([ 2, 6, 9, 17, 18, 20, 26, 23, 27, 28, 29, 31, 33, 34, 35, 43, 44, 50, 51, 53, 54, 55, 58, 59, 61, 62, - 63, 64, 65, 66, 67, 68, 71, 75, 76, 85, 86, 90, 91, - 92, 93, 94, 96]) + 63, 64, 65, 66, 67, 68, 71, 75, 76, 79, 85, 86, 90, + 91, 92, 93, 94, 96]) # this is a map of special blockIDs to a list of all # possible values for ancillary data that it might have. @@ -1789,6 +1791,7 @@ special_map[68] = (2,3,4,5) # wall sing, orientation special_map[71] = range(16) # iron door, open/close and orientation special_map[75] = (1,2,3,4,5) # off redstone torch, orientation special_map[76] = (1,2,3,4,5) # on redstone torch, orientation +special_map[79] = range(32) # ice, used to only render the exterior surface, uses pseudo data special_map[85] = range(17) # fences, all the possible combination, uses pseudo data special_map[86] = range(5) # pumpkin, orientation special_map[90] = (1,2,4,8) # portal, in 2 orientations, 4 cases, uses pseudo data From b86906b931d84cc1aadb1074b06765ab9e0169d6 Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Wed, 3 Aug 2011 11:22:25 +0200 Subject: [PATCH 3/3] Use per-face shading for leave block. --- overviewer_core/src/rendermode-lighting.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/overviewer_core/src/rendermode-lighting.c b/overviewer_core/src/rendermode-lighting.c index 37acf03..057331a 100644 --- a/overviewer_core/src/rendermode-lighting.c +++ b/overviewer_core/src/rendermode-lighting.c @@ -295,8 +295,8 @@ rendermode_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject if ((state->block == 9) || (state->block == 79)) { /* special case for water and ice */ /* looks like we need a new case for lighting, there are - * blocks that are transparent and need per-face shading - * if the face is drawn. */ + * blocks that are transparent for occlusion calculations and + * need per-face shading if the face is drawn. */ if ((state->block_pdata & 16) == 16) { do_shading_with_mask(self, state, x, y, z+1, self->facemasks[0]); } @@ -306,7 +306,9 @@ rendermode_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject if ((state->block_pdata & 4) == 4) { /* bottom right */ do_shading_with_mask(self, state, x, y+1, z, self->facemasks[2]); } - } else if (is_transparent(state->block)) { + /* leaves are transparent for occlusion calculations but they + * per face-shading to look as in game */ + } else if (is_transparent(state->block) && (state->block != 18)) { /* transparent: do shading on whole block */ do_shading_with_mask(self, state, x, y, z, mask_light); } else {