blob: 8833490e8183a390a4cd523dcce3dff9b9633cd6 (
plain)
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
|
uniform float normalSize;
uniform sampler2D depthTex;
uniform float alpha = 1.0;
in vec3 pos;
in vec4 lnor;
in vec4 vnor;
in vec4 norAndFlag;
flat out vec4 finalColor;
bool test_occlusion()
{
vec3 ndc = (gl_Position.xyz / gl_Position.w) * 0.5 + 0.5;
return (ndc.z - 0.00035) > texture(depthTex, ndc.xy).r;
}
void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
vec3 nor;
/* Select the right normal by cheking if the generic attrib is used. */
if (!all(equal(lnor.xyz, vec3(0)))) {
if (lnor.w < 0.0) {
finalColor = vec4(0.0);
return;
}
nor = lnor.xyz;
finalColor = colorLNormal;
}
else if (!all(equal(vnor.xyz, vec3(0)))) {
if (vnor.w < 0.0) {
finalColor = vec4(0.0);
return;
}
nor = vnor.xyz;
finalColor = colorVNormal;
}
else {
nor = norAndFlag.xyz;
if (all(equal(nor, vec3(0.0)))) {
finalColor = vec4(0.0);
return;
}
finalColor = colorNormal;
}
vec3 n = normalize(normal_object_to_world(nor));
vec3 world_pos = point_object_to_world(pos);
if (gl_VertexID == 0) {
world_pos += n * normalSize;
}
gl_Position = point_world_to_ndc(world_pos);
finalColor.a *= (test_occlusion()) ? alpha : 1.0;
#ifdef USE_WORLD_CLIP_PLANES
world_clip_planes_calc_clip_distance(world_pos);
#endif
}
|