optimise skybox_pbr

main
Dominik Madarász 2024-03-20 21:46:51 +01:00
parent 082f78d25f
commit f620ed1938
9 changed files with 2575 additions and 122 deletions

View File

@ -1259,8 +1259,6 @@ typedef struct skybox_t {
handle program;
mesh_t geometry;
cubemap_t cubemap;
cubemap_t refl_cubemap;
cubemap_t env_cubemap;
int flags;
int framebuffers[6];
int textures[6];

View File

@ -7,6 +7,7 @@
const char *skyboxes[][2] = { // reflection, env, metadata
{"hdr/mesto.hdr","hdr/mesto_Env.hdr"},
{"hdr/graffiti_shelter_4k.hdr","hdr/graffiti_shelter_Env.hdr"},
{"hdr/music_hall_01_4k.hdr","hdr/music_hall_01_Env.hdr"},
{"hdr/the_sky_is_on_fire_2k.hdr","hdr/the_sky_is_on_fire_Env.hdr"},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17458,8 +17458,6 @@ typedef struct skybox_t {
handle program;
mesh_t geometry;
cubemap_t cubemap;
cubemap_t refl_cubemap;
cubemap_t env_cubemap;
int flags;
// mie
@ -371739,49 +371737,11 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
sky.cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( refl_map ) {
int is_panorama = vfs_size( refl_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( refl_map, IMAGE_RGBA );
sky.refl_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", refl_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", refl_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", refl_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", refl_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", refl_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", refl_map), IMAGE_RGB ); // cubenz
sky.refl_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( env_map ) {
int is_panorama = vfs_size( env_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( env_map, IMAGE_RGBA );
sky.env_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", env_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", env_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", env_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", env_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", env_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", env_map), IMAGE_RGB ); // cubenz
sky.env_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
}

View File

@ -1710,49 +1710,11 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
sky.cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( refl_map ) {
int is_panorama = vfs_size( refl_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( refl_map, IMAGE_RGBA );
sky.refl_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", refl_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", refl_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", refl_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", refl_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", refl_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", refl_map), IMAGE_RGB ); // cubenz
sky.refl_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( env_map ) {
int is_panorama = vfs_size( env_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( env_map, IMAGE_RGBA );
sky.env_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", env_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", env_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", env_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", env_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", env_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", env_map), IMAGE_RGB ); // cubenz
sky.env_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
}

View File

@ -436,8 +436,6 @@ typedef struct skybox_t {
handle program;
mesh_t geometry;
cubemap_t cubemap;
cubemap_t refl_cubemap;
cubemap_t env_cubemap;
int flags;
// mie

View File

@ -18884,49 +18884,11 @@ skybox_t skybox_pbr(const char *sky_map, const char *refl_map, const char *env_m
sky.cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( refl_map ) {
int is_panorama = vfs_size( refl_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( refl_map, IMAGE_RGBA );
sky.refl_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", refl_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", refl_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", refl_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", refl_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", refl_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", refl_map), IMAGE_RGB ); // cubenz
sky.refl_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
}
if( env_map ) {
int is_panorama = vfs_size( env_map );
if( is_panorama ) { // is file
stbi_hdr_to_ldr_gamma(1.2f);
image_t panorama = image( env_map, IMAGE_RGBA );
sky.env_cubemap = cubemap( panorama, 0 ); // RGBA required
image_destroy(&panorama);
} else { // is folder
image_t images[6] = {0};
images[0] = image( va("%s/posx", env_map), IMAGE_RGB ); // cubepx
images[1] = image( va("%s/negx", env_map), IMAGE_RGB ); // cubenx
images[2] = image( va("%s/posy", env_map), IMAGE_RGB ); // cubepy
images[3] = image( va("%s/negy", env_map), IMAGE_RGB ); // cubeny
images[4] = image( va("%s/posz", env_map), IMAGE_RGB ); // cubepz
images[5] = image( va("%s/negz", env_map), IMAGE_RGB ); // cubenz
sky.env_cubemap = cubemap6( images, 0 );
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
}
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
}

View File

@ -3525,8 +3525,6 @@ typedef struct skybox_t {
handle program;
mesh_t geometry;
cubemap_t cubemap;
cubemap_t refl_cubemap;
cubemap_t env_cubemap;
int flags;
// mie