15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci KHR_blend_equation_advanced 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_KHR_blend_equation_advanced 85bd8deadSopenharmony_ci GL_KHR_blend_equation_advanced_coherent 95bd8deadSopenharmony_ci 105bd8deadSopenharmony_ciContact 115bd8deadSopenharmony_ci 125bd8deadSopenharmony_ci Pat Brown, NVIDIA Corporation (pbrown 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciNotice 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Copyright (c) 2012-2015 The Khronos Group Inc. Copyright terms at 175bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ciSpecification Update Policy 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 225bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL and OpenGL ES Working Groups. For 235bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 245bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 255bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 265bd8deadSopenharmony_ci described in more detail at 275bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ciContributors 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci OpenGL ES Working Group in Khronos 325bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation 335bd8deadSopenharmony_ci Mathias Heyer, NVIDIA Corporation 345bd8deadSopenharmony_ci Mark Kilgard, NVIDIA Corporation 355bd8deadSopenharmony_ci Daniel Koch, NVIDIA Corporation 365bd8deadSopenharmony_ci Rik Cabanier, Adobe 375bd8deadSopenharmony_ci Slawek Grajewski, Intel 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ciStatus 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci Complete. 425bd8deadSopenharmony_ci Ratified by the Khronos Board of Promoters on 2014/03/14. 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ciVersion 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci Last Modified Date: February 14, 2018 475bd8deadSopenharmony_ci Revision: 17 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ciNumber 505bd8deadSopenharmony_ci 515bd8deadSopenharmony_ci ARB Extension #174 525bd8deadSopenharmony_ci OpenGL ES Extension #168 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ciDependencies 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci This extension is written against the OpenGL 4.1 Specification 575bd8deadSopenharmony_ci (Compatibility Profile). 585bd8deadSopenharmony_ci 595bd8deadSopenharmony_ci This extension is written against the OpenGL Shading Language 605bd8deadSopenharmony_ci Specification, Version 4.10 (Revision 6). 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci OpenGL 2.0 is required (for Desktop). 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci OpenGL ES 2.0 is required (for mobile). 655bd8deadSopenharmony_ci 665bd8deadSopenharmony_ci EXT_blend_minmax is required (for mobile). 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ci This extension interacts with OpenGL 4.0. 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci This extension interacts with OpenGL 4.1 (Core Profile). 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci This extension interacts with OpenGL 4.3 or later. 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci This extension interacts with OpenGL ES 2.0. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.0. 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ci This extension interacts with NV_path_rendering. 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ciOverview 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci This extension adds a number of "advanced" blending equations that can be 835bd8deadSopenharmony_ci used to perform new color blending operations, many of which are more 845bd8deadSopenharmony_ci complex than the standard blend modes provided by unextended OpenGL. This 855bd8deadSopenharmony_ci extension provides two different extension string entries: 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci - KHR_blend_equation_advanced: Provides the new blending equations, but 885bd8deadSopenharmony_ci guarantees defined results only if each sample is touched no more than 895bd8deadSopenharmony_ci once in any single rendering pass. The command BlendBarrierKHR() is 905bd8deadSopenharmony_ci provided to indicate a boundary between passes. 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci - KHR_blend_equation_advanced_coherent: Provides the new blending 935bd8deadSopenharmony_ci equations, and guarantees that blending is done coherently and in API 945bd8deadSopenharmony_ci primitive order. An enable is provided to allow implementations to opt 955bd8deadSopenharmony_ci out of fully coherent blending and instead behave as though only 965bd8deadSopenharmony_ci KHR_blend_equation_advanced were supported. 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci Some implementations may support KHR_blend_equation_advanced without 995bd8deadSopenharmony_ci supporting KHR_blend_equation_advanced_coherent. 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci In unextended OpenGL, the set of blending equations is limited, and can be 1025bd8deadSopenharmony_ci expressed very simply. The MIN and MAX blend equations simply compute 1035bd8deadSopenharmony_ci component-wise minimums or maximums of source and destination color 1045bd8deadSopenharmony_ci components. The FUNC_ADD, FUNC_SUBTRACT, and FUNC_REVERSE_SUBTRACT 1055bd8deadSopenharmony_ci multiply the source and destination colors by source and destination 1065bd8deadSopenharmony_ci factors and either add the two products together or subtract one from the 1075bd8deadSopenharmony_ci other. This limited set of operations supports many common blending 1085bd8deadSopenharmony_ci operations but precludes the use of more sophisticated transparency and 1095bd8deadSopenharmony_ci blending operations commonly available in many dedicated imaging APIs. 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci This extension provides a number of new "advanced" blending equations. 1125bd8deadSopenharmony_ci Unlike traditional blending operations using the FUNC_ADD equation, these 1135bd8deadSopenharmony_ci blending equations do not use source and destination factors specified by 1145bd8deadSopenharmony_ci BlendFunc. Instead, each blend equation specifies a complete equation 1155bd8deadSopenharmony_ci based on the source and destination colors. These new blend equations are 1165bd8deadSopenharmony_ci used for both RGB and alpha components; they may not be used to perform 1175bd8deadSopenharmony_ci separate RGB and alpha blending (via functions like 1185bd8deadSopenharmony_ci BlendEquationSeparate). 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci These blending operations are performed using premultiplied source and 1215bd8deadSopenharmony_ci destination colors, where RGB colors produced by the fragment shader and 1225bd8deadSopenharmony_ci stored in the framebuffer are considered to be multiplied by alpha 1235bd8deadSopenharmony_ci (coverage). Many of these advanced blending equations are formulated 1245bd8deadSopenharmony_ci where the result of blending source and destination colors with partial 1255bd8deadSopenharmony_ci coverage have three separate contributions: from the portions covered by 1265bd8deadSopenharmony_ci both the source and the destination, from the portion covered only by the 1275bd8deadSopenharmony_ci source, and from the portion covered only by the destination. Such 1285bd8deadSopenharmony_ci equations are defined assuming that the source and destination coverage 1295bd8deadSopenharmony_ci have no spatial correlation within the pixel. 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci In addition to the coherency issues on implementations not supporting 1325bd8deadSopenharmony_ci KHR_blend_equation_advanced_coherent, this extension has several 1335bd8deadSopenharmony_ci limitations worth noting. First, the new blend equations are not 1345bd8deadSopenharmony_ci supported while rendering to more than one color buffer at once; an 1355bd8deadSopenharmony_ci INVALID_OPERATION will be generated if an application attempts to render 1365bd8deadSopenharmony_ci any primitives in this unsupported configuration. Additionally, blending 1375bd8deadSopenharmony_ci precision may be limited to 16-bit floating-point, which could result in a 1385bd8deadSopenharmony_ci loss of precision and dynamic range for framebuffer formats with 32-bit 1395bd8deadSopenharmony_ci floating-point components, and in a loss of precision for formats with 12- 1405bd8deadSopenharmony_ci and 16-bit signed or unsigned normalized integer components. 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ciNew Procedures and Functions 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci void BlendBarrierKHR(void); 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ciNew Tokens 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci Accepted by the <cap> parameter of Disable, Enable, and IsEnabled, and by 1495bd8deadSopenharmony_ci the <pname> parameter of GetIntegerv, GetBooleanv, GetFloatv, GetDoublev 1505bd8deadSopenharmony_ci and GetInteger64v: 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci BLEND_ADVANCED_COHERENT_KHR 0x9285 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci Note: The BLEND_ADVANCED_COHERENT_KHR enable is provided if and only if 1555bd8deadSopenharmony_ci the KHR_blend_equation_advanced_coherent extension is supported. On 1565bd8deadSopenharmony_ci implementations supporting only KHR_blend_equation_advanced, this enable 1575bd8deadSopenharmony_ci is considered not to exist. 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci Accepted by the <mode> parameter of BlendEquation and BlendEquationi: 1605bd8deadSopenharmony_ci 1615bd8deadSopenharmony_ci MULTIPLY_KHR 0x9294 1625bd8deadSopenharmony_ci SCREEN_KHR 0x9295 1635bd8deadSopenharmony_ci OVERLAY_KHR 0x9296 1645bd8deadSopenharmony_ci DARKEN_KHR 0x9297 1655bd8deadSopenharmony_ci LIGHTEN_KHR 0x9298 1665bd8deadSopenharmony_ci COLORDODGE_KHR 0x9299 1675bd8deadSopenharmony_ci COLORBURN_KHR 0x929A 1685bd8deadSopenharmony_ci HARDLIGHT_KHR 0x929B 1695bd8deadSopenharmony_ci SOFTLIGHT_KHR 0x929C 1705bd8deadSopenharmony_ci DIFFERENCE_KHR 0x929E 1715bd8deadSopenharmony_ci EXCLUSION_KHR 0x92A0 1725bd8deadSopenharmony_ci 1735bd8deadSopenharmony_ci HSL_HUE_KHR 0x92AD 1745bd8deadSopenharmony_ci HSL_SATURATION_KHR 0x92AE 1755bd8deadSopenharmony_ci HSL_COLOR_KHR 0x92AF 1765bd8deadSopenharmony_ci HSL_LUMINOSITY_KHR 0x92B0 1775bd8deadSopenharmony_ci 1785bd8deadSopenharmony_ci NOTE: These enums are not accepted by the <modeRGB> or <modeAlpha> 1795bd8deadSopenharmony_ci parameters of BlendEquationSeparate or BlendEquationSeparatei. 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci 1825bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 4.1 Specification (OpenGL Operation) 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci None. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 4.1 Specification (Rasterization) 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci None. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 4.1 Specification (Per-Fragment 1915bd8deadSopenharmony_ciOperations and the Frame Buffer) 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci Modify Section 4.1.8, Blending (p. 359). 1945bd8deadSopenharmony_ci 1955bd8deadSopenharmony_ci (modify the first paragraph, p. 361, allowing for new values in the 1965bd8deadSopenharmony_ci <mode> parameter) ... <modeRGB> and <modeAlpha> must be one of 1975bd8deadSopenharmony_ci FUNC_ADD, FUNC_SUBTRACT, FUNC_REVERSE_SUBTRACT, MIN, or MAX as listed 1985bd8deadSopenharmony_ci in Table 4.1. <mode> must be one of the mode values in Table 4.1, 1995bd8deadSopenharmony_ci or one of the blend equations listed in tables X.1 and X.2. ... 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci (modify the third paragraph, p. 361, specifying minimum precision and 2025bd8deadSopenharmony_ci dynamic range for blend operations) ... Blending computations are treated 2035bd8deadSopenharmony_ci as if carried out in floating-point. For the equations in table 4.1, 2045bd8deadSopenharmony_ci blending computations will be performed with a precision and dynamic range 2055bd8deadSopenharmony_ci no lower than that used to represent destination components. For the 2065bd8deadSopenharmony_ci equations in table X.1 and X.2, blending computations will be performed 2075bd8deadSopenharmony_ci with a precision and dynamic range no lower than the smaller of that used 2085bd8deadSopenharmony_ci to represent destination components or that used to represent 16-bit 2095bd8deadSopenharmony_ci floating-point values as described in section 2.1.1. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci (add unnumbered subsection prior to "Dual Source Blending and Multiple 2125bd8deadSopenharmony_ci Draw Buffers", p. 363) 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci Advanced Blend Equations 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci The advanced blend equations are those listed in tables X.1 and X.2. When 2175bd8deadSopenharmony_ci using one of these equations, blending is performed according to the 2185bd8deadSopenharmony_ci following equations: 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci R = f(Rs',Rd')*p0(As,Ad) + Y*Rs'*p1(As,Ad) + Z*Rd'*p2(As,Ad) 2215bd8deadSopenharmony_ci G = f(Gs',Gd')*p0(As,Ad) + Y*Gs'*p1(As,Ad) + Z*Gd'*p2(As,Ad) 2225bd8deadSopenharmony_ci B = f(Bs',Bd')*p0(As,Ad) + Y*Bs'*p1(As,Ad) + Z*Bd'*p2(As,Ad) 2235bd8deadSopenharmony_ci A = X*p0(As,Ad) + Y*p1(As,Ad) + Z*p2(As,Ad) 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci where the function f and terms X, Y, and Z are specified in the table. 2265bd8deadSopenharmony_ci The R, G, and B components of the source color used for blending are 2275bd8deadSopenharmony_ci considered to have been premultiplied by the A component prior to 2285bd8deadSopenharmony_ci blending. The base source color (Rs',Gs',Bs') is obtained by dividing 2295bd8deadSopenharmony_ci through by the A component: 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci (Rs', Gs', Bs') = 2325bd8deadSopenharmony_ci (0, 0, 0), if As == 0 2335bd8deadSopenharmony_ci (Rs/As, Gs/As, Bs/As), otherwise 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci The destination color components are always considered to have been 2365bd8deadSopenharmony_ci premultiplied by the destination A component and the base destination 2375bd8deadSopenharmony_ci color (Rd', Gd', Bd') is obtained by dividing through by the A component: 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci (Rd', Gd', Bd') = 2405bd8deadSopenharmony_ci (0, 0, 0), if Ad == 0 2415bd8deadSopenharmony_ci (Rd/Ad, Gd/Ad, Bd/Ad), otherwise 2425bd8deadSopenharmony_ci 2435bd8deadSopenharmony_ci When blending using advanced blend equations, we expect that the R, G, and 2445bd8deadSopenharmony_ci B components of premultiplied source and destination color inputs be 2455bd8deadSopenharmony_ci stored as the product of non-premultiplied R, G, and B components and the 2465bd8deadSopenharmony_ci A component of the color. If any R, G, or B component of a premultiplied 2475bd8deadSopenharmony_ci input color is non-zero and the A component is zero, the color is 2485bd8deadSopenharmony_ci considered ill-formed, and the corresponding component of the blend result 2495bd8deadSopenharmony_ci will be undefined. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci The weighting functions p0, p1, and p2 are defined as follows: 2525bd8deadSopenharmony_ci 2535bd8deadSopenharmony_ci p0(As,Ad) = As*Ad 2545bd8deadSopenharmony_ci p1(As,Ad) = As*(1-Ad) 2555bd8deadSopenharmony_ci p2(As,Ad) = Ad*(1-As) 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci In these functions, the A components of the source and destination colors 2585bd8deadSopenharmony_ci are taken to indicate the portion of the pixel covered by the fragment 2595bd8deadSopenharmony_ci (source) and the fragments previously accumulated in the pixel 2605bd8deadSopenharmony_ci (destination). The functions p0, p1, and p2 approximate the relative 2615bd8deadSopenharmony_ci portion of the pixel covered by the intersection of the source and 2625bd8deadSopenharmony_ci destination, covered only by the source, and covered only by the 2635bd8deadSopenharmony_ci destination, respectively. The equations defined here assume that there 2645bd8deadSopenharmony_ci is no correlation between the source and destination coverage. 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci Mode Blend Coefficients 2685bd8deadSopenharmony_ci -------------------- ----------------------------------- 2695bd8deadSopenharmony_ci MULTIPLY_KHR (X,Y,Z) = (1,1,1) 2705bd8deadSopenharmony_ci f(Cs,Cd) = Cs*Cd 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci SCREEN_KHR (X,Y,Z) = (1,1,1) 2735bd8deadSopenharmony_ci f(Cs,Cd) = Cs+Cd-Cs*Cd 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci OVERLAY_KHR (X,Y,Z) = (1,1,1) 2765bd8deadSopenharmony_ci f(Cs,Cd) = 2*Cs*Cd, if Cd <= 0.5 2775bd8deadSopenharmony_ci 1-2*(1-Cs)*(1-Cd), otherwise 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci DARKEN_KHR (X,Y,Z) = (1,1,1) 2805bd8deadSopenharmony_ci f(Cs,Cd) = min(Cs,Cd) 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci LIGHTEN_KHR (X,Y,Z) = (1,1,1) 2835bd8deadSopenharmony_ci f(Cs,Cd) = max(Cs,Cd) 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci COLORDODGE_KHR (X,Y,Z) = (1,1,1) 2865bd8deadSopenharmony_ci f(Cs,Cd) = 2875bd8deadSopenharmony_ci 0, if Cd <= 0 2885bd8deadSopenharmony_ci min(1,Cd/(1-Cs)), if Cd > 0 and Cs < 1 2895bd8deadSopenharmony_ci 1, if Cd > 0 and Cs >= 1 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci COLORBURN_KHR (X,Y,Z) = (1,1,1) 2925bd8deadSopenharmony_ci f(Cs,Cd) = 2935bd8deadSopenharmony_ci 1, if Cd >= 1 2945bd8deadSopenharmony_ci 1 - min(1,(1-Cd)/Cs), if Cd < 1 and Cs > 0 2955bd8deadSopenharmony_ci 0, if Cd < 1 and Cs <= 0 2965bd8deadSopenharmony_ci 2975bd8deadSopenharmony_ci HARDLIGHT_KHR (X,Y,Z) = (1,1,1) 2985bd8deadSopenharmony_ci f(Cs,Cd) = 2*Cs*Cd, if Cs <= 0.5 2995bd8deadSopenharmony_ci 1-2*(1-Cs)*(1-Cd), otherwise 3005bd8deadSopenharmony_ci 3015bd8deadSopenharmony_ci SOFTLIGHT_KHR (X,Y,Z) = (1,1,1) 3025bd8deadSopenharmony_ci f(Cs,Cd) = 3035bd8deadSopenharmony_ci Cd-(1-2*Cs)*Cd*(1-Cd), 3045bd8deadSopenharmony_ci if Cs <= 0.5 3055bd8deadSopenharmony_ci Cd+(2*Cs-1)*Cd*((16*Cd-12)*Cd+3), 3065bd8deadSopenharmony_ci if Cs > 0.5 and Cd <= 0.25 3075bd8deadSopenharmony_ci Cd+(2*Cs-1)*(sqrt(Cd)-Cd), 3085bd8deadSopenharmony_ci if Cs > 0.5 and Cd > 0.25 3095bd8deadSopenharmony_ci 3105bd8deadSopenharmony_ci DIFFERENCE_KHR (X,Y,Z) = (1,1,1) 3115bd8deadSopenharmony_ci f(Cs,Cd) = abs(Cd-Cs) 3125bd8deadSopenharmony_ci 3135bd8deadSopenharmony_ci EXCLUSION_KHR (X,Y,Z) = (1,1,1) 3145bd8deadSopenharmony_ci f(Cs,Cd) = Cs+Cd-2*Cs*Cd 3155bd8deadSopenharmony_ci 3165bd8deadSopenharmony_ci Table X.1, Advanced Blend Equations 3175bd8deadSopenharmony_ci 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ci When using one of the HSL blend equations in table X.2 as the blend 3205bd8deadSopenharmony_ci equation, the RGB color components produced by the function f() are 3215bd8deadSopenharmony_ci effectively obtained by converting both the non-premultiplied source and 3225bd8deadSopenharmony_ci destination colors to the HSL (hue, saturation, luminosity) color space, 3235bd8deadSopenharmony_ci generating a new HSL color by selecting H, S, and L components from the 3245bd8deadSopenharmony_ci source or destination according to the blend equation, and then converting 3255bd8deadSopenharmony_ci the result back to RGB. The HSL blend equations are only well defined 3265bd8deadSopenharmony_ci when the values of the input color components are in the range [0..1]. 3275bd8deadSopenharmony_ci In the equations below, a blended RGB color is produced according to the 3285bd8deadSopenharmony_ci following pseudocode: 3295bd8deadSopenharmony_ci 3305bd8deadSopenharmony_ci float minv3(vec3 c) { 3315bd8deadSopenharmony_ci return min(min(c.r, c.g), c.b); 3325bd8deadSopenharmony_ci } 3335bd8deadSopenharmony_ci float maxv3(vec3 c) { 3345bd8deadSopenharmony_ci return max(max(c.r, c.g), c.b); 3355bd8deadSopenharmony_ci } 3365bd8deadSopenharmony_ci float lumv3(vec3 c) { 3375bd8deadSopenharmony_ci return dot(c, vec3(0.30, 0.59, 0.11)); 3385bd8deadSopenharmony_ci } 3395bd8deadSopenharmony_ci float satv3(vec3 c) { 3405bd8deadSopenharmony_ci return maxv3(c) - minv3(c); 3415bd8deadSopenharmony_ci } 3425bd8deadSopenharmony_ci 3435bd8deadSopenharmony_ci // If any color components are outside [0,1], adjust the color to 3445bd8deadSopenharmony_ci // get the components in range. 3455bd8deadSopenharmony_ci vec3 ClipColor(vec3 color) { 3465bd8deadSopenharmony_ci float lum = lumv3(color); 3475bd8deadSopenharmony_ci float mincol = minv3(color); 3485bd8deadSopenharmony_ci float maxcol = maxv3(color); 3495bd8deadSopenharmony_ci if (mincol < 0.0) { 3505bd8deadSopenharmony_ci color = lum + ((color-lum)*lum) / (lum-mincol); 3515bd8deadSopenharmony_ci } 3525bd8deadSopenharmony_ci if (maxcol > 1.0) { 3535bd8deadSopenharmony_ci color = lum + ((color-lum)*(1-lum)) / (maxcol-lum); 3545bd8deadSopenharmony_ci } 3555bd8deadSopenharmony_ci return color; 3565bd8deadSopenharmony_ci } 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci // Take the base RGB color <cbase> and override its luminosity 3595bd8deadSopenharmony_ci // with that of the RGB color <clum>. 3605bd8deadSopenharmony_ci vec3 SetLum(vec3 cbase, vec3 clum) { 3615bd8deadSopenharmony_ci float lbase = lumv3(cbase); 3625bd8deadSopenharmony_ci float llum = lumv3(clum); 3635bd8deadSopenharmony_ci float ldiff = llum - lbase; 3645bd8deadSopenharmony_ci vec3 color = cbase + vec3(ldiff); 3655bd8deadSopenharmony_ci return ClipColor(color); 3665bd8deadSopenharmony_ci } 3675bd8deadSopenharmony_ci 3685bd8deadSopenharmony_ci // Take the base RGB color <cbase> and override its saturation with 3695bd8deadSopenharmony_ci // that of the RGB color <csat>. The override the luminosity of the 3705bd8deadSopenharmony_ci // result with that of the RGB color <clum>. 3715bd8deadSopenharmony_ci vec3 SetLumSat(vec3 cbase, vec3 csat, vec3 clum) 3725bd8deadSopenharmony_ci { 3735bd8deadSopenharmony_ci float minbase = minv3(cbase); 3745bd8deadSopenharmony_ci float sbase = satv3(cbase); 3755bd8deadSopenharmony_ci float ssat = satv3(csat); 3765bd8deadSopenharmony_ci vec3 color; 3775bd8deadSopenharmony_ci if (sbase > 0) { 3785bd8deadSopenharmony_ci // Equivalent (modulo rounding errors) to setting the 3795bd8deadSopenharmony_ci // smallest (R,G,B) component to 0, the largest to <ssat>, 3805bd8deadSopenharmony_ci // and interpolating the "middle" component based on its 3815bd8deadSopenharmony_ci // original value relative to the smallest/largest. 3825bd8deadSopenharmony_ci color = (cbase - minbase) * ssat / sbase; 3835bd8deadSopenharmony_ci } else { 3845bd8deadSopenharmony_ci color = vec3(0.0); 3855bd8deadSopenharmony_ci } 3865bd8deadSopenharmony_ci return SetLum(color, clum); 3875bd8deadSopenharmony_ci } 3885bd8deadSopenharmony_ci 3895bd8deadSopenharmony_ci 3905bd8deadSopenharmony_ci Mode Result 3915bd8deadSopenharmony_ci -------------------- ---------------------------------------- 3925bd8deadSopenharmony_ci HSL_HUE_KHR (X,Y,Z) = (1,1,1) 3935bd8deadSopenharmony_ci f(Cs,Cd) = SetLumSat(Cs,Cd,Cd); 3945bd8deadSopenharmony_ci 3955bd8deadSopenharmony_ci HSL_SATURATION_KHR (X,Y,Z) = (1,1,1) 3965bd8deadSopenharmony_ci f(Cs,Cd) = SetLumSat(Cd,Cs,Cd); 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ci HSL_COLOR_KHR (X,Y,Z) = (1,1,1) 3995bd8deadSopenharmony_ci f(Cs,Cd) = SetLum(Cs,Cd); 4005bd8deadSopenharmony_ci 4015bd8deadSopenharmony_ci HSL_LUMINOSITY_KHR (X,Y,Z) = (1,1,1) 4025bd8deadSopenharmony_ci f(Cs,Cd) = SetLum(Cd,Cs); 4035bd8deadSopenharmony_ci 4045bd8deadSopenharmony_ci Table X.2, Hue-Saturation-Luminosity Advanced Blend Equations 4055bd8deadSopenharmony_ci 4065bd8deadSopenharmony_ci 4075bd8deadSopenharmony_ci Advanced blending equations are supported only when rendering to a single 4085bd8deadSopenharmony_ci color buffer using fragment color zero. If any non-NONE draw buffer uses 4095bd8deadSopenharmony_ci a blend equation found in table X.1 or X.2, the error INVALID_OPERATION is 4105bd8deadSopenharmony_ci generated by [[Compatibility Profile: Begin or any operation that 4115bd8deadSopenharmony_ci implicitly calls Begin (such as DrawElements)]] [[Core Profile and OpenGL 4125bd8deadSopenharmony_ci ES: DrawArrays and the other drawing commands defined in section 2.8.3]] 4135bd8deadSopenharmony_ci if: 4145bd8deadSopenharmony_ci 4155bd8deadSopenharmony_ci * the draw buffer for color output zero selects multiple color buffers 4165bd8deadSopenharmony_ci (e.g., FRONT_AND_BACK in the default framebuffer); or 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ci * the draw buffer for any other color output is not NONE. 4195bd8deadSopenharmony_ci 4205bd8deadSopenharmony_ci [[ The following paragraph applies to KHR_blend_equation_advanced only. ]] 4215bd8deadSopenharmony_ci 4225bd8deadSopenharmony_ci When using advanced blending equations, applications should split their 4235bd8deadSopenharmony_ci rendering into a collection of blending passes, none of which touch an 4245bd8deadSopenharmony_ci individual sample in the framebuffer more than once. The results of 4255bd8deadSopenharmony_ci blending are undefined if the sample being blended has been touched 4265bd8deadSopenharmony_ci previously in the same pass. The command 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci void BlendBarrierKHR(void); 4295bd8deadSopenharmony_ci 4305bd8deadSopenharmony_ci specifies a boundary between passes when using advanced blend equations. 4315bd8deadSopenharmony_ci Any command that causes the value of a sample to be modified using the 4325bd8deadSopenharmony_ci framebuffer is considered to touch the sample, including clears, blended 4335bd8deadSopenharmony_ci or unblended primitives, and BlitFramebuffer copies. 4345bd8deadSopenharmony_ci 4355bd8deadSopenharmony_ci [[ The following paragraph applies to KHR_blend_equation_advanced_coherent 4365bd8deadSopenharmony_ci only. ]] 4375bd8deadSopenharmony_ci 4385bd8deadSopenharmony_ci When using advanced blending equations, blending is typically done 4395bd8deadSopenharmony_ci coherently and in primitive order. When an individual sample is covered 4405bd8deadSopenharmony_ci by multiple primitives, blending for that sample is performed sequentially 4415bd8deadSopenharmony_ci in the order in which the primitives were submitted. This coherent 4425bd8deadSopenharmony_ci blending is enabled by default, but can be enabled or disabled by calling 4435bd8deadSopenharmony_ci Enable or Disable with the symbolic constant BLEND_ADVANCED_COHERENT_KHR. 4445bd8deadSopenharmony_ci If coherent blending is disabled, applications should split their 4455bd8deadSopenharmony_ci rendering into a collection of blending passes, none of which touch an 4465bd8deadSopenharmony_ci individual sample in the framebuffer more than once. When coherent 4475bd8deadSopenharmony_ci blending is disabled, the results of blending are undefined if the sample 4485bd8deadSopenharmony_ci being blended has been touched previously in the same pass. The command 4495bd8deadSopenharmony_ci 4505bd8deadSopenharmony_ci void BlendBarrierKHR(void); 4515bd8deadSopenharmony_ci 4525bd8deadSopenharmony_ci specifies a boundary between passes when using advanced blend equations. 4535bd8deadSopenharmony_ci Any command that causes the value of a sample to be modified using the 4545bd8deadSopenharmony_ci framebuffer is considered to touch the sample, including clears, blended 4555bd8deadSopenharmony_ci or unblended primitives, and BlitFramebuffer copies. 4565bd8deadSopenharmony_ci 4575bd8deadSopenharmony_ci Advanced blending equations require the use of a fragment shader with a 4585bd8deadSopenharmony_ci matching "blend_support" layout qualifier. If the current blend equation 4595bd8deadSopenharmony_ci is found in table X.1 or X.2, and the active fragment shader does not 4605bd8deadSopenharmony_ci include the layout qualifier matching the blend equation or 4615bd8deadSopenharmony_ci "blend_support_all_equations", the error INVALID_OPERATION is generated by 4625bd8deadSopenharmony_ci [[Compatibility Profile: Begin or any operation that implicitly calls 4635bd8deadSopenharmony_ci Begin (such as DrawElements)]] [[Core Profile and OpenGL ES: DrawArrays 4645bd8deadSopenharmony_ci and the other drawing commands defined in section 2.8.3]] The set of 4655bd8deadSopenharmony_ci layout qualifiers supported in fragment shaders is specified in sectino 4665bd8deadSopenharmony_ci 4.3.8.2 of the OpenGL Shading Language Specification. 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci 4695bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 4.1 Specification (Special Functions) 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci None. 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 4.1 Specification (State and 4745bd8deadSopenharmony_ciState Requests) 4755bd8deadSopenharmony_ci 4765bd8deadSopenharmony_ci None. 4775bd8deadSopenharmony_ci 4785bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 4.1 Specification (Invariance) 4795bd8deadSopenharmony_ci 4805bd8deadSopenharmony_ci None. 4815bd8deadSopenharmony_ci 4825bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL/EGL Specifications 4835bd8deadSopenharmony_ci 4845bd8deadSopenharmony_ci None. 4855bd8deadSopenharmony_ci 4865bd8deadSopenharmony_ciAdditions to the OpenGL Shading Language Specification, Version 4.10 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci Including the following line in a shader can be used to control the 4895bd8deadSopenharmony_ci language features described in this extension: 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci #extension GL_KHR_blend_equation_advanced : <behavior> 4925bd8deadSopenharmony_ci 4935bd8deadSopenharmony_ci where <behavior> is as specified in section 3.3. 4945bd8deadSopenharmony_ci 4955bd8deadSopenharmony_ci A new preprocessor #define is added to the OpenGL Shading Language: 4965bd8deadSopenharmony_ci 4975bd8deadSopenharmony_ci #define GL_KHR_blend_equation_advanced 1 4985bd8deadSopenharmony_ci 4995bd8deadSopenharmony_ci Modify Section 4.3.8.2, Output Layout Qualifiers, p. 47 5005bd8deadSopenharmony_ci 5015bd8deadSopenharmony_ci (add to the end of the section, p. 50) 5025bd8deadSopenharmony_ci 5035bd8deadSopenharmony_ci Fragment shaders additionally support the following layout qualifiers, 5045bd8deadSopenharmony_ci specifying a set of advanced blend equations supported when the fragment 5055bd8deadSopenharmony_ci shader is used. These layout qualifiers are only permitted on the 5065bd8deadSopenharmony_ci interface qualifier out, and use the identifiers specified in the "Layout 5075bd8deadSopenharmony_ci Qualifier" column of Table X.3. 5085bd8deadSopenharmony_ci 5095bd8deadSopenharmony_ci If a layout qualifier in Table X.3 is specified in the fragment shader, 5105bd8deadSopenharmony_ci the fragment shader may be used with the corresponding advanced blend 5115bd8deadSopenharmony_ci equation in the "Blend Equation(s) Supported" column. Additionally, the 5125bd8deadSopenharmony_ci special qualifier "blend_support_all_equations" indicates that the shader 5135bd8deadSopenharmony_ci may be used with any advanced blending equation supported by the OpenGL 5145bd8deadSopenharmony_ci Specification. It is not an error to specify more than one of these 5155bd8deadSopenharmony_ci identifiers in any fragment shader. Specifying more than one qualifier or 5165bd8deadSopenharmony_ci "blend_support_all_equations" means that the fragment shader may be used 5175bd8deadSopenharmony_ci with multiple advanced blend equations. Additionally, it is not an error 5185bd8deadSopenharmony_ci to specify any single any of these layout qualifiers more than once. 5195bd8deadSopenharmony_ci 5205bd8deadSopenharmony_ci Layout Qualifier Blend Equation(s) Supported 5215bd8deadSopenharmony_ci ------------------------ ------------------------------ 5225bd8deadSopenharmony_ci blend_support_multiply MULTIPLY_KHR 5235bd8deadSopenharmony_ci blend_support_screen SCREEN_KHR 5245bd8deadSopenharmony_ci blend_support_overlay OVERLAY_KHR 5255bd8deadSopenharmony_ci blend_support_darken DARKEN_KHR 5265bd8deadSopenharmony_ci blend_support_lighten LIGHTEN_KHR 5275bd8deadSopenharmony_ci blend_support_colordodge COLORDODGE_KHR 5285bd8deadSopenharmony_ci blend_support_colorburn COLORBURN_KHR 5295bd8deadSopenharmony_ci blend_support_hardlight HARDLIGHT_KHR 5305bd8deadSopenharmony_ci blend_support_softlight SOFTLIGHT_KHR 5315bd8deadSopenharmony_ci blend_support_difference DIFFERENCE_KHR 5325bd8deadSopenharmony_ci blend_support_exclusion EXCLUSION_KHR 5335bd8deadSopenharmony_ci blend_support_hsl_hue HSL_HUE_KHR 5345bd8deadSopenharmony_ci blend_support_hsl_saturation HSL_SATURATION_KHR 5355bd8deadSopenharmony_ci blend_support_hsl_color HSL_COLOR_KHR 5365bd8deadSopenharmony_ci blend_support_hsl_luminosity HSL_LUMINOSITY_KHR 5375bd8deadSopenharmony_ci blend_support_all_equations /all blend equations/ 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ci Table X.3, Fragment Shader Output Layout Qualifiers for Blend Support 5405bd8deadSopenharmony_ci 5415bd8deadSopenharmony_ci A draw-time error will be generated in the OpenGL API if an application 5425bd8deadSopenharmony_ci attempts to render using an advanced blending equation without having a 5435bd8deadSopenharmony_ci matching layout qualifier specified in the active fragment shader. 5445bd8deadSopenharmony_ci 5455bd8deadSopenharmony_ciGLX Protocol 5465bd8deadSopenharmony_ci 5475bd8deadSopenharmony_ci !!! TBD 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ciDependencies on OpenGL 4.0 5505bd8deadSopenharmony_ci 5515bd8deadSopenharmony_ci If OpenGL 4.0 is not supported, references to the BlendEquationi API should 5525bd8deadSopenharmony_ci be removed. 5535bd8deadSopenharmony_ci 5545bd8deadSopenharmony_ciDependencies on OpenGL 4.1 (Core Profile) 5555bd8deadSopenharmony_ci 5565bd8deadSopenharmony_ci This extension throws an INVALID_OPERATION when Begin is called if advanced 5575bd8deadSopenharmony_ci blend equations are used in conjunction with multiple draw buffers. For 5585bd8deadSopenharmony_ci the core profile of OpenGL 4.1 (and other versions of OpenGL), there is no 5595bd8deadSopenharmony_ci Begin command; instead, the error is thrown by other rendering commands 5605bd8deadSopenharmony_ci such as DrawArrays. The language in this specification documenting the 5615bd8deadSopenharmony_ci error has separate versions for the core and compatibility profiles. 5625bd8deadSopenharmony_ci 5635bd8deadSopenharmony_ciDependencies on OpenGL 4.3 or later (any Profile) 5645bd8deadSopenharmony_ci 5655bd8deadSopenharmony_ci References to Chapter 4 are replaced with references to Chapter 17 (Writing 5665bd8deadSopenharmony_ci Fragments and Samples to the Framebuffer). 5675bd8deadSopenharmony_ci References to section 4.1.8 are replaced with references to section 17.3.8. 5685bd8deadSopenharmony_ci References to Table 4.1 are replace with references to Table 17.1. 5695bd8deadSopenharmony_ci References to section 2.1.1 are replaced with references to section 2.3.3. 5705bd8deadSopenharmony_ci 5715bd8deadSopenharmony_ciDependencies on OpenGL ES 2.0 5725bd8deadSopenharmony_ci 5735bd8deadSopenharmony_ci If unextended OpenGL ES 2.0 is supported, references to BlendEquationi, 5745bd8deadSopenharmony_ci BlendEquationSeparatei, GetInteger64v, and GetDoublev should be ignored. 5755bd8deadSopenharmony_ci 5765bd8deadSopenharmony_ci Ignore any references to multiple draw buffers if EXT_draw_buffers or 5775bd8deadSopenharmony_ci NV_draw_buffers is not supported. 5785bd8deadSopenharmony_ci 5795bd8deadSopenharmony_ciDependencies on EXT_blend_minmax 5805bd8deadSopenharmony_ci 5815bd8deadSopenharmony_ci Requires EXT_blend_minmax on OpenGL ES 2.0 implementations and references 5825bd8deadSopenharmony_ci to MIN and MAX should be replace by references to MIN_EXT and MAX_EXT as 5835bd8deadSopenharmony_ci introduced by that extension. 5845bd8deadSopenharmony_ci 5855bd8deadSopenharmony_ciDependencies on OpenGL ES 3.0 5865bd8deadSopenharmony_ci 5875bd8deadSopenharmony_ci If unextended OpenGL ES 3.0 is supported, references to BlendEquationi, 5885bd8deadSopenharmony_ci BlendEquationSeparatei, and GetDoublev should be ignored. 5895bd8deadSopenharmony_ci 5905bd8deadSopenharmony_ciDependencies on NV_path_rendering 5915bd8deadSopenharmony_ci 5925bd8deadSopenharmony_ci When NV_path_rendering is supported, covering geometry generated by the 5935bd8deadSopenharmony_ci commands CoverFillPathNV, CoverFillPathInstancedNV, CoverStrokePathNV, and 5945bd8deadSopenharmony_ci CoverStrokePathInstancedNV will automatically be blended coherently 5955bd8deadSopenharmony_ci relative to previous geometry when using the blend equations in this 5965bd8deadSopenharmony_ci extension. This guarantee is provided even on implementations supporting 5975bd8deadSopenharmony_ci only NV_blend_equation_advanced. 5985bd8deadSopenharmony_ci 5995bd8deadSopenharmony_ci Insert the following language after the discussion of the 6005bd8deadSopenharmony_ci BlendBarrierKHR() command for both extensions: 6015bd8deadSopenharmony_ci 6025bd8deadSopenharmony_ci [[ For KHR_blend_equation_advanced only: ]] 6035bd8deadSopenharmony_ci 6045bd8deadSopenharmony_ci The commands CoverFillPathNV, CoverFillPathInstancedNV, 6055bd8deadSopenharmony_ci CoverStrokePathNV, and CoverStrokePathInstancedNV are considered to 6065bd8deadSopenharmony_ci start a new blending pass, as though BlendBarrierKHR were called prior 6075bd8deadSopenharmony_ci to the cover operation. If a cover primitive is followed by subsequent 6085bd8deadSopenharmony_ci non-cover primitives using advanced blend equations and touching the 6095bd8deadSopenharmony_ci same samples, applications must call BlendBarrierKHR after the cover 6105bd8deadSopenharmony_ci primitives to ensure defined blending results. 6115bd8deadSopenharmony_ci 6125bd8deadSopenharmony_ci [[ For KHR_blend_equation_advanced_coherent, the language immediately 6135bd8deadSopenharmony_ci above should be used, but the first sentence should be prefixed with 6145bd8deadSopenharmony_ci "When coherent blending is disabled, ...". ]] 6155bd8deadSopenharmony_ci 6165bd8deadSopenharmony_ci 6175bd8deadSopenharmony_ciErrors 6185bd8deadSopenharmony_ci 6195bd8deadSopenharmony_ci If any non-NONE draw buffer uses a blend equation found in table X.1 or 6205bd8deadSopenharmony_ci X.2, the error INVALID_OPERATION is generated by Begin or any operation 6215bd8deadSopenharmony_ci that implicitly calls Begin (such as DrawElements) if: 6225bd8deadSopenharmony_ci 6235bd8deadSopenharmony_ci * the draw buffer for color output zero selects multiple color buffers 6245bd8deadSopenharmony_ci (e.g., FRONT_AND_BACK in the default framebuffer); or 6255bd8deadSopenharmony_ci 6265bd8deadSopenharmony_ci * the draw buffer for any other color output is not NONE. 6275bd8deadSopenharmony_ci 6285bd8deadSopenharmony_ciNew State 6295bd8deadSopenharmony_ci Initial 6305bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec Attribute 6315bd8deadSopenharmony_ci -------------------- ---- ------------ ------------ ------------------------ ----- ------------ 6325bd8deadSopenharmony_ci BLEND_ADVANCED_ B IsEnabled TRUE are advanced blending 4.1.8 color-buffer 6335bd8deadSopenharmony_ci COHERENT_KHR equations guaranteed to 6345bd8deadSopenharmony_ci be evaluated coherently? 6355bd8deadSopenharmony_ci 6365bd8deadSopenharmony_ci Note: The BLEND_ADVANCED_COHERENT_KHR enable is provided if and only if 6375bd8deadSopenharmony_ci the KHR_blend_equation_advanced_coherent extension is supported. On 6385bd8deadSopenharmony_ci implementations supporting only KHR_blend_equation_advanced, this enable 6395bd8deadSopenharmony_ci is considered not to exist. 6405bd8deadSopenharmony_ci 6415bd8deadSopenharmony_ciNew Implementation Dependent State 6425bd8deadSopenharmony_ci 6435bd8deadSopenharmony_ci None. 6445bd8deadSopenharmony_ci 6455bd8deadSopenharmony_ciIssues 6465bd8deadSopenharmony_ci 6475bd8deadSopenharmony_ci Note: These issues apply specifically to the definition of the 6485bd8deadSopenharmony_ci KHR_blend_equation_advanced specification, which was derived from the 6495bd8deadSopenharmony_ci extension NV_blend_equation_advanced. The issues from the original 6505bd8deadSopenharmony_ci NV_blend_equation_advanced specification have been removed, but can be 6515bd8deadSopenharmony_ci found (as of August 2013) in the OpenGL Registry at: 6525bd8deadSopenharmony_ci 6535bd8deadSopenharmony_ci http://www.opengl.org/registry/specs/NV/blend_equation_advanced.txt 6545bd8deadSopenharmony_ci 6555bd8deadSopenharmony_ci (0) How does this extension differ from the NV_blend_equation_advanced 6565bd8deadSopenharmony_ci extension for OpenGL and OpenGL ES? 6575bd8deadSopenharmony_ci 6585bd8deadSopenharmony_ci RESOLVED: A number of features have been removed from 6595bd8deadSopenharmony_ci NV_blend_equation_advanced, including: 6605bd8deadSopenharmony_ci 6615bd8deadSopenharmony_ci * The BlendParameterivNV API has been removed, and with it, the 6625bd8deadSopenharmony_ci BLEND_PREMULTIPLIED_SRC_NV and BLEND_OVERLAP_NV parameters. The spec 6635bd8deadSopenharmony_ci has been refactored to assume premultipled source colors and 6645bd8deadSopenharmony_ci uncorrelated source and destination coverage. 6655bd8deadSopenharmony_ci 6665bd8deadSopenharmony_ci * A number of less commonly used blend modes have been removed, 6675bd8deadSopenharmony_ci including: 6685bd8deadSopenharmony_ci 6695bd8deadSopenharmony_ci - certain "X/Y/Z" blending modes supported by few, if any, standards 6705bd8deadSopenharmony_ci (INVERT, INVERT_RGB_NV, LINEARDODGE_NV, LINEARBURN_NV, 6715bd8deadSopenharmony_ci VIVIDLIGHT_NV, LINEARLIGHT_NV, PINLIGHT_NV, HARDMIX_NV) 6725bd8deadSopenharmony_ci 6735bd8deadSopenharmony_ci - various versions of additive and subtractive modes (PLUS_NV, 6745bd8deadSopenharmony_ci PLUS_CLAMPED_NV, PLUS_CLAMPED_ALPHA_NV, PLUS_DARKER_NV, MINUS_NV, 6755bd8deadSopenharmony_ci MINUS_CLAMPED_NV) 6765bd8deadSopenharmony_ci 6775bd8deadSopenharmony_ci - other uncommon miscellaneous modes (CONTRAST_NV, INVERT_OVG_NV, 6785bd8deadSopenharmony_ci RED, GREEN, BLUE) 6795bd8deadSopenharmony_ci 6805bd8deadSopenharmony_ci Additionally, this extension adds blending support layout qualifiers to 6815bd8deadSopenharmony_ci the fragment shader (qualifying "out"). Each fragment shader can 6825bd8deadSopenharmony_ci specify a set of advanced blend equations that can be used when it is 6835bd8deadSopenharmony_ci active. For example: 6845bd8deadSopenharmony_ci 6855bd8deadSopenharmony_ci layout(blend_support_hardlight, blend_support_softlight) out; 6865bd8deadSopenharmony_ci 6875bd8deadSopenharmony_ci specifies that the HARDLIGHT_KHR and SOFTLIGHT_KHR equations are allowed 6885bd8deadSopenharmony_ci when using the shader. A draw-time error will be generated if an 6895bd8deadSopenharmony_ci advanced blend equation is enabled in the API and a matching layout 6905bd8deadSopenharmony_ci qualifier is not specified in the active fragment shader. 6915bd8deadSopenharmony_ci 6925bd8deadSopenharmony_ci (1) What should we do about the BLEND_PREMULTIPLIED_SRC_NV blend parameter 6935bd8deadSopenharmony_ci from NV_blend_equation_advanced? 6945bd8deadSopenharmony_ci 6955bd8deadSopenharmony_ci RESOLVED: Remove this parameter for simplicity. All equations in this 6965bd8deadSopenharmony_ci extension assume that the source and destination colors are both 6975bd8deadSopenharmony_ci premultiplied. 6985bd8deadSopenharmony_ci 6995bd8deadSopenharmony_ci (2) What should we do about the BLEND_OVERLAP_NV blend parameter from 7005bd8deadSopenharmony_ci NV_blend_equation_advanced? 7015bd8deadSopenharmony_ci 7025bd8deadSopenharmony_ci RESOLVED: Remove this parameter for simplicitly. All equations in this 7035bd8deadSopenharmony_ci extension assume an UNCORRELATED_NV overlap mode. Blending using the 7045bd8deadSopenharmony_ci UNCORRELATED_NV overlap mode is usually mathematically simpler than 7055bd8deadSopenharmony_ci blending using the DISJOINT_NV or CONJOINT_NV modes. 7065bd8deadSopenharmony_ci 7075bd8deadSopenharmony_ci (3) What set of "complex" blending equations should we support in this 7085bd8deadSopenharmony_ci extension? 7095bd8deadSopenharmony_ci 7105bd8deadSopenharmony_ci RESOLVED: During standardization of this extensions, the set of 7115bd8deadSopenharmony_ci equations provided in this extension has been reduced to a smaller 7125bd8deadSopenharmony_ci subset for simplicitly. The remaining equations are typically found in 7135bd8deadSopenharmony_ci a wide collection of compositing standards. In particular, the 7145bd8deadSopenharmony_ci standarization process removed several classes of blend equations from 7155bd8deadSopenharmony_ci the NV_blend_equation_advanced, as described in "differences" issue (0) 7165bd8deadSopenharmony_ci above. 7175bd8deadSopenharmony_ci 7185bd8deadSopenharmony_ci (4) Should we support the "Porter-Duff" blend equations (e.g., 7195bd8deadSopenharmony_ci SRC_OVER_NV) from NV_blend_equation_advanced? 7205bd8deadSopenharmony_ci 7215bd8deadSopenharmony_ci RESOLVED: All of these blend equations should be supportable in 7225bd8deadSopenharmony_ci unextended OpenGL ES 3.0, and have been removed for simplicity. The 7235bd8deadSopenharmony_ci primary rationale for this decision is to reduce the number of internal 7245bd8deadSopenharmony_ci paths required by the driver; some implementations may have separate 7255bd8deadSopenharmony_ci paths for traditional OpenGL blending and for the new advanced blending 7265bd8deadSopenharmony_ci equations. Redirecting "simple" advanced blending equations to 7275bd8deadSopenharmony_ci traditional fixed-function blending hardware may involved more driver 7285bd8deadSopenharmony_ci implementation work and may have different performance characteristics 7295bd8deadSopenharmony_ci than other "complex" blending equations. 7305bd8deadSopenharmony_ci 7315bd8deadSopenharmony_ci This approach does mean that an application wanting to use both 7325bd8deadSopenharmony_ci Porter-Duff blend equations and advanced blending equations provided by 7335bd8deadSopenharmony_ci this extension will need GL_to program blending somewhat differently 7345bd8deadSopenharmony_ci when using the Porter-Duff equations: 7355bd8deadSopenharmony_ci 7365bd8deadSopenharmony_ci if (isPorterDuff(equation)) { 7375bd8deadSopenharmony_ci glBlendEquation(GL_FUNC_ADD); // enable sf*S+df*D blending 7385bd8deadSopenharmony_ci glBlendFunc(srcFactor, dstFactor); // and program blend factors 7395bd8deadSopenharmony_ci } else { 7405bd8deadSopenharmony_ci glBlendEquation(equation); // advanced eqs. don't use BlendFunc 7415bd8deadSopenharmony_ci } 7425bd8deadSopenharmony_ci 7435bd8deadSopenharmony_ci (5) Should we impose any requirements on fragment shaders when used in 7445bd8deadSopenharmony_ci conjunction with advanced blend equations? 7455bd8deadSopenharmony_ci 7465bd8deadSopenharmony_ci RESOLVED: Yes. This extension adds fragment shader layout qualifiers 7475bd8deadSopenharmony_ci allowing individual shaders to specify that they will be used with one 7485bd8deadSopenharmony_ci or multiple advanced blending equations. When using an advanced 7495bd8deadSopenharmony_ci blending equation from this extension, it is necessary to use a fragment 7505bd8deadSopenharmony_ci shader with a matching layout qualifier. A draw-time error will be 7515bd8deadSopenharmony_ci generated if the current fragment shader doesn't include a layout 7525bd8deadSopenharmony_ci qualifier matching the current advanced blending mode. 7535bd8deadSopenharmony_ci 7545bd8deadSopenharmony_ci The rationale for this decision is that some implementations of this 7555bd8deadSopenharmony_ci extension may require special fragment shader code when using advanced 7565bd8deadSopenharmony_ci blending equations, and may perhaps perform the entire blending 7575bd8deadSopenharmony_ci operation in the fragment shader. Knowing the set of blending equations 7585bd8deadSopenharmony_ci that a fragment shader will be used with at compile time may reduce the 7595bd8deadSopenharmony_ci extent of run-time fragment shader re-compilation when the shader is 7605bd8deadSopenharmony_ci used. 7615bd8deadSopenharmony_ci 7625bd8deadSopenharmony_ci Note that NV_blend_equation_advanced doesn't include layout qualifiers 7635bd8deadSopenharmony_ci or the draw-time error specified here. 7645bd8deadSopenharmony_ci 7655bd8deadSopenharmony_ci (6) How do we handle coherency when a fragment is hit multiple times? 7665bd8deadSopenharmony_ci 7675bd8deadSopenharmony_ci RESOLVED: In this extension, blending equations will be done coherently 7685bd8deadSopenharmony_ci and in primitive order by default, as is the case with traditional 7695bd8deadSopenharmony_ci blending in OpenGL and OpenGL ES. 7705bd8deadSopenharmony_ci 7715bd8deadSopenharmony_ci The NVIDIA extension provides two separate extension string entries: 7725bd8deadSopenharmony_ci 7735bd8deadSopenharmony_ci * NV_blend_equation_advanced 7745bd8deadSopenharmony_ci * NV_blend_equation_advanced_coherent 7755bd8deadSopenharmony_ci 7765bd8deadSopenharmony_ci Exposing the former without the latter signals that the implementation 7775bd8deadSopenharmony_ci can support blending with these equations, but is unable to ensure that 7785bd8deadSopenharmony_ci fragments are blended in order when the same (x,y) is touched multiple 7795bd8deadSopenharmony_ci times. To ensure coherent results and proper ordering using the 7805bd8deadSopenharmony_ci non-coherent version of the extension, an application must separate its 7815bd8deadSopenharmony_ci rendering into "passes" that touch each (x,y) at most once, and call 7825bd8deadSopenharmony_ci BlendBarrierNV between passes. There are important use cases (e.g., 7835bd8deadSopenharmony_ci many path rendering algorithms) where this limitation isn't too 7845bd8deadSopenharmony_ci restrictive, and NVIDIA chose to expose the non-coherent version to 7855bd8deadSopenharmony_ci allow the functionality to be used on a larger set of GPUs. 7865bd8deadSopenharmony_ci 7875bd8deadSopenharmony_ci This extension is functionally comparable to an implementation of the 7885bd8deadSopenharmony_ci NVIDIA extension exposing both strings, where coherent behavior is 7895bd8deadSopenharmony_ci enabled by default. NV_blend_equation_advanced_coherent and this 7905bd8deadSopenharmony_ci extension both provide the ability to opt out of this automatic 7915bd8deadSopenharmony_ci coherence by disabling BLEND_ADVANCED_COHERENT_KHR and using 7925bd8deadSopenharmony_ci BlendBarrierKHR manually. This could theoretically result in higher 7935bd8deadSopenharmony_ci performance -- see issue (32) of the NVIDIA extension for more 7945bd8deadSopenharmony_ci discussion. 7955bd8deadSopenharmony_ci 7965bd8deadSopenharmony_ci (7) How should the blend equations COLORDODGE_KHR and COLORBURN_KHR be 7975bd8deadSopenharmony_ci expressed mathematically? 7985bd8deadSopenharmony_ci 7995bd8deadSopenharmony_ci RESOLVED: NVIDIA changed the definition of these equations after the 8005bd8deadSopenharmony_ci NV_blend_equation_advanced spec was originally published, as discussed 8015bd8deadSopenharmony_ci below. These changes add new special cases to the COLORDODGE_KHR and 8025bd8deadSopenharmony_ci COLORBURN_KHR equations that are found in newer compositing standard 8035bd8deadSopenharmony_ci specifications and in a number of implementations of old and new 8045bd8deadSopenharmony_ci standards. They believe that the omission of the special case in other 8055bd8deadSopenharmony_ci older specifications is a bug. They have no plans to add new blend 8065bd8deadSopenharmony_ci equation tokens to support "equivalent" modes without the new special 8075bd8deadSopenharmony_ci case. We are adopting the same approach in this extension. 8085bd8deadSopenharmony_ci 8095bd8deadSopenharmony_ci Note, however, that older versions of this extension and older NVIDIA 8105bd8deadSopenharmony_ci drivers implementing it will lack these special cases. A driver update 8115bd8deadSopenharmony_ci may be required to get the new behavior. 8125bd8deadSopenharmony_ci 8135bd8deadSopenharmony_ci There is some disagreement in different published specifications about 8145bd8deadSopenharmony_ci how these two blend equations should be handled. At the time the NVIDIA 8155bd8deadSopenharmony_ci extension was initially developed, all specifications they found that 8165bd8deadSopenharmony_ci specified blending equations mathematically (see issue 28 of 8175bd8deadSopenharmony_ci NV_blend_equation_advanced) were written the same way. Since then, they 8185bd8deadSopenharmony_ci discovered that newer working drafts of the W3C Compositing and Blending 8195bd8deadSopenharmony_ci Level 1 specification (for CSS and SVG) express "color-burn" as follows 8205bd8deadSopenharmony_ci (translated to our nomenclature): 8215bd8deadSopenharmony_ci 8225bd8deadSopenharmony_ci if (Cd == 1) // their Cb (backdrop) is our Cd (destination) 8235bd8deadSopenharmony_ci f(Cs,Cd) = 1 // their B() is our f() 8245bd8deadSopenharmony_ci else if (Cs == 0) 8255bd8deadSopenharmony_ci f(Cs,Cd) = 0 8265bd8deadSopenharmony_ci else 8275bd8deadSopenharmony_ci f(Cs,Cd) = 1 - min(1, (1-Cd)/Cs) 8285bd8deadSopenharmony_ci 8295bd8deadSopenharmony_ci http://www.w3.org/TR/2013/WD-compositing-1-20131010/ 8305bd8deadSopenharmony_ci #blendingcolorburn 8315bd8deadSopenharmony_ci 8325bd8deadSopenharmony_ci Earlier versions of the same W3C specification, an older SVG compositing 8335bd8deadSopenharmony_ci draft specification, the Adobe PDF specification (and the ISO 32000-1 8345bd8deadSopenharmony_ci standard), and the KHR_advanced_blending extension to OpenVG all specify 8355bd8deadSopenharmony_ci the following equation without the initial special case: 8365bd8deadSopenharmony_ci 8375bd8deadSopenharmony_ci if (Cs == 0) 8385bd8deadSopenharmony_ci f(Cs,Cd) = 0 8395bd8deadSopenharmony_ci else 8405bd8deadSopenharmony_ci f(Cs,Cd) = 1 - min(1, (1-Cd)/Cs) 8415bd8deadSopenharmony_ci 8425bd8deadSopenharmony_ci http://www.w3.org/TR/2012/WD-compositing-20120816/ 8435bd8deadSopenharmony_ci #blendingcolorburn 8445bd8deadSopenharmony_ci http://www.w3.org/TR/2011/WD-SVGCompositing-20110315/ 8455bd8deadSopenharmony_ci http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/ 8465bd8deadSopenharmony_ci pdfs/pdf_reference_1-7.pdf 8475bd8deadSopenharmony_ci http://www.khronos.org/registry/vg/extensions/KHR/ 8485bd8deadSopenharmony_ci advanced_blending.txt 8495bd8deadSopenharmony_ci 8505bd8deadSopenharmony_ci For the Adobe PDF specification, the corrected blend equations are 8515bd8deadSopenharmony_ci published in an Adobe supplement to ISO 32000-1 and are expected to be 8525bd8deadSopenharmony_ci accepted in a future version of the standard: 8535bd8deadSopenharmony_ci 8545bd8deadSopenharmony_ci http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/ 8555bd8deadSopenharmony_ci devnet/pdf/pdfs/adobe_supplement_iso32000_1.pdf 8565bd8deadSopenharmony_ci 8575bd8deadSopenharmony_ci The author's understanding is that multiple shipping implementations of 8585bd8deadSopenharmony_ci these blending modes implement the special case for "Cd==1" above, 8595bd8deadSopenharmony_ci including various Adobe products and the open-source Ghostscript 8605bd8deadSopenharmony_ci project. 8615bd8deadSopenharmony_ci 8625bd8deadSopenharmony_ci We believe that the extra special case in this specification is 8635bd8deadSopenharmony_ci consistent with the physical model of color burning. Burning is 8645bd8deadSopenharmony_ci described in 8655bd8deadSopenharmony_ci 8665bd8deadSopenharmony_ci http://en.wikipedia.org/wiki/Dodging_and_burning 8675bd8deadSopenharmony_ci 8685bd8deadSopenharmony_ci as making a print with normal exposure, and then adding additional 8695bd8deadSopenharmony_ci exposure to darken the overall image. In the general equation: 8705bd8deadSopenharmony_ci 8715bd8deadSopenharmony_ci 1 - min(1, (1-Cd)/Cs) 8725bd8deadSopenharmony_ci 8735bd8deadSopenharmony_ci Cs operates as a sort of fudge factor where a value of 1.0 implies no 8745bd8deadSopenharmony_ci additional exposure time and 0.0 implies arbitrarily long additional 8755bd8deadSopenharmony_ci exposure time, where the initial amount of exposure (1-Cd) is multiplied 8765bd8deadSopenharmony_ci by 1/Cs and then clamped to maximum exposure by the min() operation. 8775bd8deadSopenharmony_ci The Cd==1 special case here implies that we get zero exposure in the 8785bd8deadSopenharmony_ci initial print, since 1-Cd==0. No amount of extra exposure time will 8795bd8deadSopenharmony_ci generate any additional exposure. This would imply that the final 8805bd8deadSopenharmony_ci result should have zero exposure and thus a final f() value of 1. This 8815bd8deadSopenharmony_ci matches the initial special case. Without that special case, we would 8825bd8deadSopenharmony_ci hit the second special case if Cs==0 (infinite exposure time), which 8835bd8deadSopenharmony_ci would yield an incorrect final value of 0 (full exposure). 8845bd8deadSopenharmony_ci 8855bd8deadSopenharmony_ci A similar issue applies to COLORDODGE_KHR, where some specifications 8865bd8deadSopenharmony_ci include a special case for Cb==0 while others do not. We have added a 8875bd8deadSopenharmony_ci special case there as well. 8885bd8deadSopenharmony_ci 8895bd8deadSopenharmony_ci (8) The NV_blend_equation_advanced extension has two variants: 8905bd8deadSopenharmony_ci NV_blend_equation_advanced and NV_blend_equation_advanced_coherent. 8915bd8deadSopenharmony_ci Some implementations of that extension are not capable of performing 8925bd8deadSopenharmony_ci fully coherent blending when samples are touched more than once 8935bd8deadSopenharmony_ci without a barrier, and may expose only the former. Should we follow 8945bd8deadSopenharmony_ci this pattern here or support only the "coherent" variant? 8955bd8deadSopenharmony_ci 8965bd8deadSopenharmony_ci RESOLVED: Yes. The working group originally decided to support only 8975bd8deadSopenharmony_ci the "coherent" variant (revision 4) for simplicity but later decided to 8985bd8deadSopenharmony_ci support both extension string entries as some implementations on both 8995bd8deadSopenharmony_ci OpenGL and OpenGL ES are unable to support the "coherent" variant. 9005bd8deadSopenharmony_ci Applications not wanting to manage coherency manually should look for 9015bd8deadSopenharmony_ci the KHR_blend_equation_advanced_coherent extension and ignore 9025bd8deadSopenharmony_ci KHR_blend_equation_advanced. 9035bd8deadSopenharmony_ci 9045bd8deadSopenharmony_ci (9) We don't permit the use of advanced blend equations with multiple draw 9055bd8deadSopenharmony_ci buffers. Should we produce compile-, link-, or draw-time errors if we 9065bd8deadSopenharmony_ci encounter a shader that includes both (a) one or more layout 9075bd8deadSopenharmony_ci qualifiers indicating that the shader wants to use advanced blending 9085bd8deadSopenharmony_ci and (b) a color output with a location other than zero? 9095bd8deadSopenharmony_ci 9105bd8deadSopenharmony_ci RESOLVED: No. 9115bd8deadSopenharmony_ci 9125bd8deadSopenharmony_ci In the current extension, there is a draw-time error generated if you 9135bd8deadSopenharmony_ci try to use one of the new blend equations with multiple color targets 9145bd8deadSopenharmony_ci (glDrawBuffers with a count > 1). With this restriction, any "extra" 9155bd8deadSopenharmony_ci fragment shader color outputs could never be successfully blended into 9165bd8deadSopenharmony_ci the framebuffer with one of these equations. 9175bd8deadSopenharmony_ci 9185bd8deadSopenharmony_ci When only one draw buffer is enabled when using a shader with multiple 9195bd8deadSopenharmony_ci outputs, "extra" outputs will simply be dropped and have no effect on 9205bd8deadSopenharmony_ci the framebuffer. You can already do this in unextended OpenGL and 9215bd8deadSopenharmony_ci OpenGL ES without generating an error. We didn't feel that the value of 9225bd8deadSopenharmony_ci such a warning/error justifies the draw-time overhead needed to detect 9235bd8deadSopenharmony_ci and report such a condition. 9245bd8deadSopenharmony_ci 9255bd8deadSopenharmony_ci Since this extension requires that you declare the intent to use 9265bd8deadSopenharmony_ci advanced blending using layout qualifers, it is possible to identify a 9275bd8deadSopenharmony_ci shader that may want to use "extra" color outputs with advanced blending 9285bd8deadSopenharmony_ci at compile time, with no draw-time overhead. We decided not to treat 9295bd8deadSopenharmony_ci this condition as an error for several reasons: 9305bd8deadSopenharmony_ci 9315bd8deadSopenharmony_ci - Advanced blending layout qualifiers don't require that blending 9325bd8deadSopenharmony_ci actually be enabled. Multiple draw buffers with multiple outputs 9335bd8deadSopenharmony_ci work just fine in that case. 9345bd8deadSopenharmony_ci 9355bd8deadSopenharmony_ci - If we treated this condition as an error and a future extension 9365bd8deadSopenharmony_ci relaxed the DrawBuffers restriction, it would be necessary to also 9375bd8deadSopenharmony_ci add a GLSL language feature to disable the now-undesirable error. 9385bd8deadSopenharmony_ci 9395bd8deadSopenharmony_ci (10) What happens when converting a premultiplied color with an alpha of 9405bd8deadSopenharmony_ci zero to a non-premultiplied color? 9415bd8deadSopenharmony_ci 9425bd8deadSopenharmony_ci RESOLVED: We specify that a premultiplied color of (0,0,0,0) should 9435bd8deadSopenharmony_ci produce non-premultiplied (R,G,B) values of (0,0,0). A premultiplied 9445bd8deadSopenharmony_ci color with an alpha of zero and a non-zero R, G, or B component is 9455bd8deadSopenharmony_ci considered to be ill-formed and will produce undefined blending results. 9465bd8deadSopenharmony_ci 9475bd8deadSopenharmony_ci For a non-premultiplied color (R',G',B',A'), the corresponding 9485bd8deadSopenharmony_ci premultiplied color (R,G,B,A) should satisfy the equation: 9495bd8deadSopenharmony_ci 9505bd8deadSopenharmony_ci (R,G,B,A) = (R'*A', G'*A', B'*A', A') 9515bd8deadSopenharmony_ci 9525bd8deadSopenharmony_ci If the alpha of a non-premultiplied color is zero, the corresponding 9535bd8deadSopenharmony_ci premultiplied color (R,G,B,A) should be (0,0,0,0). 9545bd8deadSopenharmony_ci 9555bd8deadSopenharmony_ci We specify that ill-formed premultiplied colors produce undefined 9565bd8deadSopenharmony_ci blending results to enable certain performance optimizations. In many 9575bd8deadSopenharmony_ci of these blending equations, the alpha component used as a denominator 9585bd8deadSopenharmony_ci to compute the non-premultiplied color ends up being multiplied by the 9595bd8deadSopenharmony_ci same alpha component in the coverage, resulting in cancellation. For 9605bd8deadSopenharmony_ci example, implementations may want to substitute a premultiplied 9615bd8deadSopenharmony_ci destination color into the last term of the basic blend equation: 9625bd8deadSopenharmony_ci 9635bd8deadSopenharmony_ci R = f(Rs',Rd')*p0(As,Ad) + Y*Rs'*p1(As,Ad) + Z*Rd'*p2(As,Ad) 9645bd8deadSopenharmony_ci = ... + Z*Rd'*(Ad*(1-As)) 9655bd8deadSopenharmony_ci = ... + Z*(Rd'*Ad)*(1-As) 9665bd8deadSopenharmony_ci = ... + Z* Rd * (1-As) 9675bd8deadSopenharmony_ci 9685bd8deadSopenharmony_ci This substitution would be invalid for ill-formed premultiplied 9695bd8deadSopenharmony_ci destination colors. We choose to specify undefined results for invalid 9705bd8deadSopenharmony_ci input colors rather than requiring implementations to skip such 9715bd8deadSopenharmony_ci optimizations or include logic to check for zero alpha values for each 9725bd8deadSopenharmony_ci input. 9735bd8deadSopenharmony_ci 9745bd8deadSopenharmony_ci (11) For "HSL" blend equations, the blend equation involves a clipping 9755bd8deadSopenharmony_ci step where colors may be "clipped" if the blend would produce 9765bd8deadSopenharmony_ci components are outside the range [0,1]. Are there inputs where this 9775bd8deadSopenharmony_ci blend could produce ill-defined or nonsensical results? 9785bd8deadSopenharmony_ci 9795bd8deadSopenharmony_ci RESOLVED: Yes, the results of HSL blend equations are undefined if the 9805bd8deadSopenharmony_ci input colors have components outside the range [0,1]. Even if the input 9815bd8deadSopenharmony_ci colors are in-range, the basic color adjustment done in these blends 9825bd8deadSopenharmony_ci could produce result components outside the range [0,1]. To compensate, 9835bd8deadSopenharmony_ci the ClipColor() function in the specification interpolates the result 9845bd8deadSopenharmony_ci color and a greyscale value that matches the luminance of the result. 9855bd8deadSopenharmony_ci The math for the clipping operation assumes the luminance of the result 9865bd8deadSopenharmony_ci color is in the range [0,1]. If that isn't the case, the clipping 9875bd8deadSopenharmony_ci operation could result in a divide by zero (when all result components 9885bd8deadSopenharmony_ci have the same out-of-bounds value) or perform an otherwise nonsensical 9895bd8deadSopenharmony_ci computation. 9905bd8deadSopenharmony_ci 9915bd8deadSopenharmony_ci 9925bd8deadSopenharmony_ciRevision History 9935bd8deadSopenharmony_ci 9945bd8deadSopenharmony_ci Revision 17, February 14, 2018 9955bd8deadSopenharmony_ci 9965bd8deadSopenharmony_ci Fix ClipColor() equation where in the "if (maxcol > 1.0)" body the 9975bd8deadSopenharmony_ci "(color-lum)*lum" term should have been "(color-lum)*(1-lum)". Also 9985bd8deadSopenharmony_ci add new issue 11 for the case where the inputs to SetLum() are outside 9995bd8deadSopenharmony_ci the range [0..1] and could cause a divide-by-zero in ClipColor(). 10005bd8deadSopenharmony_ci 10015bd8deadSopenharmony_ci Revision 16, April 16, 2016 (from a September 30, 2014 edit that wasn't 10025bd8deadSopenharmony_ci published) 10035bd8deadSopenharmony_ci 10045bd8deadSopenharmony_ci Fix incorrectly specified color clamping in the HSL blend modes. 10055bd8deadSopenharmony_ci 10065bd8deadSopenharmony_ci Revision 15, May 9, 2015 10075bd8deadSopenharmony_ci 10085bd8deadSopenharmony_ci Renumber as OpenGL ARB extension instead of vendor extension, by 10095bd8deadSopenharmony_ci symmetry with other KHR Khronos-approved extensions. Add copyright 10105bd8deadSopenharmony_ci notice. 10115bd8deadSopenharmony_ci 10125bd8deadSopenharmony_ci Revision 14, March 14, 2014 10135bd8deadSopenharmony_ci 10145bd8deadSopenharmony_ci Cast as KHR extension. 10155bd8deadSopenharmony_ci 10165bd8deadSopenharmony_ci Revisions 12 and 13, March 5, 2014 10175bd8deadSopenharmony_ci 10185bd8deadSopenharmony_ci For non-coherent blending, clarify that all writes to a sample are 10195bd8deadSopenharmony_ci considered to "touch" that sample and require a BlendBarrierKHR call 10205bd8deadSopenharmony_ci before blending overlapping geometry. Clears, non-blended geometry, and 10215bd8deadSopenharmony_ci copies by BlitFramebuffer or TexSubImage are all considered to "touch" a 10225bd8deadSopenharmony_ci sample (bug 11738). Specify that non-premultiplied values corresponding 10235bd8deadSopenharmony_ci to ill-conditioned premultiplied colors such as (1,1,1,0) are undefined 10245bd8deadSopenharmony_ci (bug 11739). Add issue (10) related to the ill-conditioned 10255bd8deadSopenharmony_ci premultiplied color issue. 10265bd8deadSopenharmony_ci 10275bd8deadSopenharmony_ci Revision 11, January 30, 2014 10285bd8deadSopenharmony_ci 10295bd8deadSopenharmony_ci Cast as OES extension. 10305bd8deadSopenharmony_ci 10315bd8deadSopenharmony_ci Revision 10, January 22, 2014 10325bd8deadSopenharmony_ci 10335bd8deadSopenharmony_ci Add issue (9), where we decided not to add compile- or link-time errors 10345bd8deadSopenharmony_ci when using both advanced blending and multiple color outputs (bug 10355bd8deadSopenharmony_ci 11468). 10365bd8deadSopenharmony_ci 10375bd8deadSopenharmony_ci Revision 9, January 2, 2014 10385bd8deadSopenharmony_ci 10395bd8deadSopenharmony_ci Fix typo in issue (0). 10405bd8deadSopenharmony_ci 10415bd8deadSopenharmony_ci Revision 8, November 6, 2013 10425bd8deadSopenharmony_ci 10435bd8deadSopenharmony_ci Restore support for non-coherent-only implementations that was removed 10445bd8deadSopenharmony_ci in revision 4. Fix the language about non-coherent blending to specify 10455bd8deadSopenharmony_ci that results are undefined only if an individual *sample* is touched 10465bd8deadSopenharmony_ci more than once (instead of *pixel*). Minor language tweaks to use 10475bd8deadSopenharmony_ci "equations" consistently, instead of sometimes using "modes". 10485bd8deadSopenharmony_ci 10495bd8deadSopenharmony_ci Revision 7, October 21, 2013 10505bd8deadSopenharmony_ci 10515bd8deadSopenharmony_ci Add a reference to the Adobe supplement to ISO 32000-1, which includes 10525bd8deadSopenharmony_ci the corrected equations for COLORDODGE_NV and COLORBURN_NV. Move 10535bd8deadSopenharmony_ci "NVIDIA Implementation Details" down a bit in the spec. 10545bd8deadSopenharmony_ci 10555bd8deadSopenharmony_ci Revision 6, October 16, 2013 10565bd8deadSopenharmony_ci 10575bd8deadSopenharmony_ci Add new special cases for COLORDODGE_KHR and COLORBURN_KHR, as described 10585bd8deadSopenharmony_ci in issue (7). Mark issue (7) as resolved. 10595bd8deadSopenharmony_ci 10605bd8deadSopenharmony_ci Revision 5, October 15, 2013 10615bd8deadSopenharmony_ci 10625bd8deadSopenharmony_ci Remove Porter-Duff blend equations from the specification (issue 4). 10635bd8deadSopenharmony_ci Add a Draw-time error if an advanced blending equation is used without 10645bd8deadSopenharmony_ci specifying a matching layout qualifier in the fragment shader (issue 5). 10655bd8deadSopenharmony_ci 10665bd8deadSopenharmony_ci Add issues for the spec issues discussed during standardization in 10675bd8deadSopenharmony_ci Khronos. Remove OpenGL ES 2.0 and 3.0 interactions dealing with 10685bd8deadSopenharmony_ci handling tokens present in OpenGL but not the core OpenGL ES 10695bd8deadSopenharmony_ci specification, since the relevant equations (ZERO and XOR) have been 10705bd8deadSopenharmony_ci removed. 10715bd8deadSopenharmony_ci 10725bd8deadSopenharmony_ci Revision 4, September 6, 2013 10735bd8deadSopenharmony_ci 10745bd8deadSopenharmony_ci Removed support for non-coherent-only implementations. Implementations 10755bd8deadSopenharmony_ci that could support NV_blend_equation_advanced (app-managed coherency 10765bd8deadSopenharmony_ci only) but not NV_blend_equation_advanced_coherent will be unable to 10775bd8deadSopenharmony_ci support this extension. 10785bd8deadSopenharmony_ci 10795bd8deadSopenharmony_ci Revision 3, August 19, 2013 10805bd8deadSopenharmony_ci 10815bd8deadSopenharmony_ci Fixed typos in the OpenGL ES 2.0 and 3.0 interactions section of 10825bd8deadSopenharmony_ci NV_blend_equation_advanced. 10835bd8deadSopenharmony_ci 10845bd8deadSopenharmony_ci Revision 2, August 13, 2013 10855bd8deadSopenharmony_ci 10865bd8deadSopenharmony_ci Removed issues from the original NV_blend_equation_advanced 10875bd8deadSopenharmony_ci specification. Rename "NV" prefixes and suffixes to "XXX" since the 10885bd8deadSopenharmony_ci future status of this extension is unknown. Remove the 10895bd8deadSopenharmony_ci BlendParameterivNV function and the BLEND_PREMULTIPLIED_SRC_NV and 10905bd8deadSopenharmony_ci BLEND_OVERLAP_NV parameters. Source colors are assumed to be 10915bd8deadSopenharmony_ci premultiplied. The source and destination pixel coverage, derived from 10925bd8deadSopenharmony_ci their respective alpha components, is assumed to be uncorrelated. 10935bd8deadSopenharmony_ci Removed the miscellaneous blend modes (PLUS_NV, PLUS_CLAMPED_NV, 10945bd8deadSopenharmony_ci PLUS_CLAMPED_ALPHA_NV, PLUS_DARKER_NV, MINUS_NV, MINUS_CLAMPED_NV, 10955bd8deadSopenharmony_ci CONTRAST_NV, INVERT_OVG_NV, RED, GREEN, BLUE) from Table X.4 of 10965bd8deadSopenharmony_ci NV_blend_equation_advanced. Removed some of the less common "X/Y/Z" 10975bd8deadSopenharmony_ci blend modes (INVERT, INVERT_RGB_NV, LINEARDODGE_NV, LINEARBURN_NV, 10985bd8deadSopenharmony_ci VIVIDLIGHT_NV, LINEARLIGHT_NV, PINLIGHT_NV, HARDMIX_NV). Add layout 10995bd8deadSopenharmony_ci qualifiers to the OpenGL Shading Language to indicate the set of 11005bd8deadSopenharmony_ci advanced blend equations are supported with a particular fragment 11015bd8deadSopenharmony_ci shader; using blend equations not identified in the current fragment 11025bd8deadSopenharmony_ci shader result in undefined blending results. 11035bd8deadSopenharmony_ci 11045bd8deadSopenharmony_ci Revision 1, August 13, 2013 11055bd8deadSopenharmony_ci 11065bd8deadSopenharmony_ci Forked the original NV_blend_equation_advanced specification. 1107