picrate 1.2.3-java → 2.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile +3 -1
- data/README.md +8 -9
- data/Rakefile +10 -9
- data/bin/picrate +3 -1
- data/docs/_config.yml +1 -1
- data/docs/_editors/geany.md +1 -0
- data/docs/_gems/gems/gems.md +1 -1
- data/docs/_posts/2018-05-06-getting_started.md +4 -4
- data/docs/_posts/2018-05-06-install_jruby.md +5 -11
- data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
- data/docs/_posts/2018-11-18-building-gem.md +2 -2
- data/docs/_posts/2018-11-27-getting_started_geany.md +4 -4
- data/docs/_posts/2019-11-11-getting_started_buster.md +4 -7
- data/docs/_posts/2020-03-09-auto_install_picrate.md +34 -0
- data/docs/_posts/2020-05-11-getting_started_manjaro.md +94 -0
- data/docs/about.md +1 -1
- data/lib/picrate.rb +1 -1
- data/lib/picrate/app.rb +11 -3
- data/lib/picrate/creators/parameters.rb +8 -8
- data/lib/picrate/creators/sketch_factory.rb +5 -3
- data/lib/picrate/helper_methods.rb +21 -21
- data/lib/picrate/helpers/numeric.rb +2 -0
- data/lib/picrate/library.rb +5 -1
- data/lib/picrate/library_loader.rb +2 -0
- data/lib/picrate/native_folder.rb +2 -1
- data/lib/picrate/native_loader.rb +3 -0
- data/lib/picrate/runner.rb +5 -2
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +17 -8
- data/library/chooser/chooser.rb +10 -9
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +7 -4
- data/library/dxf/dxf.rb +2 -0
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/slider/slider.rb +24 -23
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/picrate.gemspec +13 -14
- data/pom.rb +28 -26
- data/pom.xml +18 -6
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PicrateLibrary.java +8 -8
- data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
- data/src/main/java/processing/awt/ShimAWT.java +545 -0
- data/src/main/java/processing/core/PApplet.java +699 -1523
- data/src/main/java/processing/core/PConstants.java +180 -180
- data/src/main/java/processing/core/PFont.java +2 -2
- data/src/main/java/processing/core/PGraphics.java +190 -176
- data/src/main/java/processing/core/PImage.java +1536 -1721
- data/src/main/java/processing/core/PMatrix.java +39 -39
- data/src/main/java/processing/core/PSurface.java +69 -103
- data/src/main/java/processing/core/PSurfaceNone.java +29 -0
- data/src/main/java/processing/core/PVector.java +2 -2
- data/src/main/java/processing/data/FloatDict.java +251 -284
- data/src/main/java/processing/data/TableRow.java +32 -32
- data/src/main/java/processing/dxf/RawDXF.java +3 -3
- data/src/main/java/processing/net/Client.java +1 -1
- data/src/main/java/processing/opengl/PGL.java +1016 -4132
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +223 -184
- data/src/main/java/processing/opengl/PJOGL.java +374 -1526
- data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
- data/test/color_group_test.rb +4 -4
- data/test/deglut_spec_test.rb +2 -0
- data/test/helper_methods_test.rb +41 -13
- data/test/math_tool_test.rb +46 -37
- data/test/respond_to_test.rb +5 -3
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +30 -19
- data/vendors/Rakefile +13 -7
- data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
- metadata +26 -47
- data/docs/_posts/2018-06-26-auto_install_picrate.md +0 -30
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- 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
|
28
|
+
base_path=<%= home %>
|
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
|
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(home, directory, template = geany_config)
|
73
|
+
@home = home
|
74
|
+
@directory = File.join(home, 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,85 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- monkstone
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '5.10'
|
19
|
+
name: minitest
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
32
|
+
version: '12.3'
|
33
|
+
name: rake
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: arcball
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0
|
48
|
-
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
46
|
+
version: '1.0'
|
47
|
+
- - ">="
|
53
48
|
- !ruby/object:Gem::Version
|
54
49
|
version: 1.0.1
|
55
|
-
|
56
|
-
name: geomerative
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.1'
|
50
|
+
name: arcball
|
62
51
|
type: :runtime
|
63
52
|
prerelease: false
|
64
53
|
version_requirements: !ruby/object:Gem::Requirement
|
65
54
|
requirements:
|
66
55
|
- - "~>"
|
67
56
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
69
|
-
-
|
70
|
-
name: ruby_wordcram
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.0.4
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
57
|
+
version: '1.0'
|
58
|
+
- - ">="
|
81
59
|
- !ruby/object:Gem::Version
|
82
|
-
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.
|
193
|
+
- lib/picrate-2.1.0.jar
|
213
194
|
- lib/picrate.rb
|
214
195
|
- lib/picrate/app.rb
|
215
196
|
- lib/picrate/creators/parameters.rb
|
@@ -272,8 +253,10 @@ files:
|
|
272
253
|
- src/main/java/monkstone/videoevent/MovieEvent.java
|
273
254
|
- src/main/java/monkstone/videoevent/package-info.java
|
274
255
|
- src/main/java/processing/awt/PGraphicsJava2D.java
|
256
|
+
- src/main/java/processing/awt/PImageAWT.java
|
275
257
|
- src/main/java/processing/awt/PShapeJava2D.java
|
276
258
|
- src/main/java/processing/awt/PSurfaceAWT.java
|
259
|
+
- src/main/java/processing/awt/ShimAWT.java
|
277
260
|
- src/main/java/processing/core/PApplet.java
|
278
261
|
- src/main/java/processing/core/PConstants.java
|
279
262
|
- src/main/java/processing/core/PFont.java
|
@@ -334,8 +317,6 @@ files:
|
|
334
317
|
- src/main/java/processing/opengl/shaders/ColorFrag.glsl
|
335
318
|
- src/main/java/processing/opengl/shaders/ColorVert.glsl
|
336
319
|
- 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
320
|
- src/main/java/processing/opengl/shaders/LightVert.glsl
|
340
321
|
- src/main/java/processing/opengl/shaders/LineFrag.glsl
|
341
322
|
- src/main/java/processing/opengl/shaders/LineVert.glsl
|
@@ -344,8 +325,6 @@ files:
|
|
344
325
|
- src/main/java/processing/opengl/shaders/PointVert.glsl
|
345
326
|
- src/main/java/processing/opengl/shaders/TexFrag.glsl
|
346
327
|
- 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
328
|
- src/main/java/processing/opengl/shaders/TexLightVert.glsl
|
350
329
|
- src/main/java/processing/opengl/shaders/TexVert.glsl
|
351
330
|
- src/main/resources/icon/icon-128.png
|
@@ -366,8 +345,8 @@ files:
|
|
366
345
|
- test/test_helper.rb
|
367
346
|
- test/vecmath_spec_test.rb
|
368
347
|
- vendors/Rakefile
|
348
|
+
- vendors/geany.rb
|
369
349
|
- vendors/picrate.rb
|
370
|
-
- vendors/picrate_sketches.geany
|
371
350
|
homepage: https://ruby-processing.github.io/PiCrate/
|
372
351
|
licenses:
|
373
352
|
- GPL-3.0
|
@@ -388,11 +367,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
388
367
|
- !ruby/object:Gem::Version
|
389
368
|
version: '0'
|
390
369
|
requirements:
|
391
|
-
- java runtime ==
|
370
|
+
- java runtime == 11
|
392
371
|
rubygems_version: 3.0.6
|
393
|
-
signing_key:
|
372
|
+
signing_key:
|
394
373
|
specification_version: 4
|
395
|
-
summary: ruby
|
374
|
+
summary: ruby implementation of processing-3 on raspberrypi and linux64
|
396
375
|
test_files:
|
397
376
|
- test/color_group_test.rb
|
398
377
|
- test/deglut_spec_test.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: post
|
3
|
-
title: "Automated PiCrate Install"
|
4
|
-
date: 2018-06-26 07:34:13
|
5
|
-
categories: PiCrate update
|
6
|
-
permalink: /install_picrate/
|
7
|
-
---
|
8
|
-
|
9
|
-
For a semi-automated setup and install, download and extract [this gist](https://gist.github.com/monkstone/e9df8ea776aed58ce1c4de8e12982aad). To keep your system clean put the file in a folder say
|
10
|
-
`~/install_picrate`
|
11
|
-
|
12
|
-
```bash
|
13
|
-
cd ~/picrate_install
|
14
|
-
bash picrate_install.sh # to run default task
|
15
|
-
```
|
16
|
-
#### What the script does ###
|
17
|
-
1. Downloads JRuby
|
18
|
-
2. Installs JRuby to `/opt`
|
19
|
-
3. Uses `update-alternatives` to configure `jruby`, `jgem` and `jirb`
|
20
|
-
4. The script checks for `GEM_HOME`, if undefined it modifies `~/.profile` to define `GEM_HOME` and puts gem binaries on your path, at logon.
|
21
|
-
5. Installs `picrate` gem
|
22
|
-
6. Downloads and installs `picrate_samples` also configures `geanyIDE` for use with `picrate`
|
23
|
-
|
24
|
-
#### Note ####
|
25
|
-
`GEM_HOME` and path to `gem` binaries is not available until next logon, to use immediately you could:-
|
26
|
-
|
27
|
-
```bash
|
28
|
-
source ~/.profile
|
29
|
-
```
|
30
|
-
NB: this only works in current shell, so if you want to use `geanyIDE` you should logout and logon again.
|
@@ -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
|
-
}
|