render: fix skybox_mie_calc_sh sampling cubemap upside down

render: skybox_mie_calc_sh match res to 1024
main
Dominik Madarász 2023-09-11 10:23:02 +02:00
parent 2a7b177fd8
commit 959f988836
5 changed files with 17 additions and 60 deletions

View File

@ -41,9 +41,13 @@ int main(int argc, char** argv) {
} }
if( !initialized ) { if( !initialized ) {
initialized = 1; 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); 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? // 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 // fps camera

View File

@ -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')

View File

@ -341706,7 +341706,7 @@ skybox_t skybox(const char *asset, int flags) {
} }
void skybox_mie_calc_sh(skybox_t *sky) { void skybox_mie_calc_sh(skybox_t *sky) {
unsigned WIDTH = 512, HEIGHT = 512; unsigned WIDTH = 1024, HEIGHT = 1024;
int last_fb; int last_fb;
int vp[4]; int vp[4];
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb);
@ -341732,14 +341732,7 @@ void skybox_mie_calc_sh(skybox_t *sky) {
} }
} }
static vec3 directions[6] = { static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}};
{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}
};
int samples = 0; int samples = 0;
for(int i = 0; i < 6; ++i) { for(int i = 0; i < 6; ++i) {
@ -341747,8 +341740,8 @@ void skybox_mie_calc_sh(skybox_t *sky) {
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
glUseProgram(sky->program); glUseProgram(sky->program);
mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); 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)); mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0));
skybox_render(sky, proj, view); skybox_render(sky, proj, view);

View File

@ -2401,7 +2401,7 @@ skybox_t skybox(const char *asset, int flags) {
} }
void skybox_mie_calc_sh(skybox_t *sky) { void skybox_mie_calc_sh(skybox_t *sky) {
unsigned WIDTH = 512, HEIGHT = 512; unsigned WIDTH = 1024, HEIGHT = 1024;
int last_fb; int last_fb;
int vp[4]; int vp[4];
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb);
@ -2427,14 +2427,7 @@ void skybox_mie_calc_sh(skybox_t *sky) {
} }
} }
static vec3 directions[6] = { static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}};
{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}
};
int samples = 0; int samples = 0;
for(int i = 0; i < 6; ++i) { for(int i = 0; i < 6; ++i) {
@ -2442,8 +2435,8 @@ void skybox_mie_calc_sh(skybox_t *sky) {
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
glUseProgram(sky->program); glUseProgram(sky->program);
mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); 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)); mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0));
skybox_render(sky, proj, view); skybox_render(sky, proj, view);

View File

@ -12614,7 +12614,7 @@ skybox_t skybox(const char *asset, int flags) {
} }
void skybox_mie_calc_sh(skybox_t *sky) { void skybox_mie_calc_sh(skybox_t *sky) {
unsigned WIDTH = 512, HEIGHT = 512; unsigned WIDTH = 1024, HEIGHT = 1024;
int last_fb; int last_fb;
int vp[4]; int vp[4];
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb); glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &last_fb);
@ -12640,14 +12640,7 @@ void skybox_mie_calc_sh(skybox_t *sky) {
} }
} }
static vec3 directions[6] = { static vec3 directions[6] = {{ 1, 0, 0},{-1, 0, 0},{ 0, 1, 0},{ 0,-1, 0},{ 0, 0, 1},{ 0, 0,-1}};
{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}
};
int samples = 0; int samples = 0;
for(int i = 0; i < 6; ++i) { for(int i = 0; i < 6; ++i) {
@ -12655,8 +12648,8 @@ void skybox_mie_calc_sh(skybox_t *sky) {
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
glUseProgram(sky->program); glUseProgram(sky->program);
mat44 proj; perspective44(proj, 90.0f, WIDTH / (float)HEIGHT, 0.01f, 1000.f); 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)); mat44 view; lookat44(view, vec3(0,0,0), directions[i], vec3(0,-1,0));
skybox_render(sky, proj, view); skybox_render(sky, proj, view);