propane 3.9.0-java → 3.10.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +2 -2
  4. data/README.md +3 -3
  5. data/Rakefile +6 -6
  6. data/lib/java/japplemenubar/JAppleMenuBar.java +88 -0
  7. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  8. data/lib/java/monkstone/ColorUtil.java +127 -0
  9. data/lib/java/monkstone/MathToolModule.java +287 -0
  10. data/lib/java/monkstone/PropaneLibrary.java +46 -0
  11. data/lib/java/monkstone/core/LibraryProxy.java +136 -0
  12. data/lib/java/monkstone/fastmath/DegLutTables.java +111 -0
  13. data/lib/java/monkstone/fastmath/Deglut.java +71 -0
  14. data/lib/java/monkstone/fastmath/package-info.java +6 -0
  15. data/lib/java/monkstone/filechooser/Chooser.java +39 -0
  16. data/{src/main → lib}/java/monkstone/noise/FastTerrain.java +0 -0
  17. data/{src/main → lib}/java/monkstone/noise/Noise.java +0 -0
  18. data/{src/main → lib}/java/monkstone/noise/NoiseGenerator.java +0 -0
  19. data/{src/main → lib}/java/monkstone/noise/NoiseMode.java +0 -0
  20. data/lib/java/monkstone/noise/OpenSimplex2F.java +881 -0
  21. data/lib/java/monkstone/noise/OpenSimplex2S.java +1106 -0
  22. data/{src/main → lib}/java/monkstone/noise/SmoothTerrain.java +0 -0
  23. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +164 -0
  24. data/lib/java/monkstone/slider/CustomVerticalSlider.java +178 -0
  25. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +145 -0
  26. data/lib/java/monkstone/slider/SimpleSlider.java +166 -0
  27. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +157 -0
  28. data/lib/java/monkstone/slider/Slider.java +61 -0
  29. data/lib/java/monkstone/slider/SliderBar.java +245 -0
  30. data/lib/java/monkstone/slider/SliderGroup.java +56 -0
  31. data/lib/java/monkstone/slider/WheelHandler.java +35 -0
  32. data/lib/java/monkstone/vecmath/GfxRender.java +86 -0
  33. data/lib/java/monkstone/vecmath/JRender.java +56 -0
  34. data/lib/java/monkstone/vecmath/ShapeRender.java +87 -0
  35. data/lib/java/monkstone/vecmath/package-info.java +20 -0
  36. data/lib/java/monkstone/vecmath/vec2/Vec2.java +802 -0
  37. data/lib/java/monkstone/vecmath/vec2/package-info.java +6 -0
  38. data/lib/java/monkstone/vecmath/vec3/Vec3.java +727 -0
  39. data/lib/java/monkstone/vecmath/vec3/package-info.java +6 -0
  40. data/lib/java/monkstone/videoevent/CaptureEvent.java +27 -0
  41. data/lib/java/monkstone/videoevent/MovieEvent.java +32 -0
  42. data/lib/java/monkstone/videoevent/package-info.java +20 -0
  43. data/lib/java/processing/awt/PGraphicsJava2D.java +3040 -0
  44. data/lib/java/processing/awt/PImageAWT.java +377 -0
  45. data/lib/java/processing/awt/PShapeJava2D.java +387 -0
  46. data/lib/java/processing/awt/PSurfaceAWT.java +1581 -0
  47. data/lib/java/processing/awt/ShimAWT.java +581 -0
  48. data/lib/java/processing/core/PApplet.java +15156 -0
  49. data/lib/java/processing/core/PConstants.java +523 -0
  50. data/lib/java/processing/core/PFont.java +1126 -0
  51. data/lib/java/processing/core/PGraphics.java +8600 -0
  52. data/lib/java/processing/core/PImage.java +3377 -0
  53. data/lib/java/processing/core/PMatrix.java +208 -0
  54. data/lib/java/processing/core/PMatrix2D.java +562 -0
  55. data/lib/java/processing/core/PMatrix3D.java +890 -0
  56. data/lib/java/processing/core/PShape.java +3561 -0
  57. data/lib/java/processing/core/PShapeOBJ.java +483 -0
  58. data/lib/java/processing/core/PShapeSVG.java +2016 -0
  59. data/lib/java/processing/core/PStyle.java +63 -0
  60. data/lib/java/processing/core/PSurface.java +198 -0
  61. data/lib/java/processing/core/PSurfaceNone.java +431 -0
  62. data/lib/java/processing/core/PVector.java +1066 -0
  63. data/lib/java/processing/core/ThinkDifferent.java +115 -0
  64. data/lib/java/processing/data/DoubleDict.java +850 -0
  65. data/lib/java/processing/data/DoubleList.java +928 -0
  66. data/lib/java/processing/data/FloatDict.java +847 -0
  67. data/lib/java/processing/data/FloatList.java +936 -0
  68. data/lib/java/processing/data/IntDict.java +807 -0
  69. data/lib/java/processing/data/IntList.java +936 -0
  70. data/lib/java/processing/data/JSONArray.java +1260 -0
  71. data/lib/java/processing/data/JSONObject.java +2282 -0
  72. data/lib/java/processing/data/JSONTokener.java +435 -0
  73. data/lib/java/processing/data/LongDict.java +802 -0
  74. data/lib/java/processing/data/LongList.java +937 -0
  75. data/lib/java/processing/data/Sort.java +46 -0
  76. data/lib/java/processing/data/StringDict.java +613 -0
  77. data/lib/java/processing/data/StringList.java +800 -0
  78. data/lib/java/processing/data/Table.java +4936 -0
  79. data/lib/java/processing/data/TableRow.java +198 -0
  80. data/lib/java/processing/data/XML.java +1156 -0
  81. data/lib/java/processing/dxf/RawDXF.java +404 -0
  82. data/lib/java/processing/event/Event.java +125 -0
  83. data/lib/java/processing/event/KeyEvent.java +70 -0
  84. data/lib/java/processing/event/MouseEvent.java +114 -0
  85. data/lib/java/processing/event/TouchEvent.java +57 -0
  86. data/lib/java/processing/javafx/PGraphicsFX2D.java +32 -0
  87. data/lib/java/processing/javafx/PSurfaceFX.java +173 -0
  88. data/lib/java/processing/net/Client.java +744 -0
  89. data/lib/java/processing/net/Server.java +388 -0
  90. data/lib/java/processing/opengl/FontTexture.java +378 -0
  91. data/lib/java/processing/opengl/FrameBuffer.java +513 -0
  92. data/lib/java/processing/opengl/LinePath.java +627 -0
  93. data/lib/java/processing/opengl/LineStroker.java +681 -0
  94. data/lib/java/processing/opengl/PGL.java +3483 -0
  95. data/lib/java/processing/opengl/PGraphics2D.java +615 -0
  96. data/lib/java/processing/opengl/PGraphics3D.java +281 -0
  97. data/lib/java/processing/opengl/PGraphicsOpenGL.java +13753 -0
  98. data/lib/java/processing/opengl/PJOGL.java +2008 -0
  99. data/lib/java/processing/opengl/PShader.java +1484 -0
  100. data/lib/java/processing/opengl/PShapeOpenGL.java +5269 -0
  101. data/lib/java/processing/opengl/PSurfaceJOGL.java +1385 -0
  102. data/lib/java/processing/opengl/Texture.java +1696 -0
  103. data/lib/java/processing/opengl/VertexBuffer.java +88 -0
  104. data/lib/java/processing/opengl/cursors/arrow.png +0 -0
  105. data/lib/java/processing/opengl/cursors/cross.png +0 -0
  106. data/lib/java/processing/opengl/cursors/hand.png +0 -0
  107. data/lib/java/processing/opengl/cursors/license.txt +27 -0
  108. data/lib/java/processing/opengl/cursors/move.png +0 -0
  109. data/lib/java/processing/opengl/cursors/text.png +0 -0
  110. data/lib/java/processing/opengl/cursors/wait.png +0 -0
  111. data/lib/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  112. data/lib/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  113. data/lib/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  114. data/lib/java/processing/opengl/shaders/LightVert.glsl +151 -0
  115. data/lib/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  116. data/lib/java/processing/opengl/shaders/LineVert.glsl +100 -0
  117. data/lib/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  118. data/lib/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  119. data/lib/java/processing/opengl/shaders/PointVert.glsl +56 -0
  120. data/lib/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  121. data/lib/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  122. data/lib/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  123. data/lib/java/processing/opengl/shaders/TexVert.glsl +38 -0
  124. data/lib/java/processing/pdf/PGraphicsPDF.java +581 -0
  125. data/lib/java/processing/svg/PGraphicsSVG.java +378 -0
  126. data/lib/propane/app.rb +8 -13
  127. data/lib/propane/version.rb +1 -1
  128. data/mvnw +3 -3
  129. data/mvnw.cmd +2 -2
  130. data/pom.rb +7 -2
  131. data/pom.xml +14 -2
  132. data/propane.gemspec +2 -2
  133. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  134. data/src/main/java/monkstone/MathToolModule.java +30 -30
  135. data/src/main/java/monkstone/PropaneLibrary.java +2 -0
  136. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  137. data/src/main/java/monkstone/fastmath/DegLutTables.java +15 -15
  138. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  139. data/src/main/java/monkstone/noise/OpenSimplex2F.java +752 -820
  140. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -1106
  141. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  142. data/src/main/java/monkstone/vecmath/JRender.java +6 -6
  143. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +20 -19
  144. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +12 -12
  145. data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -3
  146. data/src/main/java/processing/core/PApplet.java +89 -89
  147. data/src/main/java/processing/core/PConstants.java +155 -163
  148. data/src/main/java/processing/opengl/PJOGL.java +6 -5
  149. data/vendors/Rakefile +1 -1
  150. metadata +136 -19
@@ -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 final void create() {
61
+ context = pgl.getCurrentContext();
62
+ glres = new GLResourceVertexBuffer(this);
63
+ }
64
+
65
+ protected final 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,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
+ }