Porter duff "conjoint" and "disjoint" use cases in vulkan

26 views Asked by At

I'm trying to implement manual porter-duff composite blending, partially based off the Vulkan spec. however I'm very confused by a few parts in Vulkan's advanced blending extension. Mainly, beyond where the equation comes from the first place (not in the actual porter duff paper afaict, but I see referenced with out a source in various forms in other locations), the VK_BLEND_OVERLAP_UNCORRELATED_EXT, VK_BLEND_OVERLAP_CONJOINT_EXT, and VK_BLEND_OVERLAP_DISJOINT_EXT enums.

As I understand, VK_BLEND_OVERLAP_UNCORRELATED_EXT is the "default", the version I see implicitly in other sources, for example in the SVG compositing spec

Dca' = f(Sc, Dc) × Sa × Da  + Y × Sca × (1-Da)  + Z × Dca × (1-Sa)
Da'  =         X × Sa × Da  + Y × Sa × (1-Da)   + Z × Da × (1-Sa)

which is basically equivalent to

Dca' = f(Sc, Dc) × p0  + Y × Sc x p1  + Z × Dc x p2
Da'  =         X × p0  + Y × p1       + Z × p2

where

  • p0 = source alpha * destination alpha
  • p1 = source alpha * (1.0 - destination alpha)
  • p2 = destination alpha * (1.0 - source alpha)

matching VK_BLEND_OVERLAP_UNCORRELATED_EXT coefficients.

Equations for the others are

VK_BLEND_OVERLAP_CONJOINT_EXT

  • p0 = min(source alpha, destination alpha)
  • p1 = max(source alpha - destination alpha, 0.0)
  • p2 = max(destination alpha - source alpha, 0.0)

VK_BLEND_OVERLAP_DISJOINT_EXT

  • p0 = max(source alpha + destination alpha - 1.0, 0.0)
  • p1 = min(source alpha, (1.0 - destination alpha))
  • p2 = min(destination alpha, (1.0 - source alpha))

While I physically see the equations for the other enums, I don't understand where they come from or what their purpose is.

Vulkan spec states:

* VK_BLEND_OVERLAP_UNCORRELATED_EXT specifies that there is no correlation between the source and destination coverage.

* VK_BLEND_OVERLAP_CONJOINT_EXT specifies that the source and destination coverage are considered to have maximal overlap.

* VK_BLEND_OVERLAP_DISJOINT_EXT specifies that the source and destination coverage are considered to have minimal overlap.

but I don't know what the importance of that is.

I'm ultimately trying to figure out how to add a seperate alpha blending operation in addition to color blending (f(Sc,Dc)), with out a special enum to handle blend overlap. But with these extra modes, I don't know how to properly account for arbitrary functions for alpha blending.

0

There are 0 answers