forked from bartvdbraak/blender
Studiolight: fixed diffuse lighting
- Orientation of the cubemap were not conform cycles and eevee - one side of the cubemap was flipped, so one side was overlit and the other side was to dark.
This commit is contained in:
parent
c6ab911744
commit
0fb1093b14
@ -60,6 +60,12 @@ static ListBase studiolights;
|
|||||||
#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT 32
|
#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT 32
|
||||||
#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * 2)
|
#define STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECTANGULAR_HEIGHT * 2)
|
||||||
|
|
||||||
|
/*
|
||||||
|
Disable this option so caches are not loaded from disk
|
||||||
|
Do not checkin with this commented out
|
||||||
|
*/
|
||||||
|
#define STUDIOLIGHT_LOAD_CACHED_FILES
|
||||||
|
|
||||||
static const char *STUDIOLIGHT_CAMERA_FOLDER = "studiolights/camera/";
|
static const char *STUDIOLIGHT_CAMERA_FOLDER = "studiolights/camera/";
|
||||||
static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/";
|
static const char *STUDIOLIGHT_WORLD_FOLDER = "studiolights/world/";
|
||||||
static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/";
|
static const char *STUDIOLIGHT_MATCAP_FOLDER = "studiolights/matcap/";
|
||||||
@ -345,25 +351,25 @@ static void studiolight_calculate_cubemap_vector_weight(float normal[3], float *
|
|||||||
copy_v3_fl3(normal, x * 2.0f - 1.0f, y * 2.0f - 1.0f, 1.0f);
|
copy_v3_fl3(normal, x * 2.0f - 1.0f, y * 2.0f - 1.0f, 1.0f);
|
||||||
const float conversion_matrices[6][3][3] = {
|
const float conversion_matrices[6][3][3] = {
|
||||||
{
|
{
|
||||||
{0.0f, 0.0f, -1.0f},
|
|
||||||
{0.0f, -1.0f, 0.0f},
|
|
||||||
{-1.0f, 0.0f, 0.0f},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{0.0f, 0.0f, -1.0f},
|
|
||||||
{0.0f, -1.0f, 0.0f},
|
|
||||||
{-1.0f, 0.0f, 0.0f},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{1.0f, 0.0f, 0.0f},
|
|
||||||
{0.0f, 0.0f, 1.0f},
|
{0.0f, 0.0f, 1.0f},
|
||||||
{0.0f, -1.0f, 0.0f},
|
{0.0f, -1.0f, 0.0f},
|
||||||
|
{1.0f, 0.0f, 0.0f},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{0.0f, 0.0f, -1.0f},
|
||||||
|
{0.0f, -1.0f, 0.0f},
|
||||||
|
{-1.0f, 0.0f, 0.0f},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{1.0f, 0.0f, 0.0f},
|
{1.0f, 0.0f, 0.0f},
|
||||||
{0.0f, 0.0f, -1.0f},
|
{0.0f, 0.0f, -1.0f},
|
||||||
{0.0f, 1.0f, 0.0f},
|
{0.0f, 1.0f, 0.0f},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
{1.0f, 0.0f, 0.0f},
|
||||||
|
{0.0f, 0.0f, 1.0f},
|
||||||
|
{0.0f, -1.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, 0.0f},
|
||||||
@ -375,6 +381,7 @@ static void studiolight_calculate_cubemap_vector_weight(float normal[3], float *
|
|||||||
{0.0f, 0.0f, 1.0f},
|
{0.0f, 0.0f, 1.0f},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mul_m3_v3(conversion_matrices[face], normal);
|
mul_m3_v3(conversion_matrices[face], normal);
|
||||||
normalize_v3(normal);
|
normalize_v3(normal);
|
||||||
const float halfpix = 1.0f / (2.0f * STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
|
const float halfpix = 1.0f / (2.0f * STUDIOLIGHT_RADIANCE_CUBEMAP_SIZE);
|
||||||
@ -567,6 +574,7 @@ static void studiolight_calculate_specular_irradiance(StudioLight *sl, float col
|
|||||||
|
|
||||||
static bool studiolight_load_irradiance_equirectangular_image(StudioLight *sl)
|
static bool studiolight_load_irradiance_equirectangular_image(StudioLight *sl)
|
||||||
{
|
{
|
||||||
|
#ifdef STUDIOLIGHT_LOAD_CACHED_FILES
|
||||||
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
|
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
|
||||||
ImBuf *ibuf = NULL;
|
ImBuf *ibuf = NULL;
|
||||||
ibuf = IMB_loadiffname(sl->path_irr_cache, 0, NULL);
|
ibuf = IMB_loadiffname(sl->path_irr_cache, 0, NULL);
|
||||||
@ -577,11 +585,13 @@ static bool studiolight_load_irradiance_equirectangular_image(StudioLight *sl)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool studiolight_load_spherical_harmonics_coefficients(StudioLight *sl)
|
static bool studiolight_load_spherical_harmonics_coefficients(StudioLight *sl)
|
||||||
{
|
{
|
||||||
|
#ifdef STUDIOLIGHT_LOAD_CACHED_FILES
|
||||||
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
|
if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) {
|
||||||
FILE *fp = BLI_fopen(sl->path_sh2_cache, "rb");
|
FILE *fp = BLI_fopen(sl->path_sh2_cache, "rb");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
@ -594,6 +604,7 @@ static bool studiolight_load_spherical_harmonics_coefficients(StudioLight *sl)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user