Welcome to mirror list, hosted at ThFree Co, Russian Federation.

workbench_transparent_resolve_frag.glsl « shaders « workbench « engines « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2c45d2f8e388cc0c98919f85a30cee427db8ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

/* Based on :
 * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of
 * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013
 */

void main()
{
  /* Revealage is actually stored in transparentAccum alpha channel.
   * This is a workaround to older hardware not having separate blend equation per render target.
   */
  vec4 trans_accum = texture(transparentAccum, uvcoordsvar.st);
  float trans_weight = texture(transparentRevealage, uvcoordsvar.st).r;
  float trans_reveal = trans_accum.a;

  /* Listing 4 */
  fragColor.rgb = trans_accum.rgb / clamp(trans_weight, 1e-4, 5e4);
  fragColor.a = 1.0 - trans_reveal;
}