From 959f988836b8a408f5455f70e4d66db8e7fca989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 11 Sep 2023 10:23:02 +0200 Subject: [PATCH] render: fix skybox_mie_calc_sh sampling cubemap upside down render: skybox_mie_calc_sh match res to 1024 --- demos/99-cubemap.c | 6 +++++- engine/bind/fwk.py | 26 -------------------------- engine/joint/v4k.h | 15 ++++----------- engine/split/v4k_render.c | 15 ++++----------- engine/v4k.c | 15 ++++----------- 5 files changed, 17 insertions(+), 60 deletions(-) delete mode 100644 engine/bind/fwk.py diff --git a/demos/99-cubemap.c b/demos/99-cubemap.c index e9b246f..0da6d7d 100644 --- a/demos/99-cubemap.c +++ b/demos/99-cubemap.c @@ -41,9 +41,13 @@ int main(int argc, char** argv) { } if( !initialized ) { initialized = 1; - sky = skybox(SKY_DIRS[SKY_DIR], 0); + sky = skybox(flag("--mie") ? 0 : SKY_DIRS[SKY_DIR], 0); mdl = model(OBJ_MDLS[OBJ_MDL], 0); // rotation44(mdl.pivot, 0, 1,0,0); // @fixme: -90,1,0,0 -> should we rotate SHMs as well? compensate rotation in shader? + + if (flag("--mie")) { + skybox_mie_calc_sh(&sky); + } } // fps camera diff --git a/engine/bind/fwk.py b/engine/bind/fwk.py deleted file mode 100644 index 2f0c882..0000000 --- a/engine/bind/fwk.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -import sys -import ctypes -import cffi - -ffi = cffi.FFI() -with open('./fwk.lua') as f: - lines = [line for line in f if not line.startswith('#')] - lines = [line for line in lines if not 'va_list' in line] - lines = [line for line in lines if not 'inline ' in line] - lines = [line for line in lines if not line.startswith('typedef union ') ] - lines = [line for line in lines if not '//lcpp INF' in line ] - data = ''.join(lines) - data = data[data.find('[[')+2:data.find(']]')] - data = ''' - typedef struct vec2i { float x,y; } vec2i; - typedef struct vec3i { float x,y,z; } vec3i; - typedef struct vec2 { float x,y; } vec2; - typedef struct vec3 { float x,y,z; } vec3; - typedef struct vec4 { float x,y,z,w; } vec4; - typedef struct quat { float x,y,z,w; } quat; - typedef union frustum frustum; - typedef union json_t json_t; - ''' + data - ffi.cdef(data) -fwk = ffi.dlopen('./fwk.dll') diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 9a12b17..bb29233 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -341706,7 +341706,7 @@ skybox_t skybox(const char *asset, int flags) { } void skybox_mie_calc_sh(skybox_t *sky) { - unsigned WIDTH = 512, HEIGHT = 512; + unsigned WIDTH = 1024, HEIGHT = 1024; int last_fb; int vp[4]; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); @@ -341732,14 +341732,7 @@ void skybox_mie_calc_sh(skybox_t *sky) { } } - static vec3 directions[6] = { - {1.0f, 0.0f, 0.0f}, - {-1.0f, 0.0f, 0.0f}, - {0.0f, 1.0f, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, -1.0f} - }; + static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}}; int samples = 0; for(int i = 0; i < 6; ++i) { @@ -341747,8 +341740,8 @@ void skybox_mie_calc_sh(skybox_t *sky) { glViewport(0, 0, WIDTH, HEIGHT); glUseProgram(sky->program); - mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); - mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,1,0)); + mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.1f, 500.f); + mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0)); skybox_render(sky, proj, view); diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index a953f9d..3bebe9c 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -2401,7 +2401,7 @@ skybox_t skybox(const char *asset, int flags) { } void skybox_mie_calc_sh(skybox_t *sky) { - unsigned WIDTH = 512, HEIGHT = 512; + unsigned WIDTH = 1024, HEIGHT = 1024; int last_fb; int vp[4]; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); @@ -2427,14 +2427,7 @@ void skybox_mie_calc_sh(skybox_t *sky) { } } - static vec3 directions[6] = { - {1.0f, 0.0f, 0.0f}, - {-1.0f, 0.0f, 0.0f}, - {0.0f, 1.0f, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, -1.0f} - }; + static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}}; int samples = 0; for(int i = 0; i < 6; ++i) { @@ -2442,8 +2435,8 @@ void skybox_mie_calc_sh(skybox_t *sky) { glViewport(0, 0, WIDTH, HEIGHT); glUseProgram(sky->program); - mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); - mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,1,0)); + mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.1f, 500.f); + mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0)); skybox_render(sky, proj, view); diff --git a/engine/v4k.c b/engine/v4k.c index 9d4e596..1fbe36b 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -12614,7 +12614,7 @@ skybox_t skybox(const char *asset, int flags) { } void skybox_mie_calc_sh(skybox_t *sky) { - unsigned WIDTH = 512, HEIGHT = 512; + unsigned WIDTH = 1024, HEIGHT = 1024; int last_fb; int vp[4]; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); @@ -12640,14 +12640,7 @@ void skybox_mie_calc_sh(skybox_t *sky) { } } - static vec3 directions[6] = { - {1.0f, 0.0f, 0.0f}, - {-1.0f, 0.0f, 0.0f}, - {0.0f, 1.0f, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, -1.0f} - }; + static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}}; int samples = 0; for(int i = 0; i < 6; ++i) { @@ -12655,8 +12648,8 @@ void skybox_mie_calc_sh(skybox_t *sky) { glViewport(0, 0, WIDTH, HEIGHT); glUseProgram(sky->program); - mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); - mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,1,0)); + mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.1f, 500.f); + mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0)); skybox_render(sky, proj, view);