diff options
| author | Christoph Neuhauser <c.a.neuhauser@gmail.com> | 2023-02-06 12:49:57 +0100 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2023-02-06 16:29:15 +0100 |
| commit | 427b39006268104c0e89c187f3a941c1abd62937 (patch) | |
| tree | c306a4f4cf4e0f0651d6d45adcee1695373b01c3 | |
| parent | 8197f75bc0bd267d25085036a5c46f70aeb39a91 (diff) | |
added shader compilation switch for applying opacity depending on use of premultiplied alpha
| -rw-r--r-- | CMakeLists.txt | 3 | ||||
| -rw-r--r-- | shaders/vkvg_main.frag | 5 |
2 files changed, 7 insertions, 1 deletions
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; } |