added sealevel option to HeightFading primitive
This commit is contained in:
@@ -619,6 +619,13 @@ Nether
|
|||||||
HeightFading
|
HeightFading
|
||||||
Draws a colored overlay on the blocks that fades them out according to their
|
Draws a colored overlay on the blocks that fades them out according to their
|
||||||
height.
|
height.
|
||||||
|
|
||||||
|
**Options**
|
||||||
|
|
||||||
|
sealevel
|
||||||
|
sealevel of the word you're rendering. Note that the default,
|
||||||
|
128, is usually *incorrect* for most worlds. You should
|
||||||
|
probably set this to 64. Default: 128
|
||||||
|
|
||||||
Depth
|
Depth
|
||||||
Only renders blocks between the specified min and max heights.
|
Only renders blocks between the specified min and max heights.
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ class Nether(RenderPrimitive):
|
|||||||
|
|
||||||
class HeightFading(RenderPrimitive):
|
class HeightFading(RenderPrimitive):
|
||||||
name = "height-fading"
|
name = "height-fading"
|
||||||
|
options = {
|
||||||
|
# 128 is *WRONG*, it should be 64. but we're grandfathered in for now
|
||||||
|
"sealevel": ("target sea level", 128),
|
||||||
|
}
|
||||||
|
|
||||||
black_color = Image.new("RGB", (24,24), (0,0,0))
|
black_color = Image.new("RGB", (24,24), (0,0,0))
|
||||||
white_color = Image.new("RGB", (24,24), (255,255,255))
|
white_color = Image.new("RGB", (24,24), (255,255,255))
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extesion
|
// increment this value if you've made a change to the c extesion
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 34
|
#define OVERVIEWER_EXTENSION_VERSION 35
|
||||||
|
|
||||||
/* Python PIL, and numpy headers */
|
/* Python PIL, and numpy headers */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|||||||
@@ -20,12 +20,16 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject *black_color;
|
PyObject *black_color;
|
||||||
PyObject *white_color;
|
PyObject *white_color;
|
||||||
|
unsigned int sealevel;
|
||||||
} PrimitiveHeightFading;
|
} PrimitiveHeightFading;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
height_fading_start(void *data, RenderState *state, PyObject *support) {
|
height_fading_start(void *data, RenderState *state, PyObject *support) {
|
||||||
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
PrimitiveHeightFading *self = (PrimitiveHeightFading *)data;
|
||||||
|
|
||||||
|
if (!render_mode_parse_option(support, "sealevel", "I", &(self->sealevel)))
|
||||||
|
return 1;
|
||||||
|
|
||||||
self->black_color = PyObject_GetAttrString(support, "black_color");
|
self->black_color = PyObject_GetAttrString(support, "black_color");
|
||||||
self->white_color = PyObject_GetAttrString(support, "white_color");
|
self->white_color = PyObject_GetAttrString(support, "white_color");
|
||||||
|
|
||||||
@@ -50,7 +54,7 @@ height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask
|
|||||||
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 */
|
/* current formula requires y to be between 0 and 127, so scale it */
|
||||||
y = (y * 128) / (16 * SECTIONS_PER_CHUNK);
|
y = (y * 128) / (2 * self->sealevel);
|
||||||
|
|
||||||
/* negative alpha => darkness, positive => light */
|
/* negative alpha => darkness, positive => light */
|
||||||
alpha = (1.0 / (1 + expf((70 - y) / 11.0))) * 0.6 - 0.55;
|
alpha = (1.0 / (1 + expf((70 - y) / 11.0))) * 0.6 - 0.55;
|
||||||
|
|||||||
Reference in New Issue
Block a user