-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frag_m2.txt
71 lines (45 loc) · 1.04 KB
/
Frag_m2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//for using /parsing linked list
#version 430 core
layout(binding=0, r32ui) coherent uniform uimage2D head_ptr;
struct node
{
vec4 color;
float depth;
int facing;
uint next;
};
layout(binding=0 , std430) buffer storage
{
node storage_arr[];
};
out vec4 color;
uint max_frag=25;
void main()
{
uint frag_count=0;
float net_depth=0;
ivec2 loc = ivec2(gl_FragCoord.xy);//getting location in image
uint i = imageLoad (head_ptr, loc ).x ; //head pointer value corrosponding to obtained location is loaded and put in i
while( i != 0xFFFFFFFF && frag_count < max_frag )//traverse list starting from index i
{
if(storage_arr[i].facing != 0)
{
net_depth-=storage_arr[i].depth;//if front facing
}
else
{
net_depth+=storage_arr[i].depth;//if backfacing
}
i = storage_arr[i].next;
++frag_count;
}
net_depth*=300;
if(net_depth>0.005)
{
color= vec4(0,net_depth,0,1);
}
else//for background color
{
color= vec4(0.3,0,0.2,1);
}
}