diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-15 09:57:49 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-15 14:02:15 +0300 |
commit | 64bfa4b300dabe0abf45c10c179892e1557a4b1a (patch) | |
tree | 8a2e9620b9b6b259ddbcb57f7a28e98bc41954dc | |
parent | b7338463a79913cc2eceaad04e8144b2770860e1 (diff) |
T55486: use GPU_R11F_G11F_B10F for Matcaps
-rw-r--r-- | source/blender/blenkernel/BKE_studiolight.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/studiolight.c | 32 |
2 files changed, 27 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index e4c4fd87ecd..36de1e4d22f 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -98,6 +98,7 @@ typedef struct StudioLight { ImBuf *radiance_cubemap_buffers[6]; struct GPUTexture *equirectangular_radiance_gputexture; struct GPUTexture *equirectangular_irradiance_gputexture; + float *gpu_matcap_3components; /* 3 channel buffer for GPU_R11F_G11F_B10F */ } StudioLight; void BKE_studiolight_init(void); diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 60c25b8976d..cf0bdf8c9e8 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -96,6 +96,10 @@ static void studiolight_free(struct StudioLight *sl) MEM_freeN(sl->path_irr); sl->path_irr = NULL; } + if (sl->gpu_matcap_3components) { + MEM_freeN(sl->gpu_matcap_3components); + sl->gpu_matcap_3components = NULL; + } MEM_freeN(sl); } @@ -188,12 +192,28 @@ static void studiolight_create_equierectangular_radiance_gputexture(StudioLight char error[256]; BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); ImBuf *ibuf = sl->equirectangular_radiance_buffer; - sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error); - GPUTexture *tex = sl->equirectangular_radiance_gputexture; - GPU_texture_bind(tex, 0); - GPU_texture_filter_mode(tex, true); - GPU_texture_wrap_mode(tex, true); - GPU_texture_unbind(tex); + + if (sl->flag & STUDIOLIGHT_ORIENTATION_VIEWNORMAL) { + sl->gpu_matcap_3components = MEM_callocN(sizeof(float) * ibuf->x * ibuf->y * 3, __func__); + + float* offset4 = ibuf->rect_float; + float* offset3 = sl->gpu_matcap_3components; + for (int i = 0 ; i < ibuf->x * ibuf->y; i ++) + { + copy_v3_v3(offset3, offset4); + offset3 += 3; + offset4 += 4; + } + sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_R11F_G11F_B10F, sl->gpu_matcap_3components, error); + } + else { + sl->equirectangular_radiance_gputexture = GPU_texture_create_2D(ibuf->x, ibuf->y, GPU_RGBA16F, ibuf->rect_float, error); + GPUTexture *tex = sl->equirectangular_radiance_gputexture; + GPU_texture_bind(tex, 0); + GPU_texture_filter_mode(tex, true); + GPU_texture_wrap_mode(tex, true); + GPU_texture_unbind(tex); + } } sl->flag |= STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE; } |