1 |
8777ce17
|
Leszek Koltunski
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2018 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
7602a827
|
Leszek Koltunski
|
// This file is part of DistortedLibrary. //
|
5 |
8777ce17
|
Leszek Koltunski
|
// //
|
6 |
7602a827
|
Leszek Koltunski
|
// DistortedLibrary is free software: you can redistribute it and/or modify //
|
7 |
8777ce17
|
Leszek Koltunski
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
7602a827
|
Leszek Koltunski
|
// DistortedLibrary is distributed in the hope that it will be useful, //
|
12 |
8777ce17
|
Leszek Koltunski
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
7602a827
|
Leszek Koltunski
|
// along with DistortedLibrary. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
8777ce17
|
Leszek Koltunski
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
f89a986e
|
Leszek Koltunski
|
precision highp float;
|
21 |
47511918
|
Leszek Koltunski
|
precision highp int;
|
22 |
8777ce17
|
Leszek Koltunski
|
|
23 |
56c6ca24
|
Leszek Koltunski
|
in vec2 v_TexCoordinate;
|
24 |
375b3950
|
Leszek Koltunski
|
in vec2 v_Pixel; // location of the current fragment, in pixels
|
25 |
|
|
|
26 |
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
27 |
|
|
// per-pixel linked list. Order Independent Transparency.
|
28 |
8777ce17
|
Leszek Koltunski
|
|
29 |
344ac0e4
|
Leszek Koltunski
|
uniform uvec2 u_Size;
|
30 |
8777ce17
|
Leszek Koltunski
|
|
31 |
375b3950
|
Leszek Koltunski
|
layout (std430,binding=1) buffer linkedlist // first (u_Size.x*u_Size.y) uints - head pointers,
|
32 |
|
|
{ // one for each pixel in the Output rectangle.
|
33 |
|
|
uint u_Records[]; //
|
34 |
|
|
}; // Next 3*u_numRecords uints - actual linked list, i.e.
|
35 |
|
|
// triplets of (pointer,depth,rgba).
|
36 |
|
|
|
37 |
|
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
38 |
56c6ca24
|
Leszek Koltunski
|
// Pass1 of the OIT algorithm - 'clear the head pointers' phase.
|
39 |
|
|
// No we cannot optimize this out by moving the 'u_Records[index]=0u' to the end of the Pass3,
|
40 |
|
|
// because between passes the size of the surface we render to might change.
|
41 |
8777ce17
|
Leszek Koltunski
|
|
42 |
|
|
void main()
|
43 |
|
|
{
|
44 |
344ac0e4
|
Leszek Koltunski
|
uint index= uint(v_Pixel.x) + uint(v_Pixel.y) * u_Size.x;
|
45 |
56c6ca24
|
Leszek Koltunski
|
u_Records[index] = 0u;
|
46 |
|
|
discard;
|
47 |
8777ce17
|
Leszek Koltunski
|
}
|