-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstandard.glsl
110 lines (95 loc) · 1.83 KB
/
standard.glsl
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#define INCLUDE_MERGESORT 0
void sortAndComposite(int fragIndex)
{
LFB_INIT(lfb, fragIndex);
int fragCount = 0;
LFB_FOREACH(lfb, frag)
if (fragCount < MAX_FRAGS)
{
FRAGS(fragCount) = frag;
++fragCount;
}
}
#if 1
#if INCLUDE_MERGESORT
#if MAX_FRAGS_OVERRIDE != 0
#if MAX_FRAGS >= 64
sort_merge(fragCount);
#else
sort_insert(fragCount);
#endif
#else
if (fragCount > 32)
sort_merge(fragCount);
else
sort_insert(fragCount);
#endif
#else
sort_insert(fragCount);
//sort_cbinsert(fragCount);
#endif
#endif
#if DEBUG
if (fragCount > MAX_FRAGS)
{
//warning: hit max frags!
fragColour = vec4(1,0,1,1);
return;
}
float lastDepth = 9999.0;
#endif
fragColour = vec4(1.0);
for (int i = fragCount-1; i >= 0; --i)
{
LFB_FRAG_TYPE f = FRAGS(i);
#if DEBUG
float thisDepth = LFB_FRAG_DEPTH(FRAGS(i));
if (thisDepth > lastDepth)
{
//error: out of order!
fragColour = vec4(1,0,0,1);
return;
}
lastDepth = thisDepth;
#endif
vec4 col = floatToRGBA8(f.x); //extract rgba from rg
//col.a = 0.1;
fragColour.rgb = mix(fragColour.rgb, col.rgb, col.a);
}
}
void compositeOnly(int fragIndex)
{
#if 0
fragColour = vec4(1.0);
int fragCount = 0;
LFB_INIT(lfb, fragIndex);
LFB_FOREACH(lfb, frag)
if (fragCount < MAX_FRAGS)
{
vec4 col = floatToRGBA8(frag.x);
fragColour.rgb = mix(fragColour.rgb, col.rgb, col.a);
++fragCount;
}
else
break;
}
#else
LFB_INIT(lfb, fragIndex);
int fragCount = 0;
LFB_FOREACH(lfb, frag)
if (fragCount < MAX_FRAGS)
{
FRAGS(fragCount) = frag;
++fragCount;
}
}
fragColour = vec4(1.0);
for (int i = fragCount-1; i >= 0; --i)
{
LFB_FRAG_TYPE f = FRAGS(i);
vec4 col = floatToRGBA8(f.x); //extract rgba from rg
//col.a = 0.1;
fragColour.rgb = mix(fragColour.rgb, col.rgb, col.a);
}
#endif
}