From 66700196074ad168f3322f2766846a0a07f7a00f Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 27 Aug 2019 08:42:50 +0200 Subject: Workbench: Specular Highlighting for MatCaps With Blender 2.80 we introduced a more flexible matcap system. One change we did was to multiply the matcap with the base color that was shaded. As matcaps contains diffuse and specular lighting in a single texture this lead to rendering artifacts. Artists were complaining that everything looked to metalic. We now support a separate `diffuse` and `specular` pass for matcaps. `shaded_color = diffuse_light * base_color + specular_light` For matcaps to support this feature they need to be multilayer openexr files with 2 renderpasses (named `diffuse` and `specular`). In the future we can change this to first pass/second pass in stead of this naming convention. Reviewed By: fclem, brecht Differential Revision: https://developer.blender.org/D5335 --- source/blender/blenkernel/BKE_studiolight.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/blenkernel/BKE_studiolight.h') diff --git a/source/blender/blenkernel/BKE_studiolight.h b/source/blender/blenkernel/BKE_studiolight.h index d6fff528348..108e93d9caa 100644 --- a/source/blender/blenkernel/BKE_studiolight.h +++ b/source/blender/blenkernel/BKE_studiolight.h @@ -87,6 +87,11 @@ enum StudioLightFlag { STUDIOLIGHT_RADIANCE_BUFFERS_CALCULATED = (1 << 11), STUDIOLIGHT_USER_DEFINED = (1 << 12), STUDIOLIGHT_UI_EXPANDED = (1 << 13), + + STUDIOLIGHT_MATCAP_DIFFUSE_GPUTEXTURE = (1 << 14), + STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE = (1 << 15), + /* Is set for studio lights and matcaps with specular highlight pass. */ + STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS = (1 << 16), }; #define STUDIOLIGHT_FLAG_ALL (STUDIOLIGHT_INTERNAL | STUDIOLIGHT_EXTERNAL_FILE) @@ -97,6 +102,11 @@ enum StudioLightFlag { typedef void StudioLightFreeFunction(struct StudioLight *, void *data); +typedef struct StudioLightImage { + ImBuf *ibuf; + struct GPUTexture *gputexture; +} StudioLightImage; + typedef struct StudioLight { struct StudioLight *next, *prev; @@ -112,6 +122,8 @@ typedef struct StudioLight { int icon_id_matcap_flipped; float spherical_harmonics_coefs[STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN][3]; float light_direction[3]; + StudioLightImage matcap_diffuse; + StudioLightImage matcap_specular; ImBuf *equirect_radiance_buffer; ImBuf *equirect_irradiance_buffer; ImBuf *radiance_cubemap_buffers[6]; -- cgit v1.2.3