-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffect_outline.vert
72 lines (53 loc) · 1.84 KB
/
effect_outline.vert
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
///////////////////////////////////////////////////////
//*-------------------------------------------------*//
//| Part of Project One (https://www.maus-games.at) |//
//*-------------------------------------------------*//
//| Copyright (c) 2010 Martin Mauersics |//
//| Released under the zlib License |//
//*-------------------------------------------------*//
///////////////////////////////////////////////////////
#include "engine/data_transform_3d.glsl"
// shader uniforms
uniform float u_v1Depth; //
// vertex attributes
attribute float a_v1Depth; //
// shader output
varying float v_v1Strength; // outline intensity
void VertexMain()
{
//
#if defined(_P1_THICK_)
const float v1Thickness = 0.8;
#else
const float v1Thickness = 0.35;
#endif
// transform position normal-resized
vec3 v3BasePosition = coreQuatApply(u_v4Rotation, (a_v3RawPosition * u_v3Size) + (a_v3RawNormal * v1Thickness));
#if defined(_P1_FLAT_)
//
#if defined(_P1_BULLET_)
#if defined(_CORE_OPTION_INSTANCING_)
float v1Depth = a_v1Depth;
#else
float v1Depth = u_v1Depth;
#endif
#else
const float v1Depth = -1.0;
#endif
// (and make flat)
gl_Position = u_m4ViewProj * vec4(v3BasePosition * vec3(1.0, 1.0, 0.0) + u_v3Position, 1.0);
//
gl_Position.z -= (v1Depth * 0.0012 - 0.0006) * gl_Position.w;
#else
//
gl_Position = u_m4ViewProj * vec4(v3BasePosition + u_v3Position, 1.0);
// increase depth to draw behind base object
gl_Position.z += 0.4 * gl_Position.w;
#endif
#if defined(_P1_DIRECT_)
// calculate interpolated outline intensity
v_v1Strength = (a_v2RawTexCoord.y * 2.0 - 1.0) * (0.8/0.7);
#endif
// make sure outlines can be rendered for close objects in Eigengrau
gl_Position.z = clamp(gl_Position.z, -gl_Position.w, gl_Position.w);
}