Project

General

Profile

« Previous | Next » 

Revision 90eb5f53

Added by Leszek Koltunski over 6 years ago

OIT: correction for blending in Pass4

View differences:

src/main/res/raw/oit_render_fragment_shader.glsl
43 43
  }
44 44

  
45 45
//////////////////////////////////////////////////////////////////////////////////////////////
46
// https://en.wikipedia.org/wiki/Alpha_compositing (premultiplied)
46
// A over B (https://en.wikipedia.org/wiki/Alpha_compositing)
47 47

  
48
vec4 blend(vec4 clr,vec4 srf)
48

  
49
vec4 blend(vec4 A,vec4 B)
49 50
  {
50
  return clr + (1.0 - clr.a) * vec4(srf.rgb * srf.a , srf.a);
51
  float b = B.a * (1.0-A.a);
52
  float a = A.a + b;
53

  
54
  return vec4( (A.rgb*A.a + B.rgb*b)/a , a );
51 55
  }
52 56

  
53 57
//////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff