optimise skybox_pbr
parent
082f78d25f
commit
f620ed1938
|
@ -1259,8 +1259,6 @@ typedef struct skybox_t {
|
||||||
handle program;
|
handle program;
|
||||||
mesh_t geometry;
|
mesh_t geometry;
|
||||||
cubemap_t cubemap;
|
cubemap_t cubemap;
|
||||||
cubemap_t refl_cubemap;
|
|
||||||
cubemap_t env_cubemap;
|
|
||||||
int flags;
|
int flags;
|
||||||
int framebuffers[6];
|
int framebuffers[6];
|
||||||
int textures[6];
|
int textures[6];
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
|
|
||||||
const char *skyboxes[][2] = { // reflection, env, metadata
|
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/graffiti_shelter_4k.hdr","hdr/graffiti_shelter_Env.hdr"},
|
||||||
{"hdr/music_hall_01_4k.hdr","hdr/music_hall_01_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"},
|
{"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
|
@ -17458,8 +17458,6 @@ typedef struct skybox_t {
|
||||||
handle program;
|
handle program;
|
||||||
mesh_t geometry;
|
mesh_t geometry;
|
||||||
cubemap_t cubemap;
|
cubemap_t cubemap;
|
||||||
cubemap_t refl_cubemap;
|
|
||||||
cubemap_t env_cubemap;
|
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// mie
|
// 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 );
|
sky.cubemap = cubemap6( images, 0 );
|
||||||
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
|
||||||
}
|
}
|
||||||
if( refl_map ) {
|
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);
|
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
if( env_map ) {
|
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);
|
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 );
|
sky.cubemap = cubemap6( images, 0 );
|
||||||
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
|
||||||
}
|
}
|
||||||
if( refl_map ) {
|
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);
|
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
if( env_map ) {
|
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);
|
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -436,8 +436,6 @@ typedef struct skybox_t {
|
||||||
handle program;
|
handle program;
|
||||||
mesh_t geometry;
|
mesh_t geometry;
|
||||||
cubemap_t cubemap;
|
cubemap_t cubemap;
|
||||||
cubemap_t refl_cubemap;
|
|
||||||
cubemap_t env_cubemap;
|
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// mie
|
// mie
|
||||||
|
|
38
engine/v4k.c
38
engine/v4k.c
|
@ -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 );
|
sky.cubemap = cubemap6( images, 0 );
|
||||||
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
for( int i = 0; i < countof(images); ++i ) image_destroy(&images[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
|
||||||
}
|
}
|
||||||
if( refl_map ) {
|
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);
|
sky.refl = load_env_tex(refl_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
if( env_map ) {
|
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);
|
sky.env = load_env_tex(env_map, TEXTURE_SRGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3525,8 +3525,6 @@ typedef struct skybox_t {
|
||||||
handle program;
|
handle program;
|
||||||
mesh_t geometry;
|
mesh_t geometry;
|
||||||
cubemap_t cubemap;
|
cubemap_t cubemap;
|
||||||
cubemap_t refl_cubemap;
|
|
||||||
cubemap_t env_cubemap;
|
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// mie
|
// mie
|
||||||
|
|
Loading…
Reference in New Issue