propane 2.7.2-java → 2.8.0.pre-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,40 @@
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
+ #define PROCESSING_TEXTURE_SHADER
29
+
30
+ uniform sampler2D texture;
31
+ uniform sampler2D mask;
32
+
33
+ varying vec4 vertTexCoord;
34
+
35
+ void main() {
36
+ vec3 texColor = texture2D(texture, vertTexCoord.st).rgb;
37
+ vec3 maskColor = texture2D(mask, vertTexCoord.st).rgb;
38
+ float luminance = dot(maskColor, vec3(0.2126, 0.7152, 0.0722));
39
+ gl_FragColor = vec4(texColor, luminance);
40
+ }
@@ -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,56 @@
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 projectionMatrix;
24
+ uniform mat4 modelviewMatrix;
25
+
26
+ uniform vec4 viewport;
27
+ uniform int perspective;
28
+
29
+ attribute vec4 position;
30
+ attribute vec4 color;
31
+ attribute vec2 offset;
32
+
33
+ varying vec4 vertColor;
34
+
35
+ void main() {
36
+ vec4 pos = modelviewMatrix * position;
37
+ vec4 clip = projectionMatrix * pos;
38
+
39
+ // Perspective ---
40
+ // convert from world to clip by multiplying with projection scaling factor
41
+ // invert Y, projections in Processing invert Y
42
+ vec2 perspScale = (projectionMatrix * vec4(1, -1, 0, 0)).xy;
43
+
44
+ // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
45
+ // screen_p = (p.xy/p.w + <1,1>) * 0.5 * viewport.zw
46
+
47
+ // No Perspective ---
48
+ // multiply by W (to cancel out division by W later in the pipeline) and
49
+ // convert from screen to clip (derived from clip to screen above)
50
+ vec2 noPerspScale = clip.w / (0.5 * viewport.zw);
51
+
52
+ gl_Position.xy = clip.xy + offset.xy * mix(noPerspScale, perspScale, float(perspective > 0));
53
+ gl_Position.zw = clip.zw;
54
+
55
+ vertColor = color;
56
+ }
@@ -0,0 +1,37 @@
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
+ uniform sampler2D texture;
29
+
30
+ uniform vec2 texOffset;
31
+
32
+ varying vec4 vertColor;
33
+ varying vec4 vertTexCoord;
34
+
35
+ void main() {
36
+ gl_FragColor = texture2D(texture, vertTexCoord.st) * vertColor;
37
+ }
@@ -0,0 +1,37 @@
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
+ #ifdef GL_ES
23
+ precision mediump float;
24
+ precision mediump int;
25
+ #endif
26
+
27
+ uniform sampler2D texture;
28
+
29
+ uniform vec2 texOffset;
30
+
31
+ varying vec4 vertColor;
32
+ varying vec4 backVertColor;
33
+ varying vec4 vertTexCoord;
34
+
35
+ void main() {
36
+ gl_FragColor = texture2D(texture, vertTexCoord.st) * (gl_FrontFacing ? vertColor : backVertColor);
37
+ }
@@ -0,0 +1,160 @@
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
+ uniform mat4 texMatrix;
27
+
28
+ uniform int lightCount;
29
+ uniform vec4 lightPosition[8];
30
+ uniform vec3 lightNormal[8];
31
+ uniform vec3 lightAmbient[8];
32
+ uniform vec3 lightDiffuse[8];
33
+ uniform vec3 lightSpecular[8];
34
+ uniform vec3 lightFalloff[8];
35
+ uniform vec2 lightSpot[8];
36
+
37
+ attribute vec4 position;
38
+ attribute vec4 color;
39
+ attribute vec3 normal;
40
+ attribute vec2 texCoord;
41
+
42
+ attribute vec4 ambient;
43
+ attribute vec4 specular;
44
+ attribute vec4 emissive;
45
+ attribute float shininess;
46
+
47
+ varying vec4 vertColor;
48
+ varying vec4 backVertColor;
49
+ varying vec4 vertTexCoord;
50
+
51
+ const float zero_float = 0.0;
52
+ const float one_float = 1.0;
53
+ const vec3 zero_vec3 = vec3(0.0);
54
+ const vec3 minus_one_vec3 = vec3(0.0-1.0);
55
+
56
+ float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
57
+ vec3 lpv = lightPos - vertPos;
58
+ vec3 dist = vec3(one_float);
59
+ dist.z = dot(lpv, lpv);
60
+ dist.y = sqrt(dist.z);
61
+ return one_float / dot(dist, coeff);
62
+ }
63
+
64
+ float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
65
+ vec3 lpv = normalize(lightPos - vertPos);
66
+ vec3 nln = minus_one_vec3 * lightNorm;
67
+ float spotCos = dot(nln, lpv);
68
+ return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
69
+ }
70
+
71
+ float lambertFactor(vec3 lightDir, vec3 vecNormal) {
72
+ return max(zero_float, dot(lightDir, vecNormal));
73
+ }
74
+
75
+ float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine) {
76
+ vec3 np = normalize(vertPos);
77
+ vec3 ldp = normalize(lightDir - np);
78
+ return pow(max(zero_float, dot(ldp, vecNormal)), shine);
79
+ }
80
+
81
+ void main() {
82
+ // Vertex in clip coordinates
83
+ gl_Position = transformMatrix * position;
84
+
85
+ // Vertex in eye coordinates
86
+ vec3 ecVertex = vec3(modelviewMatrix * position);
87
+
88
+ // Normal vector in eye coordinates
89
+ vec3 ecNormal = normalize(normalMatrix * normal);
90
+ vec3 ecNormalInv = ecNormal * minus_one_vec3;
91
+
92
+ // Light calculations
93
+ vec3 totalAmbient = vec3(0, 0, 0);
94
+
95
+ vec3 totalFrontDiffuse = vec3(0, 0, 0);
96
+ vec3 totalFrontSpecular = vec3(0, 0, 0);
97
+
98
+ vec3 totalBackDiffuse = vec3(0, 0, 0);
99
+ vec3 totalBackSpecular = vec3(0, 0, 0);
100
+
101
+ // prevent register allocation failure by limiting ourselves to
102
+ // two lights for now
103
+ for (int i = 0; i < 2; i++) {
104
+ if (lightCount == i) break;
105
+
106
+ vec3 lightPos = lightPosition[i].xyz;
107
+ bool isDir = lightPosition[i].w < one_float;
108
+ float spotCos = lightSpot[i].x;
109
+ float spotExp = lightSpot[i].y;
110
+
111
+ vec3 lightDir;
112
+ float falloff;
113
+ float spotf;
114
+
115
+ if (isDir) {
116
+ falloff = one_float;
117
+ lightDir = minus_one_vec3 * lightNormal[i];
118
+ } else {
119
+ falloff = falloffFactor(lightPos, ecVertex, lightFalloff[i]);
120
+ lightDir = normalize(lightPos - ecVertex);
121
+ }
122
+
123
+ spotf = spotExp > zero_float ? spotFactor(lightPos, ecVertex, lightNormal[i],
124
+ spotCos, spotExp)
125
+ : one_float;
126
+
127
+ if (any(greaterThan(lightAmbient[i], zero_vec3))) {
128
+ totalAmbient += lightAmbient[i] * falloff;
129
+ }
130
+
131
+ if (any(greaterThan(lightDiffuse[i], zero_vec3))) {
132
+ totalFrontDiffuse += lightDiffuse[i] * falloff * spotf *
133
+ lambertFactor(lightDir, ecNormal);
134
+ totalBackDiffuse += lightDiffuse[i] * falloff * spotf *
135
+ lambertFactor(lightDir, ecNormalInv);
136
+ }
137
+
138
+ if (any(greaterThan(lightSpecular[i], zero_vec3))) {
139
+ totalFrontSpecular += lightSpecular[i] * falloff * spotf *
140
+ blinnPhongFactor(lightDir, ecVertex, ecNormal, shininess);
141
+ totalBackSpecular += lightSpecular[i] * falloff * spotf *
142
+ blinnPhongFactor(lightDir, ecVertex, ecNormalInv, shininess);
143
+ }
144
+ }
145
+
146
+ // Calculating final color as result of all lights (plus emissive term).
147
+ // Transparency is determined exclusively by the diffuse component.
148
+ vertColor = vec4(totalAmbient, 0) * ambient +
149
+ vec4(totalFrontDiffuse, 1) * color +
150
+ vec4(totalFrontSpecular, 0) * specular +
151
+ vec4(emissive.rgb, 0);
152
+
153
+ backVertColor = vec4(totalAmbient, 0) * ambient +
154
+ vec4(totalBackDiffuse, 1) * color +
155
+ vec4(totalBackSpecular, 0) * specular +
156
+ vec4(emissive.rgb, 0);
157
+
158
+ // Calculating texture coordinates, with r and q set both to one
159
+ vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
160
+ }
@@ -0,0 +1,157 @@
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
+ uniform mat4 texMatrix;
27
+
28
+ uniform int lightCount;
29
+ uniform vec4 lightPosition[8];
30
+ uniform vec3 lightNormal[8];
31
+ uniform vec3 lightAmbient[8];
32
+ uniform vec3 lightDiffuse[8];
33
+ uniform vec3 lightSpecular[8];
34
+ uniform vec3 lightFalloff[8];
35
+ uniform vec2 lightSpot[8];
36
+
37
+ attribute vec4 position;
38
+ attribute vec4 color;
39
+ attribute vec3 normal;
40
+ attribute vec2 texCoord;
41
+
42
+ attribute vec4 ambient;
43
+ attribute vec4 specular;
44
+ attribute vec4 emissive;
45
+ attribute float shininess;
46
+
47
+ varying vec4 vertColor;
48
+ varying vec4 backVertColor;
49
+ varying vec4 vertTexCoord;
50
+
51
+ const float zero_float = 0.0;
52
+ const float one_float = 1.0;
53
+ const vec3 zero_vec3 = vec3(0);
54
+
55
+ float falloffFactor(vec3 lightPos, vec3 vertPos, vec3 coeff) {
56
+ vec3 lpv = lightPos - vertPos;
57
+ vec3 dist = vec3(one_float);
58
+ dist.z = dot(lpv, lpv);
59
+ dist.y = sqrt(dist.z);
60
+ return one_float / dot(dist, coeff);
61
+ }
62
+
63
+ float spotFactor(vec3 lightPos, vec3 vertPos, vec3 lightNorm, float minCos, float spotExp) {
64
+ vec3 lpv = normalize(lightPos - vertPos);
65
+ vec3 nln = -one_float * lightNorm;
66
+ float spotCos = dot(nln, lpv);
67
+ return spotCos <= minCos ? zero_float : pow(spotCos, spotExp);
68
+ }
69
+
70
+ float lambertFactor(vec3 lightDir, vec3 vecNormal) {
71
+ return max(zero_float, dot(lightDir, vecNormal));
72
+ }
73
+
74
+ float blinnPhongFactor(vec3 lightDir, vec3 vertPos, vec3 vecNormal, float shine) {
75
+ vec3 np = normalize(vertPos);
76
+ vec3 ldp = normalize(lightDir - np);
77
+ return pow(max(zero_float, dot(ldp, vecNormal)), shine);
78
+ }
79
+
80
+ void main() {
81
+ // Vertex in clip coordinates
82
+ gl_Position = transformMatrix * position;
83
+
84
+ // Vertex in eye coordinates
85
+ vec3 ecVertex = vec3(modelviewMatrix * position);
86
+
87
+ // Normal vector in eye coordinates
88
+ vec3 ecNormal = normalize(normalMatrix * normal);
89
+ vec3 ecNormalInv = ecNormal * -one_float;
90
+
91
+ // Light calculations
92
+ vec3 totalAmbient = vec3(0, 0, 0);
93
+
94
+ vec3 totalFrontDiffuse = vec3(0, 0, 0);
95
+ vec3 totalFrontSpecular = vec3(0, 0, 0);
96
+
97
+ vec3 totalBackDiffuse = vec3(0, 0, 0);
98
+ vec3 totalBackSpecular = vec3(0, 0, 0);
99
+
100
+ for (int i = 0; i < 8; 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 = -one_float * 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
+
155
+ // Calculating texture coordinates, with r and q set both to one
156
+ vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
157
+ }
@@ -0,0 +1,38 @@
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
+ uniform mat4 texMatrix;
25
+
26
+ attribute vec4 position;
27
+ attribute vec4 color;
28
+ attribute vec2 texCoord;
29
+
30
+ varying vec4 vertColor;
31
+ varying vec4 vertTexCoord;
32
+
33
+ void main() {
34
+ gl_Position = transformMatrix * position;
35
+
36
+ vertColor = color;
37
+ vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
38
+ }
Binary file
Binary file
Binary file
Binary file