1
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2018 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// 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
|
// Distorted 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 //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
precision highp float;
|
21
|
precision highp int;
|
22
|
|
23
|
out vec4 fragColor;
|
24
|
in vec2 v_TexCoordinate;
|
25
|
|
26
|
uniform vec2 u_Size;
|
27
|
|
28
|
layout (binding=0, offset=0) uniform atomic_uint u_Counter;
|
29
|
|
30
|
layout (std430,binding=1) buffer linkedlist
|
31
|
{
|
32
|
uint u_Records[];
|
33
|
};
|
34
|
|
35
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
36
|
|
37
|
void main()
|
38
|
{
|
39
|
uint pixelX = uint(v_TexCoordinate.x * u_Size.x);
|
40
|
uint pixelY = uint(v_TexCoordinate.y * u_Size.y);
|
41
|
uint index = pixelX + pixelY * uint(u_Size.x);
|
42
|
|
43
|
uint ptr = atomicCounterIncrement(u_Counter) + uint(u_Size.x*u_Size.y);
|
44
|
u_Records[ptr ] = (v_TexCoordinate.x>0.5?2u:1u);
|
45
|
u_Records[index] = ptr;
|
46
|
discard;
|
47
|
}
|