-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshaders.py
More file actions
42 lines (36 loc) · 891 Bytes
/
shaders.py
File metadata and controls
42 lines (36 loc) · 891 Bytes
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
circlesVertex = """
#version 330
attribute vec2 position;
attribute float color;
uniform float radius;
uniform vec2 resolution;
uniform vec2 spaceLength;
varying vec2 v_center;
varying float v_radius;
varying vec3 v_color;
void main () {
v_center = position / spaceLength * resolution;
v_radius = radius;
v_color = vec3(0.,0.,0.);
if (color <0.0){
v_color = vec3(0.,0.,sqrt(-color));
}else{
v_color = vec3(sqrt(color),0.,0.);
}
gl_Position = vec4(2*position/spaceLength-1.0, 0.0, 1.0);
gl_PointSize = 3.0 + ceil(2.0*radius);
}
"""
circlesFragment = """
#version 330
varying vec2 v_center;
varying float v_radius;
varying vec3 v_color;
void main() {
vec2 p = gl_FragCoord.xy - v_center;
float a = 1.0;
float d = length(p)-v_radius*0.99;
if(d > 0.0) a = exp(-4*d*d);
gl_FragColor = vec4(v_color, a);
}
"""