propane 3.4.0-java → 3.7.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +2 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -0
- data/README.md +17 -8
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +6 -4
- data/lib/propane/app.rb +20 -10
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +23 -24
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +14 -6
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +28 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +6 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +7 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +4 -1
- data/pom.rb +37 -36
- data/pom.xml +7 -7
- data/propane.gemspec +16 -12
- data/src/main/java/monkstone/ColorUtil.java +13 -1
- data/src/main/java/monkstone/MathToolModule.java +253 -203
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- 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 +1 -1
- 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 +7 -6
- 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 +3 -3
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -209
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +4510 -4503
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +193 -177
- data/src/main/java/processing/core/PImage.java +611 -309
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2888 -2652
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +997 -965
- data/src/main/java/processing/core/ThinkDifferent.java +15 -13
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +289 -270
- data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
- data/src/main/java/processing/opengl/LinePath.java +547 -500
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +3047 -2914
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +1266 -1257
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- 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 +35 -22
- data/vendors/Rakefile +33 -62
- metadata +56 -48
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
- 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,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
|
-
}
|
@@ -1,160 +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
|
-
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
|
-
}
|