Project

General

Profile

Download (3.04 KB) Statistics
| Branch: | Revision:

library / src / main / res / raw / oit_clear_fragment_shader.glsl @ 3f12341d

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2018 Leszek Koltunski  leszek@koltunski.pl                                          //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// This library is free software; you can redistribute it and/or                                 //
7
// modify it under the terms of the GNU Lesser General Public                                    //
8
// License as published by the Free Software Foundation; either                                  //
9
// version 2.1 of the License, or (at your option) any later version.                            //
10
//                                                                                               //
11
// This library is distributed in the hope that it will be useful,                               //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                             //
14
// Lesser General Public License for more details.                                               //
15
//                                                                                               //
16
// You should have received a copy of the GNU Lesser General Public                              //
17
// License along with this library; if not, write to the Free Software                           //
18
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
19
///////////////////////////////////////////////////////////////////////////////////////////////////
20

    
21
precision highp float;
22
precision highp int;
23

    
24
in vec2 v_TexCoordinate;
25
in vec2 v_Pixel;              // location of the current fragment, in pixels
26

    
27
//////////////////////////////////////////////////////////////////////////////////////////////
28
// per-pixel linked list. Order Independent Transparency.
29

    
30
uniform uvec2 u_Size;
31

    
32
layout (std430,binding=1) buffer linkedlist  // first (u_Size.x*u_Size.y) uints - head pointers,
33
  {                                          // one for each pixel in the Output rectangle.
34
  uint u_Records[];                          //
35
  };                                         // Next 3*u_numRecords uints - actual linked list, i.e.
36
                                             // triplets of (pointer,depth,rgba).
37

    
38
//////////////////////////////////////////////////////////////////////////////////////////////
39
// Pass1 of the OIT algorithm - 'clear the head pointers' phase.
40
// No we cannot optimize this out by moving the 'u_Records[index]=0u' to the end of the Pass3,
41
// because between passes the size of the surface we render to might change.
42

    
43
void main()                    		
44
  {
45
  uint index= uint(v_Pixel.x) + uint(v_Pixel.y) * u_Size.x;
46
  u_Records[index] = 0u;
47
  discard;
48
  }
(10-10/14)