Implement particle velocity and acceleration visualization
[blender.git] / source / blender / draw / modes / shaders / object_particle_dot_frag.glsl
1
2 uniform vec3 color;
3 uniform vec3 outlineColor;
4 uniform sampler1D ramp;
5
6 in vec4 radii;
7 flat in float finalVal;
8
9 out vec4 fragColor;
10
11 void main() {
12         float dist = length(gl_PointCoord - vec2(0.5));
13
14 // transparent outside of point
15 // --- 0 ---
16 // smooth transition
17 // --- 1 ---
18 // pure outline color
19 // --- 2 ---
20 // smooth transition
21 // --- 3 ---
22 // pure point color
23 // ...
24 // dist = 0 at center of point
25
26         float midStroke = 0.5 * (radii[1] + radii[2]);
27
28         if (dist > midStroke) {
29                 if (finalVal < 0.0) {
30                         fragColor.rgb = outlineColor;
31                 }
32                 else {
33                         fragColor.rgb = texture(ramp, finalVal).rgb;
34                 }
35
36                 fragColor.a = mix(1.0, 0.0, smoothstep(radii[1], radii[0], dist));
37         }
38         else {
39                 if (finalVal < 0.0) {
40                         fragColor.rgb = mix(color, outlineColor, smoothstep(radii[3], radii[2], dist));
41                 }
42                 else {
43                         fragColor.rgb = texture(ramp, finalVal).rgb;
44                 }
45
46                 fragColor.a = 1.0;
47         }
48
49         if (fragColor.a == 0.0) {
50                 discard;
51         }
52 }