Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/studiolight.c
| Context not available. | |||||
| #define STUDIOLIGHT_IRRADIANCE_EQUIRECT_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT * 2) | #define STUDIOLIGHT_IRRADIANCE_EQUIRECT_WIDTH (STUDIOLIGHT_IRRADIANCE_EQUIRECT_HEIGHT * 2) | ||||
| #define STUDIOLIGHT_PASSNAME_DIFFUSE "diffuse" | #define STUDIOLIGHT_PASSNAME_DIFFUSE "diffuse" | ||||
| #define STUDIOLIGHT_PASSNAME_SPECULAR "specular" | #define STUDIOLIGHT_PASSNAME_SPECULAR "specular" | ||||
| #define STUDIOLIGHT_PASSNAME_RIDGE "ridge" | |||||
| #define STUDIOLIGHT_PASSNAME_VALLEY "valley" | |||||
| /* Temporarily disabled due to the creation of textures with -nan(ind)s */ | /* Temporarily disabled due to the creation of textures with -nan(ind)s */ | ||||
| #define STUDIOLIGHT_SH_WINDOWING 0.0f /* 0.0 is disabled */ | #define STUDIOLIGHT_SH_WINDOWING 0.0f /* 0.0 is disabled */ | ||||
| Context not available. | |||||
| IMB_SAFE_FREE(sl->equirect_irradiance_buffer); | IMB_SAFE_FREE(sl->equirect_irradiance_buffer); | ||||
| GPU_TEXTURE_SAFE_FREE(sl->matcap_diffuse.gputexture); | GPU_TEXTURE_SAFE_FREE(sl->matcap_diffuse.gputexture); | ||||
| GPU_TEXTURE_SAFE_FREE(sl->matcap_specular.gputexture); | GPU_TEXTURE_SAFE_FREE(sl->matcap_specular.gputexture); | ||||
| GPU_TEXTURE_SAFE_FREE(sl->matcap_ridge.gputexture); | |||||
| GPU_TEXTURE_SAFE_FREE(sl->matcap_valley.gputexture); | |||||
| IMB_SAFE_FREE(sl->matcap_diffuse.ibuf); | IMB_SAFE_FREE(sl->matcap_diffuse.ibuf); | ||||
| IMB_SAFE_FREE(sl->matcap_specular.ibuf); | IMB_SAFE_FREE(sl->matcap_specular.ibuf); | ||||
| IMB_SAFE_FREE(sl->matcap_ridge.ibuf); | |||||
| IMB_SAFE_FREE(sl->matcap_valley.ibuf); | |||||
| MEM_SAFE_FREE(sl->path_irr_cache); | MEM_SAFE_FREE(sl->path_irr_cache); | ||||
| MEM_SAFE_FREE(sl->path_sh_cache); | MEM_SAFE_FREE(sl->path_sh_cache); | ||||
| MEM_SAFE_FREE(sl); | MEM_SAFE_FREE(sl); | ||||
| Context not available. | |||||
| float *diffuse_pass; | float *diffuse_pass; | ||||
| int num_specular_channels; | int num_specular_channels; | ||||
| float *specular_pass; | float *specular_pass; | ||||
| int num_ridge_channels; | |||||
| float *ridge_pass; | |||||
| int num_valley_channels; | |||||
| float *valley_pass; | |||||
| } MultilayerConvertContext; | } MultilayerConvertContext; | ||||
| static void *studiolight_multilayer_addview(void *UNUSED(base), const char *UNUSED(view_name)) | static void *studiolight_multilayer_addview(void *UNUSED(base), const char *UNUSED(view_name)) | ||||
| Context not available. | |||||
| ctx->specular_pass = rect; | ctx->specular_pass = rect; | ||||
| ctx->num_specular_channels = num_channels; | ctx->num_specular_channels = num_channels; | ||||
| } | } | ||||
| else if (STREQ(pass_name, STUDIOLIGHT_PASSNAME_RIDGE)) { | |||||
| ctx->ridge_pass = rect; | |||||
| ctx->num_ridge_channels = num_channels; | |||||
| } | |||||
| else if (STREQ(pass_name, STUDIOLIGHT_PASSNAME_VALLEY)) { | |||||
| ctx->valley_pass = rect; | |||||
| ctx->num_valley_channels = num_channels; | |||||
| } | |||||
| else { | else { | ||||
| MEM_freeN(rect); | MEM_freeN(rect); | ||||
| } | } | ||||
| Context not available. | |||||
| ImBuf *ibuf = IMB_loadiffname(sl->path, IB_multilayer, NULL); | ImBuf *ibuf = IMB_loadiffname(sl->path, IB_multilayer, NULL); | ||||
| ImBuf *specular_ibuf = NULL; | ImBuf *specular_ibuf = NULL; | ||||
| ImBuf *diffuse_ibuf = NULL; | ImBuf *diffuse_ibuf = NULL; | ||||
| ImBuf *ridge_ibuf = NULL; | |||||
| ImBuf *valley_ibuf = NULL; | |||||
| const bool failed = (ibuf == NULL); | const bool failed = (ibuf == NULL); | ||||
| if (ibuf) { | if (ibuf) { | ||||
| Context not available. | |||||
| MEM_freeN(converted_pass); | MEM_freeN(converted_pass); | ||||
| } | } | ||||
| if (ctx.ridge_pass != NULL) { | |||||
| float *converted_pass = studiolight_multilayer_convert_pass( | |||||
| ibuf, ctx.ridge_pass, ctx.num_ridge_channels); | |||||
| ridge_ibuf = IMB_allocFromBuffer( | |||||
| NULL, converted_pass, ibuf->x, ibuf->y, ctx.num_specular_channels); | |||||
| MEM_freeN(converted_pass); | |||||
| } | |||||
| if (ctx.valley_pass != NULL) { | |||||
| float *converted_pass = studiolight_multilayer_convert_pass( | |||||
| ibuf, ctx.valley_pass, ctx.num_valley_channels); | |||||
| valley_ibuf = IMB_allocFromBuffer( | |||||
| NULL, converted_pass, ibuf->x, ibuf->y, ctx.num_specular_channels); | |||||
| MEM_freeN(converted_pass); | |||||
| } | |||||
| IMB_exr_close(ibuf->userdata); | IMB_exr_close(ibuf->userdata); | ||||
| ibuf->userdata = NULL; | ibuf->userdata = NULL; | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| Context not available. | |||||
| if ((sl->flag & STUDIOLIGHT_TYPE_MATCAP)) { | if ((sl->flag & STUDIOLIGHT_TYPE_MATCAP)) { | ||||
| sl->matcap_diffuse.ibuf = diffuse_ibuf; | sl->matcap_diffuse.ibuf = diffuse_ibuf; | ||||
| sl->matcap_specular.ibuf = specular_ibuf; | sl->matcap_specular.ibuf = specular_ibuf; | ||||
| sl->matcap_ridge.ibuf = ridge_ibuf; | |||||
| sl->matcap_valley.ibuf = valley_ibuf; | |||||
| if (specular_ibuf != NULL) { | if (specular_ibuf != NULL) { | ||||
| sl->flag |= STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS; | sl->flag |= STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS; | ||||
| } | } | ||||
| if (ridge_ibuf != NULL) { | |||||
| sl->flag |= STUDIOLIGHT_MATCAP_RIDGE_PASS; | |||||
| } | |||||
| if (valley_ibuf != NULL) { | |||||
| sl->flag |= STUDIOLIGHT_MATCAP_VALLEY_PASS; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| sl->equirect_radiance_buffer = diffuse_ibuf; | sl->equirect_radiance_buffer = diffuse_ibuf; | ||||
| if (specular_ibuf != NULL) { | if (specular_ibuf != NULL) { | ||||
| IMB_freeImBuf(specular_ibuf); | IMB_freeImBuf(specular_ibuf); | ||||
| } | } | ||||
| if (ridge_ibuf != NULL) { | |||||
| IMB_freeImBuf(ridge_ibuf); | |||||
| } | |||||
| if (valley_ibuf != NULL) { | |||||
| IMB_freeImBuf(valley_ibuf); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| sl->flag |= STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE; | sl->flag |= STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE; | ||||
| } | } | ||||
| static void studiolight_create_matcap_ridge_gputexture(StudioLight *sl) | |||||
| { | |||||
| if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { | |||||
| if (sl->flag & STUDIOLIGHT_TYPE_MATCAP) { | |||||
| BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); | |||||
| if (sl->matcap_ridge.ibuf) { | |||||
| studiolight_create_matcap_gputexture(&sl->matcap_ridge); | |||||
| } | |||||
| } | |||||
| } | |||||
| sl->flag |= STUDIOLIGHT_MATCAP_RIDGE_GPUTEXTURE; | |||||
| } | |||||
| static void studiolight_create_matcap_valley_gputexture(StudioLight *sl) | |||||
| { | |||||
| if (sl->flag & STUDIOLIGHT_EXTERNAL_FILE) { | |||||
| if (sl->flag & STUDIOLIGHT_TYPE_MATCAP) { | |||||
| BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); | |||||
| if (sl->matcap_valley.ibuf) { | |||||
| studiolight_create_matcap_gputexture(&sl->matcap_valley); | |||||
| } | |||||
| } | |||||
| } | |||||
| sl->flag |= STUDIOLIGHT_MATCAP_VALLEY_GPUTEXTURE; | |||||
| } | |||||
| static void studiolight_create_equirect_irradiance_gputexture(StudioLight *sl) | static void studiolight_create_equirect_irradiance_gputexture(StudioLight *sl) | ||||
| { | { | ||||
| Context not available. | |||||
| if ((flag & STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE)) { | if ((flag & STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE)) { | ||||
| studiolight_create_matcap_specular_gputexture(sl); | studiolight_create_matcap_specular_gputexture(sl); | ||||
| } | } | ||||
| if ((flag & STUDIOLIGHT_MATCAP_RIDGE_GPUTEXTURE)) { | |||||
| studiolight_create_matcap_ridge_gputexture(sl); | |||||
| } | |||||
| if ((flag & STUDIOLIGHT_MATCAP_VALLEY_GPUTEXTURE)) { | |||||
| studiolight_create_matcap_valley_gputexture(sl); | |||||
| } | |||||
| } | } | ||||
| /* | /* | ||||
| Context not available. | |||||