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
|
void node_attribute_color(vec4 attr, out vec4 out_attr)
{
out_attr = attr_load_color_post(attr);
}
void node_attribute_temperature(vec4 attr, out vec4 out_attr)
{
out_attr.x = attr_load_temperature_post(attr.x);
out_attr.y = 0.0;
out_attr.z = 0.0;
out_attr.w = 1.0;
}
void node_attribute_density(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute_flame(vec4 attr, out float out_attr)
{
out_attr = attr.x;
}
void node_attribute_uniform(vec4 attr, const float attr_hash, out vec4 out_attr)
{
/* Temporary solution to support both old UBO attribs and new SSBO loading.
* Old UBO load is already done through `attr` and will just be passed through. */
out_attr = attr_load_uniform(attr, floatBitsToUint(attr_hash));
}
vec4 attr_load_layer(const uint attr_hash)
{
#ifdef VLATTR_LIB
/* The first record of the buffer stores the length. */
uint left = 0, right = drw_layer_attrs[0].buffer_length;
while (left < right) {
uint mid = (left + right) / 2;
uint hash = drw_layer_attrs[mid].hash_code;
if (hash < attr_hash) {
left = mid + 1;
}
else if (hash > attr_hash) {
right = mid;
}
else {
return drw_layer_attrs[mid].data;
}
}
#endif
return vec4(0.0);
}
void node_attribute(
vec4 attr, out vec4 outcol, out vec3 outvec, out float outf, out float outalpha)
{
outcol = vec4(attr.xyz, 1.0);
outvec = attr.xyz;
outf = avg(attr.xyz);
outalpha = attr.w;
}
|