picrate 1.3.0-java → 2.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  3. data/CHANGELOG.md +10 -1
  4. data/Gemfile +3 -1
  5. data/README.md +9 -6
  6. data/Rakefile +8 -3
  7. data/bin/picrate +3 -1
  8. data/docs/_config.yml +1 -1
  9. data/docs/_editors/geany.md +1 -0
  10. data/docs/_gems/gems/gems.md +1 -1
  11. data/docs/_methods/alternative_methods.md +2 -1
  12. data/docs/_posts/2018-05-06-getting_started.md +4 -4
  13. data/docs/_posts/2018-05-06-install_jruby.md +5 -11
  14. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
  15. data/docs/_posts/2018-11-18-building-gem.md +2 -2
  16. data/docs/_posts/2018-11-27-getting_started_geany.md +1 -1
  17. data/docs/_posts/2019-11-11-getting_started_buster.md +3 -6
  18. data/docs/_posts/{2018-06-26-auto_install_picrate.md → 2020-03-09-auto_install_picrate.md} +9 -6
  19. data/docs/_posts/2020-05-11-getting_started_manjaro.md +106 -0
  20. data/docs/about.md +1 -1
  21. data/lib/picrate.rb +3 -2
  22. data/lib/picrate/app.rb +11 -3
  23. data/lib/picrate/creators/parameters.rb +8 -8
  24. data/lib/picrate/creators/sketch_factory.rb +5 -3
  25. data/lib/picrate/helper_methods.rb +22 -22
  26. data/lib/picrate/helpers/numeric.rb +2 -0
  27. data/lib/picrate/library.rb +5 -1
  28. data/lib/picrate/library_loader.rb +2 -0
  29. data/lib/picrate/native_folder.rb +2 -1
  30. data/lib/picrate/native_loader.rb +3 -0
  31. data/lib/picrate/runner.rb +5 -4
  32. data/lib/picrate/version.rb +1 -1
  33. data/library/boids/boids.rb +17 -8
  34. data/library/chooser/chooser.rb +10 -9
  35. data/library/color_group/color_group.rb +2 -0
  36. data/library/control_panel/control_panel.rb +7 -4
  37. data/library/dxf/dxf.rb +2 -0
  38. data/library/jcomplex/jcomplex.rb +1 -0
  39. data/library/library_proxy/library_proxy.rb +2 -0
  40. data/library/net/net.rb +2 -0
  41. data/library/slider/slider.rb +24 -23
  42. data/library/vector_utils/vector_utils.rb +4 -0
  43. data/library/video_event/video_event.rb +2 -0
  44. data/mvnw +2 -2
  45. data/mvnw.cmd +2 -2
  46. data/picrate.gemspec +13 -13
  47. data/pom.rb +26 -23
  48. data/pom.xml +19 -7
  49. data/src/main/java/monkstone/ColorUtil.java +1 -1
  50. data/src/main/java/monkstone/MathToolModule.java +1 -1
  51. data/src/main/java/monkstone/PicrateLibrary.java +8 -8
  52. data/src/main/java/monkstone/complex/JComplex.java +252 -0
  53. data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
  54. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  55. data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
  56. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  57. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  58. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
  59. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  60. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  61. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  62. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  63. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  64. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  65. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  66. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  67. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  68. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  69. data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
  70. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  71. data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
  72. data/src/main/java/processing/awt/ShimAWT.java +545 -0
  73. data/src/main/java/processing/core/PApplet.java +699 -1523
  74. data/src/main/java/processing/core/PConstants.java +180 -180
  75. data/src/main/java/processing/core/PFont.java +2 -2
  76. data/src/main/java/processing/core/PGraphics.java +190 -176
  77. data/src/main/java/processing/core/PImage.java +1536 -1721
  78. data/src/main/java/processing/core/PMatrix.java +39 -39
  79. data/src/main/java/processing/core/PSurface.java +69 -103
  80. data/src/main/java/processing/core/PSurfaceNone.java +29 -0
  81. data/src/main/java/processing/core/PVector.java +2 -2
  82. data/src/main/java/processing/data/FloatDict.java +251 -284
  83. data/src/main/java/processing/data/TableRow.java +32 -32
  84. data/src/main/java/processing/dxf/RawDXF.java +3 -3
  85. data/src/main/java/processing/net/Client.java +1 -1
  86. data/src/main/java/processing/opengl/PGL.java +1016 -4132
  87. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +232 -176
  88. data/src/main/java/processing/opengl/PJOGL.java +374 -1526
  89. data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
  90. data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
  91. data/test/color_group_test.rb +4 -4
  92. data/test/deglut_spec_test.rb +2 -0
  93. data/test/helper_methods_test.rb +41 -13
  94. data/test/math_tool_test.rb +46 -37
  95. data/test/respond_to_test.rb +5 -3
  96. data/test/sketches/key_event.rb +2 -2
  97. data/test/sketches/library/my_library/my_library.rb +3 -0
  98. data/test/test_helper.rb +2 -0
  99. data/test/vecmath_spec_test.rb +30 -19
  100. data/vendors/Rakefile +33 -21
  101. data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
  102. metadata +27 -46
  103. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  104. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  105. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  106. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -1,3 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ def geany_config
6
+ %(
1
7
  [editor]
2
8
  line_wrapping=false
3
9
  line_break_column=72
@@ -19,7 +25,7 @@ indent_mode=2
19
25
 
20
26
  [project]
21
27
  name=picrate_samples
22
- base_path=/home/pi/projects/picrate_sketches
28
+ base_path=examples
23
29
  description=Exploring PiCrate
24
30
  file_patterns=*.rb;*.glsl;*.txt;
25
31
 
@@ -28,14 +34,9 @@ long_line_behaviour=1
28
34
  long_line_column=72
29
35
 
30
36
  [files]
31
- current_page=3
32
- FILE_NAME_0=667;Ruby;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fprojects%2Fpicrate_sketches%2Fbasics%2Farrays%2Farray.rb;0;2
33
- FILE_NAME_1=1664;Ruby;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fprojects%2Fpicrate_sketches%2Fadvanced_data%2Fload_save_json.rb;0;2
34
- FILE_NAME_2=259;Sh;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Fjruby_install.sh;0;2
35
- FILE_NAME_3=236;Sh;0;EUTF-8;0;1;0;%2Fhome%2Fpi%2Ftest.sh;0;2
36
37
 
37
38
  [VTE]
38
- last_dir=/home/pi
39
+ last_dir=<%= directory %>
39
40
 
40
41
  [build-menu]
41
42
  EX_00_LB=_Execute
@@ -60,3 +61,27 @@ NF_02_WD=
60
61
  RubyFT_02_LB=_Reek
61
62
  RubyFT_02_CM=reek --failure-exit-code=0 "%f"
62
63
  RubyFT_02_WD=
64
+ )
65
+ end
66
+
67
+ # Class to merge ERB template and write config to file
68
+ class GeanyConfig
69
+ include ERB::Util
70
+ attr_accessor :home, :directory, :template
71
+
72
+ def initialize(directory, template = geany_config)
73
+ @home = home
74
+ @directory = directory
75
+ @template = template
76
+ end
77
+
78
+ def render
79
+ ERB.new(@template).result(binding)
80
+ end
81
+
82
+ def save(file)
83
+ File.open(file, 'w+') do |f|
84
+ f.write(render)
85
+ end
86
+ end
87
+ end
metadata CHANGED
@@ -1,36 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.1.2
5
5
  platform: java
6
6
  authors:
7
7
  - monkstone
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-22 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '12.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '12.3'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
14
  requirement: !ruby/object:Gem::Requirement
30
15
  requirements:
31
16
  - - "~>"
32
17
  - !ruby/object:Gem::Version
33
18
  version: '5.10'
19
+ name: minitest
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -39,47 +25,39 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '5.10'
41
27
  - !ruby/object:Gem::Dependency
42
- name: arcball
43
28
  requirement: !ruby/object:Gem::Requirement
44
29
  requirements:
45
30
  - - "~>"
46
31
  - !ruby/object:Gem::Version
47
- version: 1.0.1
32
+ version: '13.0'
33
+ name: rake
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 1.0.1
40
+ version: '13.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: geomerative
57
42
  requirement: !ruby/object:Gem::Requirement
58
43
  requirements:
59
44
  - - "~>"
60
45
  - !ruby/object:Gem::Version
61
- version: '1.1'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.1'
69
- - !ruby/object:Gem::Dependency
70
- name: ruby_wordcram
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
46
+ version: '1.0'
47
+ - - ">="
74
48
  - !ruby/object:Gem::Version
75
- version: 2.0.4
49
+ version: 1.0.1
50
+ name: arcball
76
51
  type: :runtime
77
52
  prerelease: false
78
53
  version_requirements: !ruby/object:Gem::Requirement
79
54
  requirements:
80
55
  - - "~>"
81
56
  - !ruby/object:Gem::Version
82
- version: 2.0.4
57
+ version: '1.0'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.0.1
83
61
  description: |
84
62
  A batteries included version of processing in ruby, for raspberrypi and
85
63
  linux. Install samples to configures geany ide.
@@ -170,10 +148,11 @@ files:
170
148
  - docs/_posts/2018-05-06-install_jruby.md
171
149
  - docs/_posts/2018-05-06-processing-api.md
172
150
  - docs/_posts/2018-05-11-arch-linux-arm.md
173
- - docs/_posts/2018-06-26-auto_install_picrate.md
174
151
  - docs/_posts/2018-11-18-building-gem.md
175
152
  - docs/_posts/2018-11-27-getting_started_geany.md
176
153
  - docs/_posts/2019-11-11-getting_started_buster.md
154
+ - docs/_posts/2020-03-09-auto_install_picrate.md
155
+ - docs/_posts/2020-05-11-getting_started_manjaro.md
177
156
  - docs/_sass/_base.scss
178
157
  - docs/_sass/_layout.scss
179
158
  - docs/_sass/_syntax-highlighting.scss
@@ -203,13 +182,15 @@ files:
203
182
  - docs/modules.md
204
183
  - docs/objects.md
205
184
  - lib/export.txt
185
+ - lib/gluegen-rt-natives-linux-aarch64.jar
206
186
  - lib/gluegen-rt-natives-linux-amd64.jar
207
187
  - lib/gluegen-rt-natives-linux-armv6hf.jar
208
188
  - lib/gluegen-rt.jar
189
+ - lib/jogl-all-natives-linux-aarch64.jar
209
190
  - lib/jogl-all-natives-linux-amd64.jar
210
191
  - lib/jogl-all-natives-linux-armv6hf.jar
211
192
  - lib/jogl-all.jar
212
- - lib/picrate-1.3.0.jar
193
+ - lib/picrate-2.1.2.jar
213
194
  - lib/picrate.rb
214
195
  - lib/picrate/app.rb
215
196
  - lib/picrate/creators/parameters.rb
@@ -228,6 +209,7 @@ files:
228
209
  - library/color_group/color_group.rb
229
210
  - library/control_panel/control_panel.rb
230
211
  - library/dxf/dxf.rb
212
+ - library/jcomplex/jcomplex.rb
231
213
  - library/library_proxy/README.md
232
214
  - library/library_proxy/library_proxy.rb
233
215
  - library/net/net.rb
@@ -245,6 +227,7 @@ files:
245
227
  - src/main/java/monkstone/ColorUtil.java
246
228
  - src/main/java/monkstone/MathToolModule.java
247
229
  - src/main/java/monkstone/PicrateLibrary.java
230
+ - src/main/java/monkstone/complex/JComplex.java
248
231
  - src/main/java/monkstone/core/LibraryProxy.java
249
232
  - src/main/java/monkstone/fastmath/Deglut.java
250
233
  - src/main/java/monkstone/fastmath/package-info.java
@@ -272,8 +255,10 @@ files:
272
255
  - src/main/java/monkstone/videoevent/MovieEvent.java
273
256
  - src/main/java/monkstone/videoevent/package-info.java
274
257
  - src/main/java/processing/awt/PGraphicsJava2D.java
258
+ - src/main/java/processing/awt/PImageAWT.java
275
259
  - src/main/java/processing/awt/PShapeJava2D.java
276
260
  - src/main/java/processing/awt/PSurfaceAWT.java
261
+ - src/main/java/processing/awt/ShimAWT.java
277
262
  - src/main/java/processing/core/PApplet.java
278
263
  - src/main/java/processing/core/PConstants.java
279
264
  - src/main/java/processing/core/PFont.java
@@ -334,8 +319,6 @@ files:
334
319
  - src/main/java/processing/opengl/shaders/ColorFrag.glsl
335
320
  - src/main/java/processing/opengl/shaders/ColorVert.glsl
336
321
  - src/main/java/processing/opengl/shaders/LightFrag.glsl
337
- - src/main/java/processing/opengl/shaders/LightVert-brcm.glsl
338
- - src/main/java/processing/opengl/shaders/LightVert-vc4.glsl
339
322
  - src/main/java/processing/opengl/shaders/LightVert.glsl
340
323
  - src/main/java/processing/opengl/shaders/LineFrag.glsl
341
324
  - src/main/java/processing/opengl/shaders/LineVert.glsl
@@ -344,8 +327,6 @@ files:
344
327
  - src/main/java/processing/opengl/shaders/PointVert.glsl
345
328
  - src/main/java/processing/opengl/shaders/TexFrag.glsl
346
329
  - src/main/java/processing/opengl/shaders/TexLightFrag.glsl
347
- - src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl
348
- - src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl
349
330
  - src/main/java/processing/opengl/shaders/TexLightVert.glsl
350
331
  - src/main/java/processing/opengl/shaders/TexVert.glsl
351
332
  - src/main/resources/icon/icon-128.png
@@ -366,8 +347,8 @@ files:
366
347
  - test/test_helper.rb
367
348
  - test/vecmath_spec_test.rb
368
349
  - vendors/Rakefile
350
+ - vendors/geany.rb
369
351
  - vendors/picrate.rb
370
- - vendors/picrate_sketches.geany
371
352
  homepage: https://ruby-processing.github.io/PiCrate/
372
353
  licenses:
373
354
  - GPL-3.0
@@ -388,9 +369,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
388
369
  - !ruby/object:Gem::Version
389
370
  version: '0'
390
371
  requirements:
391
- - java runtime == 8
372
+ - java runtime == 11
392
373
  rubygems_version: 3.0.6
393
- signing_key:
374
+ signing_key:
394
375
  specification_version: 4
395
376
  summary: ruby implementation of processing-3 on raspberrypi and linux64
396
377
  test_files:
@@ -1,154 +0,0 @@
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
- }
@@ -1,154 +0,0 @@
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
- // four lights for now
100
- for (int i = 0; i < 4; 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
- }