forked from Librelancer/Librelancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NebulaExtPuff.glsl
60 lines (51 loc) · 1.24 KB
/
NebulaExtPuff.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
@vertex
@include (includes/camera.inc)
in vec3 vertex_position;
in vec3 vertex_dimensions;
in vec4 vertex_color;
in vec4 vertex_color2;
in vec2 vertex_texture1;
out vec2 uv;
out vec4 innercolor;
out vec4 outercolor;
uniform mat4 World;
void main()
{
//Up/right
vec3 srcRight = vec3(
View[0][0],
View[1][0],
View[2][0]
);
vec3 srcUp = vec3(
View[0][1],
View[1][1],
View[2][1]
);
vec3 worldpos = (World * vec4(vertex_position, 1)).xyz;
//Billboard calculation
float s = sin(vertex_dimensions.z);
float c = cos(vertex_dimensions.z);
vec3 up = c * srcRight - s * srcUp;
vec3 right = s * srcRight + c * srcUp;
vec3 pos = worldpos + (right * vertex_dimensions.x) + (up * vertex_dimensions.y);
gl_Position = ViewProjection * vec4(pos, 1);
//pass-through to fragment
uv = vertex_texture1;
innercolor = vertex_color;
outercolor = vertex_color2;
}
@fragment
uniform sampler2D DtSampler;
uniform vec4 FogColor;
uniform float FogFactor;
in vec2 uv;
in vec4 innercolor;
in vec4 outercolor;
out vec4 FragColor;
void main(void)
{
vec4 result = texture(DtSampler, uv) * innercolor;
result.rgb = mix(result.rgb, outercolor.rgb, FogFactor);
FragColor = result;
}