From: Christoph Neuhauser Date: Mon, 6 Feb 2023 11:49:57 +0000 (+0100) Subject: added shader compilation switch for applying opacity depending on use of premultiplie... X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=427b39006268104c0e89c187f3a941c1abd62937;p=jp%2Fvkvg.git added shader compilation switch for applying opacity depending on use of premultiplied alpha --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f159319..f59f756 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,7 @@ OPTION(VKVG_RECORDING "enable experimental recording functions" ON) OPTION(VKVG_PREMULT_ALPHA "use premultiplied alpha for internal rendering" ON) IF (VKVG_PREMULT_ALPHA) ADD_DEFINITIONS (-DVKVG_PREMULT_ALPHA) + SET(GLSLDEFS ${GLSLDEFS} -DVKVG_PREMULT_ALPHA) ENDIF () OPTION(VKVG_DBG_STATS "record contexts statistics in the device" OFF) @@ -147,7 +148,7 @@ CMAKE_DEPENDENT_OPTION(VKVG_LCD_FONT_FILTER "enable freetype lcd font filtering" OPTION(VKVG_ENABLE_VK_SCALAR_BLOCK_LAYOUT "Enable scalar block layout support." ON) IF (VKVG_ENABLE_VK_SCALAR_BLOCK_LAYOUT) ADD_DEFINITIONS (-DVKVG_ENABLE_VK_SCALAR_BLOCK_LAYOUT) - SET(GLSLDEFS "-DVKVG_ENABLE_VK_SCALAR_BLOCK_LAYOUT") + SET(GLSLDEFS ${GLSLDEFS} -DVKVG_ENABLE_VK_SCALAR_BLOCK_LAYOUT) ENDIF () OPTION(VKVG_ENABLE_VK_TIMELINE_SEMAPHORE "Enable vulkan TimelineSemaphore support." OFF) diff --git a/shaders/vkvg_main.frag b/shaders/vkvg_main.frag index 8c1c8f5..5b43765 100644 --- a/shaders/vkvg_main.frag +++ b/shaders/vkvg_main.frag @@ -145,7 +145,12 @@ void main() if (inFontUV.z >= 0.0) c *= texture(fontMap, inFontUV).r; +#ifdef VKVG_PREMULT_ALPHA c *= inOpacity; +#else + c.a *= inOpacity; +#endif + outFragColor = c; }