]> O.S.I.I.S - jp/vkvg.git/commitdiff
added shader compilation switch for applying opacity depending on use of premultiplie...
authorChristoph Neuhauser <c.a.neuhauser@gmail.com>
Mon, 6 Feb 2023 11:49:57 +0000 (12:49 +0100)
committerj-p <jp_bruyere@hotmail.com>
Mon, 6 Feb 2023 15:29:15 +0000 (16:29 +0100)
CMakeLists.txt
shaders/vkvg_main.frag

index f15931951cc2f75900fba6c7c45181d5b4e980d3..f59f75620ad47a1260214a481c1204a5f1c23ce0 100644 (file)
@@ -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)
index 8c1c8f5921b8b6bccce5192153599e809e3b01e5..5b4376581c0d563a181c4bbb236e897dba77b10c 100644 (file)
@@ -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;
 }