propane 2.7.2-java → 2.8.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/CHANGELOG.md +1 -1
  4. data/README.md +10 -8
  5. data/Rakefile +1 -1
  6. data/lib/propane/app.rb +3 -3
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
  9. data/library/control_panel/control_panel.rb +3 -2
  10. data/pom.rb +89 -88
  11. data/pom.xml +75 -46
  12. data/propane.gemspec +1 -2
  13. data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
  14. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  15. data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
  16. data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
  17. data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
  18. data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
  19. data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
  20. data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
  21. data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
  22. data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
  23. data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
  24. data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
  25. data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
  26. data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
  27. data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
  28. data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
  29. data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
  30. data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
  31. data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
  32. data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
  33. data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
  34. data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
  35. data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
  36. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
  37. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
  38. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
  39. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
  40. data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
  41. data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
  42. data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
  43. data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
  44. data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
  45. data/src/main/java/processing/core/PApplet.java +15709 -0
  46. data/src/main/java/processing/core/PConstants.java +527 -0
  47. data/src/main/java/processing/core/PFont.java +1098 -0
  48. data/src/main/java/processing/core/PGraphics.java +8467 -0
  49. data/src/main/java/processing/core/PImage.java +3438 -0
  50. data/src/main/java/processing/core/PMatrix.java +208 -0
  51. data/src/main/java/processing/core/PMatrix2D.java +534 -0
  52. data/src/main/java/processing/core/PMatrix3D.java +877 -0
  53. data/src/main/java/processing/core/PShape.java +3445 -0
  54. data/src/main/java/processing/core/PShapeOBJ.java +469 -0
  55. data/src/main/java/processing/core/PShapeSVG.java +1787 -0
  56. data/src/main/java/processing/core/PStyle.java +63 -0
  57. data/src/main/java/processing/core/PSurface.java +161 -0
  58. data/src/main/java/processing/core/PSurfaceNone.java +374 -0
  59. data/src/main/java/processing/core/PVector.java +1063 -0
  60. data/src/main/java/processing/data/FloatDict.java +829 -0
  61. data/src/main/java/processing/data/FloatList.java +912 -0
  62. data/src/main/java/processing/data/IntDict.java +796 -0
  63. data/src/main/java/processing/data/IntList.java +913 -0
  64. data/src/main/java/processing/data/JSONArray.java +1260 -0
  65. data/src/main/java/processing/data/JSONObject.java +2282 -0
  66. data/src/main/java/processing/data/JSONTokener.java +435 -0
  67. data/src/main/java/processing/data/Sort.java +46 -0
  68. data/src/main/java/processing/data/StringDict.java +601 -0
  69. data/src/main/java/processing/data/StringList.java +775 -0
  70. data/src/main/java/processing/data/Table.java +4923 -0
  71. data/src/main/java/processing/data/TableRow.java +198 -0
  72. data/src/main/java/processing/data/XML.java +1149 -0
  73. data/src/main/java/processing/event/Event.java +125 -0
  74. data/src/main/java/processing/event/KeyEvent.java +70 -0
  75. data/src/main/java/processing/event/MouseEvent.java +149 -0
  76. data/src/main/java/processing/event/TouchEvent.java +57 -0
  77. data/src/main/java/processing/opengl/FontTexture.java +379 -0
  78. data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
  79. data/src/main/java/processing/opengl/LinePath.java +623 -0
  80. data/src/main/java/processing/opengl/LineStroker.java +685 -0
  81. data/src/main/java/processing/opengl/PGL.java +3366 -0
  82. data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
  83. data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
  84. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
  85. data/src/main/java/processing/opengl/PJOGL.java +1966 -0
  86. data/src/main/java/processing/opengl/PShader.java +1478 -0
  87. data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
  88. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
  89. data/src/main/java/processing/opengl/Texture.java +1670 -0
  90. data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
  91. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  92. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  93. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  94. data/src/main/java/processing/opengl/cursors/license.txt +27 -0
  95. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  96. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  97. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  98. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  99. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  100. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  101. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
  102. data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
  103. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  104. data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
  105. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  106. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  107. data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
  108. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  109. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  110. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
  111. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  112. data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
  113. data/src/main/resources/icon/icon-1024.png +0 -0
  114. data/src/main/resources/icon/icon-128.png +0 -0
  115. data/src/main/resources/icon/icon-16.png +0 -0
  116. data/src/main/resources/icon/icon-256.png +0 -0
  117. data/src/main/resources/icon/icon-32.png +0 -0
  118. data/src/main/resources/icon/icon-48.png +0 -0
  119. data/src/main/resources/icon/icon-512.png +0 -0
  120. data/src/main/resources/icon/icon-64.png +0 -0
  121. data/src/main/resources/license.txt +508 -0
  122. data/vendors/Rakefile +5 -20
  123. metadata +115 -33
  124. data/lib/propane.jar +0 -0
@@ -0,0 +1,88 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ Part of the Processing project - http://processing.org
5
+
6
+ Copyright (c) 2012-15 The Processing Foundation
7
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
8
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
9
+
10
+ This library is free software; you can redistribute it and/or
11
+ modify it under the terms of the GNU Lesser General Public
12
+ License as published by the Free Software Foundation, version 2.1.
13
+
14
+ This library is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General
20
+ Public License along with this library; if not, write to the
21
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
+ Boston, MA 02111-1307 USA
23
+ */
24
+
25
+ package processing.opengl;
26
+
27
+ import processing.opengl.PGraphicsOpenGL.GLResourceVertexBuffer;
28
+
29
+ // TODO: need to combine with PGraphicsOpenGL.VertexAttribute
30
+ public class VertexBuffer {
31
+ static protected final int INIT_VERTEX_BUFFER_SIZE = 256;
32
+ static protected final int INIT_INDEX_BUFFER_SIZE = 512;
33
+
34
+ public int glId;
35
+ int target;
36
+ int elementSize;
37
+ int ncoords;
38
+ boolean index;
39
+
40
+ protected PGL pgl; // The interface between Processing and OpenGL.
41
+ protected int context; // The context that created this texture.
42
+ private GLResourceVertexBuffer glres;
43
+
44
+ VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize) {
45
+ this(pg, target, ncoords, esize, false);
46
+ }
47
+
48
+ VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, boolean index) {
49
+ pgl = pg.pgl;
50
+ context = pgl.createEmptyContext();
51
+
52
+ this.target = target;
53
+ this.ncoords = ncoords;
54
+ this.elementSize = esize;
55
+ this.index = index;
56
+ create();
57
+ init();
58
+ }
59
+
60
+ protected void create() {
61
+ context = pgl.getCurrentContext();
62
+ glres = new GLResourceVertexBuffer(this);
63
+ }
64
+
65
+ protected void init() {
66
+ int size = index ? ncoords * INIT_INDEX_BUFFER_SIZE * elementSize :
67
+ ncoords * INIT_VERTEX_BUFFER_SIZE * elementSize;
68
+ pgl.bindBuffer(target, glId);
69
+ pgl.bufferData(target, size, null, PGL.STATIC_DRAW);
70
+ }
71
+
72
+ protected void dispose() {
73
+ if (glres != null) {
74
+ glres.dispose();
75
+ glId = 0;
76
+ glres = null;
77
+ }
78
+ }
79
+
80
+ protected boolean contextIsOutdated() {
81
+ boolean outdated = !pgl.contextIsCurrent(context);
82
+ if (outdated) {
83
+ dispose();
84
+ }
85
+ return outdated;
86
+ }
87
+
88
+ }
@@ -0,0 +1,27 @@
1
+ These files are based on the DMZ Cursors package,
2
+ used with permission from Jakub Steiner <jimmac@gmail.com>
3
+ 11 September 2015
4
+
5
+
6
+ The MIT License (MIT)
7
+
8
+ Copyright (c) 2006 Jakub Steiner <jimmac@novell.com>
9
+ Copyright (c) 2006 Novell, Inc.
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in
19
+ all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #ifdef GL_ES
24
+ precision mediump float;
25
+ precision mediump int;
26
+ #endif
27
+
28
+ varying vec4 vertColor;
29
+
30
+ void main() {
31
+ gl_FragColor = vertColor;
32
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ uniform mat4 transformMatrix;
24
+
25
+ attribute vec4 position;
26
+ attribute vec4 color;
27
+
28
+ varying vec4 vertColor;
29
+
30
+ void main() {
31
+ gl_Position = transformMatrix * position;
32
+
33
+ vertColor = color;
34
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #ifdef GL_ES
24
+ precision mediump float;
25
+ precision mediump int;
26
+ #endif
27
+
28
+ varying vec4 vertColor;
29
+ varying vec4 backVertColor;
30
+
31
+ void main() {
32
+ gl_FragColor = gl_FrontFacing ? vertColor : backVertColor;
33
+ }
@@ -0,0 +1,154 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ uniform mat4 modelviewMatrix;
24
+ uniform mat4 transformMatrix;
25
+ uniform mat3 normalMatrix;
26
+
27
+ uniform int lightCount;
28
+ uniform vec4 lightPosition[8];
29
+ uniform vec3 lightNormal[8];
30
+ uniform vec3 lightAmbient[8];
31
+ uniform vec3 lightDiffuse[8];
32
+ uniform vec3 lightSpecular[8];
33
+ uniform vec3 lightFalloff[8];
34
+ uniform vec2 lightSpot[8];
35
+
36
+ attribute vec4 position;
37
+ attribute vec4 color;
38
+ attribute vec3 normal;
39
+
40
+ attribute vec4 ambient;
41
+ attribute vec4 specular;
42
+ attribute vec4 emissive;
43
+ attribute float shininess;
44
+
45
+ varying vec4 vertColor;
46
+ varying vec4 backVertColor;
47
+
48
+ const float zero_float = 0.0;
49
+ const float one_float = 1.0;
50
+ const vec3 zero_vec3 = vec3(0.0);
51
+ const vec3 minus_one_vec3 = vec3(0.0-1.0);
52
+
53
+ float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
54
+ vec3 lpv = lightPos - vertPos;
55
+ vec3 dist = vec3(one_float);
56
+ dist.z = dot(lpv, lpv);
57
+ dist.y = sqrt(dist.z);
58
+ return one_float / dot(dist, coeff);
59
+ }
60
+
61
+ float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
62
+ vec3 lpv = normalize(lightPos - vertPos);
63
+ vec3 nln = minus_one_vec3 * lightNorm;
64
+ float spotCos = dot(nln, lpv);
65
+ return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
66
+ }
67
+
68
+ float lambertFactor(vec3 lightDir, vec3 vecNormal) {
69
+ return max(zero_float, dot(lightDir, vecNormal));
70
+ }
71
+
72
+ float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine) {
73
+ vec3 np = normalize(vertPos);
74
+ vec3 ldp = normalize(lightDir - np);
75
+ return pow(max(zero_float, dot(ldp, vecNormal)), shine);
76
+ }
77
+
78
+ void main() {
79
+ // Vertex in clip coordinates
80
+ gl_Position = transformMatrix * position;
81
+
82
+ // Vertex in eye coordinates
83
+ vec3 ecVertex = vec3(modelviewMatrix * position);
84
+
85
+ // Normal vector in eye coordinates
86
+ vec3 ecNormal = normalize(normalMatrix * normal);
87
+ vec3 ecNormalInv = ecNormal * minus_one_vec3;
88
+
89
+ // Light calculations
90
+ vec3 totalAmbient = vec3(0, 0, 0);
91
+
92
+ vec3 totalFrontDiffuse = vec3(0, 0, 0);
93
+ vec3 totalFrontSpecular = vec3(0, 0, 0);
94
+
95
+ vec3 totalBackDiffuse = vec3(0, 0, 0);
96
+ vec3 totalBackSpecular = vec3(0, 0, 0);
97
+
98
+ // prevent register allocation failure by limiting ourselves to
99
+ // two lights for now
100
+ for (int i = 0; i < 2; i++) {
101
+ if (lightCount == i) break;
102
+
103
+ vec3 lightPos = lightPosition[i].xyz;
104
+ bool isDir = lightPosition[i].w < one_float;
105
+ float spotCos = lightSpot[i].x;
106
+ float spotExp = lightSpot[i].y;
107
+
108
+ vec3 lightDir;
109
+ float falloff;
110
+ float spotf;
111
+
112
+ if (isDir) {
113
+ falloff = one_float;
114
+ lightDir = minus_one_vec3 * lightNormal[i];
115
+ } else {
116
+ falloff = falloffFactor(lightPos, ecVertex, lightFalloff[i]);
117
+ lightDir = normalize(lightPos - ecVertex);
118
+ }
119
+
120
+ spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i],
121
+ spotCos, spotExp)
122
+ : one_float;
123
+
124
+ if (any(greaterThan(lightAmbient[i], zero_vec3))) {
125
+ totalAmbient += lightAmbient[i] * falloff;
126
+ }
127
+
128
+ if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
129
+ totalFrontDiffuse += lightDiffuse[i] * falloff * spotf *
130
+ lambertFactor(lightDir, ecNormal);
131
+ totalBackDiffuse += lightDiffuse[i] * falloff * spotf *
132
+ lambertFactor(lightDir, ecNormalInv);
133
+ }
134
+
135
+ if (any(greaterThan(lightSpecular[i], zero_vec3))) {
136
+ totalFrontSpecular += lightSpecular[i] * falloff * spotf *
137
+ blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);
138
+ totalBackSpecular += lightSpecular[i] * falloff * spotf *
139
+ blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess);
140
+ }
141
+ }
142
+
143
+ // Calculating final color as result of all lights (plus emissive term).
144
+ // Transparency is determined exclusively by the diffuse component.
145
+ vertColor = vec4(totalAmbient, 0) * ambient +
146
+ vec4(totalFrontDiffuse, 1) * color +
147
+ vec4(totalFrontSpecular, 0) * specular +
148
+ vec4(emissive.rgb, 0);
149
+
150
+ backVertColor = vec4(totalAmbient, 0) * ambient +
151
+ vec4(totalBackDiffuse, 1) * color +
152
+ vec4(totalBackSpecular, 0) * specular +
153
+ vec4(emissive.rgb, 0);
154
+ }
@@ -0,0 +1,151 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ uniform mat4 modelviewMatrix;
24
+ uniform mat4 transformMatrix;
25
+ uniform mat3 normalMatrix;
26
+
27
+ uniform int lightCount;
28
+ uniform vec4 lightPosition[8];
29
+ uniform vec3 lightNormal[8];
30
+ uniform vec3 lightAmbient[8];
31
+ uniform vec3 lightDiffuse[8];
32
+ uniform vec3 lightSpecular[8];
33
+ uniform vec3 lightFalloff[8];
34
+ uniform vec2 lightSpot[8];
35
+
36
+ attribute vec4 position;
37
+ attribute vec4 color;
38
+ attribute vec3 normal;
39
+
40
+ attribute vec4 ambient;
41
+ attribute vec4 specular;
42
+ attribute vec4 emissive;
43
+ attribute float shininess;
44
+
45
+ varying vec4 vertColor;
46
+ varying vec4 backVertColor;
47
+
48
+ const float zero_float = 0.0;
49
+ const float one_float = 1.0;
50
+ const vec3 zero_vec3 = vec3(0);
51
+
52
+ float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
53
+ vec3 lpv = lightPos - vertPos;
54
+ vec3 dist = vec3(one_float);
55
+ dist.z = dot(lpv, lpv);
56
+ dist.y = sqrt(dist.z);
57
+ return one_float / dot(dist, coeff);
58
+ }
59
+
60
+ float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
61
+ vec3 lpv = normalize(lightPos - vertPos);
62
+ vec3 nln = -one_float * lightNorm;
63
+ float spotCos = dot(nln, lpv);
64
+ return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
65
+ }
66
+
67
+ float lambertFactor(vec3 lightDir, vec3 vecNormal) {
68
+ return max(zero_float, dot(lightDir, vecNormal));
69
+ }
70
+
71
+ float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine) {
72
+ vec3 np = normalize(vertPos);
73
+ vec3 ldp = normalize(lightDir - np);
74
+ return pow(max(zero_float, dot(ldp, vecNormal)), shine);
75
+ }
76
+
77
+ void main() {
78
+ // Vertex in clip coordinates
79
+ gl_Position = transformMatrix * position;
80
+
81
+ // Vertex in eye coordinates
82
+ vec3 ecVertex = vec3(modelviewMatrix * position);
83
+
84
+ // Normal vector in eye coordinates
85
+ vec3 ecNormal = normalize(normalMatrix * normal);
86
+ vec3 ecNormalInv = ecNormal * -one_float;
87
+
88
+ // Light calculations
89
+ vec3 totalAmbient = vec3(0, 0, 0);
90
+
91
+ vec3 totalFrontDiffuse = vec3(0, 0, 0);
92
+ vec3 totalFrontSpecular = vec3(0, 0, 0);
93
+
94
+ vec3 totalBackDiffuse = vec3(0, 0, 0);
95
+ vec3 totalBackSpecular = vec3(0, 0, 0);
96
+
97
+ for (int i = 0; i < 8; i++) {
98
+ if (lightCount == i) break;
99
+
100
+ vec3 lightPos = lightPosition[i].xyz;
101
+ bool isDir = lightPosition[i].w < one_float;
102
+ float spotCos = lightSpot[i].x;
103
+ float spotExp = lightSpot[i].y;
104
+
105
+ vec3 lightDir;
106
+ float falloff;
107
+ float spotf;
108
+
109
+ if (isDir) {
110
+ falloff = one_float;
111
+ lightDir = -one_float * lightNormal[i];
112
+ } else {
113
+ falloff = falloffFactor(lightPos, ecVertex, lightFalloff[i]);
114
+ lightDir = normalize(lightPos - ecVertex);
115
+ }
116
+
117
+ spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i],
118
+ spotCos, spotExp)
119
+ : one_float;
120
+
121
+ if (any(greaterThan(lightAmbient[i], zero_vec3))) {
122
+ totalAmbient += lightAmbient[i] * falloff;
123
+ }
124
+
125
+ if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
126
+ totalFrontDiffuse += lightDiffuse[i] * falloff * spotf *
127
+ lambertFactor(lightDir, ecNormal);
128
+ totalBackDiffuse += lightDiffuse[i] * falloff * spotf *
129
+ lambertFactor(lightDir, ecNormalInv);
130
+ }
131
+
132
+ if (any(greaterThan(lightSpecular[i], zero_vec3))) {
133
+ totalFrontSpecular += lightSpecular[i] * falloff * spotf *
134
+ blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);
135
+ totalBackSpecular += lightSpecular[i] * falloff * spotf *
136
+ blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess);
137
+ }
138
+ }
139
+
140
+ // Calculating final color as result of all lights (plus emissive term).
141
+ // Transparency is determined exclusively by the diffuse component.
142
+ vertColor = vec4(totalAmbient, 0) * ambient +
143
+ vec4(totalFrontDiffuse, 1) * color +
144
+ vec4(totalFrontSpecular, 0) * specular +
145
+ vec4(emissive.rgb, 0);
146
+
147
+ backVertColor = vec4(totalAmbient, 0) * ambient +
148
+ vec4(totalBackDiffuse, 1) * color +
149
+ vec4(totalBackSpecular, 0) * specular +
150
+ vec4(emissive.rgb, 0);
151
+ }
@@ -0,0 +1,32 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #ifdef GL_ES
24
+ precision mediump float;
25
+ precision mediump int;
26
+ #endif
27
+
28
+ varying vec4 vertColor;
29
+
30
+ void main() {
31
+ gl_FragColor = vertColor;
32
+ }
@@ -0,0 +1,100 @@
1
+ /*
2
+ Part of the Processing project - http://processing.org
3
+
4
+ Copyright (c) 2012-15 The Processing Foundation
5
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
6
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
7
+
8
+ This library is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU Lesser General Public
10
+ License as published by the Free Software Foundation, version 2.1.
11
+
12
+ This library is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ Lesser General Public License for more details.
16
+
17
+ You should have received a copy of the GNU Lesser General
18
+ Public License along with this library; if not, write to the
19
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
+ Boston, MA 02111-1307 USA
21
+ */
22
+
23
+ #define PROCESSING_LINE_SHADER
24
+
25
+ uniform mat4 modelviewMatrix;
26
+ uniform mat4 projectionMatrix;
27
+
28
+ uniform vec4 viewport;
29
+ uniform int perspective;
30
+ uniform vec3 scale;
31
+
32
+ attribute vec4 position;
33
+ attribute vec4 color;
34
+ attribute vec4 direction;
35
+
36
+ varying vec4 vertColor;
37
+
38
+ void main() {
39
+ vec4 posp = modelviewMatrix * position;
40
+ vec4 posq = modelviewMatrix * (position + vec4(direction.xyz, 0));
41
+
42
+ // Moving vertices slightly toward the camera
43
+ // to avoid depth-fighting with the fill triangles.
44
+ // Discussed here:
45
+ // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848
46
+ posp.xyz = posp.xyz * scale;
47
+ posq.xyz = posq.xyz * scale;
48
+
49
+ vec4 p = projectionMatrix * posp;
50
+ vec4 q = projectionMatrix * posq;
51
+
52
+ // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
53
+ // screen_p = (p.xy/p.w + <1,1>) * 0.5 * viewport.zw
54
+
55
+ // prevent division by W by transforming the tangent formula (div by 0 causes
56
+ // the line to disappear, see https://github.com/processing/processing/issues/5183)
57
+ // t = screen_q - screen_p
58
+ //
59
+ // tangent is normalized and we don't care which direction it points to (+-)
60
+ // t = +- normalize( screen_q - screen_p )
61
+ // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*viewport.zw - (p.xy/p.w+<1,1>)*0.5*viewport.zw )
62
+ //
63
+ // extract common factor, <1,1> - <1,1> cancels out
64
+ // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * viewport.zw )
65
+ //
66
+ // convert to common divisor
67
+ // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * viewport.zw )
68
+ //
69
+ // remove the common scalar divisor/factor, not needed due to normalize and +-
70
+ // (keep viewport - can't remove because it has different components for x and y
71
+ // and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)
72
+ // t = +- normalize( (q.xy*p.w - p.xy*q.w) * viewport.zw )
73
+
74
+ vec2 tangent = (q.xy*p.w - p.xy*q.w) * viewport.zw;
75
+
76
+ // don't normalize zero vector (line join triangles and lines perpendicular to the eye plane)
77
+ tangent = length(tangent) == 0.0 ? vec2(0.0, 0.0) : normalize(tangent);
78
+
79
+ // flip tangent to normal (it's already normalized)
80
+ vec2 normal = vec2(-tangent.y, tangent.x);
81
+
82
+ float thickness = direction.w;
83
+ vec2 offset = normal * thickness;
84
+
85
+ // Perspective ---
86
+ // convert from world to clip by multiplying with projection scaling factor
87
+ // to get the right thickness (see https://github.com/processing/processing/issues/5182)
88
+ // invert Y, projections in Processing invert Y
89
+ vec2 perspScale = (projectionMatrix * vec4(1, -1, 0, 0)).xy;
90
+
91
+ // No Perspective ---
92
+ // multiply by W (to cancel out division by W later in the pipeline) and
93
+ // convert from screen to clip (derived from clip to screen above)
94
+ vec2 noPerspScale = p.w / (0.5 * viewport.zw);
95
+
96
+ gl_Position.xy = p.xy + offset.xy * mix(noPerspScale, perspScale, float(perspective > 0));
97
+ gl_Position.zw = p.zw;
98
+
99
+ vertColor = color;
100
+ }