p5 2.0.0 → 2.0.1
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.
- package/{src → dist}/accessibility/color_namer.js +48 -3
- package/{src → dist}/accessibility/describe.js +2 -2
- package/{src → dist}/accessibility/gridOutput.js +2 -2
- package/dist/accessibility/index.js +60 -0
- package/{src → dist}/accessibility/outputs.js +2 -2
- package/{src → dist}/accessibility/textOutput.js +2 -2
- package/dist/app.js +120 -0
- package/{src → dist}/color/color_conversion.js +48 -10
- package/{src → dist}/color/color_spaces/hsb.js +3 -1
- package/dist/color/creating_reading.js +3 -0
- package/dist/color/index.js +13 -0
- package/dist/color/p5.Color.culori.js +1 -0
- package/dist/color/p5.Color.js +3 -0
- package/{src → dist}/color/setting.js +9 -6
- package/{src/core/constants.js → dist/constants-C-g_eAdC.js} +266 -130
- package/{src → dist}/core/States.js +3 -1
- package/dist/core/constants.js +1 -0
- package/{src → dist}/core/environment.js +7 -6
- package/{src → dist}/core/friendly_errors/browser_errors.js +1 -1
- package/{src → dist}/core/friendly_errors/fes_core.js +14 -44
- package/{src → dist}/core/friendly_errors/file_errors.js +6 -3
- package/dist/core/friendly_errors/index.js +23 -0
- package/dist/core/friendly_errors/param_validator.js +5455 -0
- package/{src → dist}/core/friendly_errors/sketch_reader.js +50 -4
- package/{src → dist}/core/friendly_errors/sketch_verifier.js +6 -6
- package/{src → dist}/core/friendly_errors/stacktrace.js +3 -5
- package/{src → dist}/core/friendly_errors/validate_params.js +50 -41
- package/{src → dist}/core/helpers.js +9 -6
- package/dist/core/init.js +105 -0
- package/dist/core/internationalization.js +302 -0
- package/dist/core/legacy.js +73 -0
- package/dist/core/main.js +44 -0
- package/dist/core/noop.js +3 -0
- package/dist/core/p5.Graphics.js +40 -0
- package/dist/core/p5.Renderer.js +11 -0
- package/dist/core/p5.Renderer2D.js +44 -0
- package/dist/core/reference.js +1 -0
- package/dist/core/rendering.js +40 -0
- package/{src → dist}/core/structure.js +3 -3
- package/{src → dist}/core/transform.js +2 -2
- package/{src/color/creating_reading.js → dist/creating_reading-D4AAKRbx.js} +841 -13
- package/{src → dist}/data/index.js +3 -1
- package/{src → dist}/data/local_storage.js +2 -8
- package/{src → dist}/dom/dom.js +11 -5
- package/dist/dom/index.js +18 -0
- package/{src → dist}/dom/p5.Element.js +14 -12
- package/{src → dist}/dom/p5.File.js +4 -4
- package/{src → dist}/dom/p5.MediaElement.js +10 -4
- package/{src → dist}/events/acceleration.js +2 -2
- package/{src → dist}/events/index.js +3 -1
- package/{src → dist}/events/keyboard.js +14 -11
- package/{src → dist}/events/pointer.js +16 -17
- package/dist/image/const.js +9 -0
- package/{src → dist}/image/filterRenderer2D.js +57 -37
- package/{src → dist}/image/filters.js +1 -3
- package/dist/image/image.js +40 -0
- package/dist/image/index.js +51 -0
- package/dist/image/loading_displaying.js +40 -0
- package/dist/image/p5.Image.js +11 -0
- package/{src → dist}/image/pixels.js +4 -3
- package/{src → dist}/io/csv.js +72 -70
- package/dist/io/files.js +40 -0
- package/dist/io/index.js +51 -0
- package/{src → dist}/io/p5.Table.js +6 -6
- package/{src → dist}/io/p5.TableRow.js +3 -4
- package/{src → dist}/io/p5.XML.js +2 -5
- package/{src → dist}/io/utilities.js +1 -1
- package/{src/core/p5.Renderer2D.js → dist/main-s72KWcUy.js} +735 -57
- package/{src → dist}/math/Matrices/Matrix.js +10 -8
- package/{src → dist}/math/Matrices/MatrixInterface.js +5 -3
- package/{src → dist}/math/Matrices/MatrixNumjs.js +12 -26
- package/{src → dist}/math/calculation.js +2 -2
- package/{src → dist}/math/index.js +6 -3
- package/{src → dist}/math/math.js +2 -2
- package/{src → dist}/math/noise.js +2 -2
- package/{src → dist}/math/p5.Matrix.js +7 -4
- package/{src → dist}/math/p5.Vector.js +6 -6
- package/{src → dist}/math/random.js +2 -2
- package/{src → dist}/math/trigonometry.js +16 -15
- package/{src/image/p5.Image.js → dist/p5.Renderer-CwAYZOC2.js} +390 -19
- package/dist/rendering--aAe5aq3.js +24925 -0
- package/{src → dist}/shape/2d_primitives.js +18 -17
- package/{src → dist}/shape/attributes.js +18 -17
- package/{src → dist}/shape/curves.js +2 -2
- package/{src → dist}/shape/custom_shapes.js +44 -64
- package/{src → dist}/shape/index.js +10 -2
- package/{src → dist}/shape/vertex.js +2 -3
- package/dist/type/index.js +25 -0
- package/{src → dist}/type/lib/Typr.js +76 -94
- package/{src → dist}/type/p5.Font.js +37 -61
- package/{src → dist}/type/textCore.js +34 -57
- package/{src → dist}/type/unicodeRanges.js +3 -1
- package/{src → dist}/utilities/conversion.js +2 -2
- package/{src → dist}/utilities/index.js +3 -1
- package/{src → dist}/utilities/time_date.js +6 -7
- package/{src → dist}/utilities/utility_functions.js +2 -2
- package/dist/webgl/3d_primitives.js +40 -0
- package/{src → dist}/webgl/GeometryBufferCache.js +3 -1
- package/{src → dist}/webgl/GeometryBuilder.js +12 -8
- package/{src → dist}/webgl/ShaderGenerator.js +79 -82
- package/{src → dist}/webgl/ShapeBuilder.js +26 -23
- package/dist/webgl/index.js +76 -0
- package/{src → dist}/webgl/interaction.js +7 -6
- package/dist/webgl/light.js +40 -0
- package/{src → dist}/webgl/loading.js +45 -12
- package/dist/webgl/material.js +40 -0
- package/dist/webgl/p5.Camera.js +40 -0
- package/{src → dist}/webgl/p5.DataArray.js +3 -5
- package/dist/webgl/p5.Framebuffer.js +40 -0
- package/{src → dist}/webgl/p5.Geometry.js +12 -15
- package/{src → dist}/webgl/p5.Quat.js +5 -4
- package/{src → dist}/webgl/p5.RenderBuffer.js +2 -3
- package/dist/webgl/p5.RendererGL.js +40 -0
- package/dist/webgl/p5.Shader.js +40 -0
- package/dist/webgl/p5.Texture.js +40 -0
- package/{src → dist}/webgl/text.js +51 -9
- package/lib/p5.esm.js +102 -48
- package/lib/p5.js +102 -48
- package/lib/p5.min.js +1 -1
- package/package.json +17 -16
- package/translations/dev.js +6 -6
- package/translations/index.js +1 -1
- package/src/README.md +0 -27
- package/src/accessibility/index.js +0 -13
- package/src/app.js +0 -61
- package/src/color/index.js +0 -9
- package/src/color/p5.Color.culori.js +0 -66
- package/src/color/p5.Color.js +0 -851
- package/src/core/README.md +0 -91
- package/src/core/friendly_errors/index.js +0 -13
- package/src/core/friendly_errors/param_validator.js +0 -561
- package/src/core/init.js +0 -58
- package/src/core/internationalization.js +0 -195
- package/src/core/legacy.js +0 -29
- package/src/core/main.js +0 -689
- package/src/core/noop.js +0 -1
- package/src/core/p5.Graphics.js +0 -696
- package/src/core/p5.Renderer.js +0 -408
- package/src/core/reference.js +0 -2060
- package/src/core/rendering.js +0 -697
- package/src/dom/index.js +0 -11
- package/src/image/const.js +0 -6
- package/src/image/image.js +0 -731
- package/src/image/index.js +0 -15
- package/src/image/loading_displaying.js +0 -1431
- package/src/io/files.js +0 -2210
- package/src/io/index.js +0 -11
- package/src/math/README.md +0 -40
- package/src/type/index.js +0 -9
- package/src/webgl/3d_primitives.js +0 -2741
- package/src/webgl/index.js +0 -37
- package/src/webgl/light.js +0 -1851
- package/src/webgl/material.js +0 -3854
- package/src/webgl/p5.Camera.js +0 -4010
- package/src/webgl/p5.Framebuffer.js +0 -1865
- package/src/webgl/p5.RendererGL.js +0 -2867
- package/src/webgl/p5.Shader.js +0 -1505
- package/src/webgl/p5.Texture.js +0 -541
- package/src/webgl/shaders/basic.frag +0 -6
- package/src/webgl/shaders/filters/base.frag +0 -22
- package/src/webgl/shaders/filters/base.vert +0 -19
- package/src/webgl/shaders/filters/blur.frag +0 -60
- package/src/webgl/shaders/filters/default.vert +0 -18
- package/src/webgl/shaders/filters/dilate.frag +0 -39
- package/src/webgl/shaders/filters/erode.frag +0 -39
- package/src/webgl/shaders/filters/gray.frag +0 -16
- package/src/webgl/shaders/filters/invert.frag +0 -15
- package/src/webgl/shaders/filters/opaque.frag +0 -12
- package/src/webgl/shaders/filters/posterize.frag +0 -29
- package/src/webgl/shaders/filters/threshold.frag +0 -23
- package/src/webgl/shaders/font.frag +0 -216
- package/src/webgl/shaders/font.vert +0 -44
- package/src/webgl/shaders/imageLight.vert +0 -33
- package/src/webgl/shaders/imageLightDiffused.frag +0 -82
- package/src/webgl/shaders/imageLightSpecular.frag +0 -134
- package/src/webgl/shaders/light.vert +0 -37
- package/src/webgl/shaders/light_texture.frag +0 -26
- package/src/webgl/shaders/lighting.glsl +0 -227
- package/src/webgl/shaders/line.frag +0 -74
- package/src/webgl/shaders/line.vert +0 -294
- package/src/webgl/shaders/normal.frag +0 -6
- package/src/webgl/shaders/normal.vert +0 -72
- package/src/webgl/shaders/phong.frag +0 -84
- package/src/webgl/shaders/phong.vert +0 -87
- package/src/webgl/shaders/point.frag +0 -29
- package/src/webgl/shaders/point.vert +0 -19
- package/src/webgl/shaders/sphereMapping.frag +0 -26
- package/src/webgl/shaders/webgl2Compatibility.glsl +0 -34
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// include lighting.glgl
|
|
2
|
-
|
|
3
|
-
IN vec3 aPosition;
|
|
4
|
-
IN vec3 aNormal;
|
|
5
|
-
IN vec2 aTexCoord;
|
|
6
|
-
IN vec4 aVertexColor;
|
|
7
|
-
|
|
8
|
-
uniform mat4 uModelViewMatrix;
|
|
9
|
-
uniform mat4 uProjectionMatrix;
|
|
10
|
-
uniform mat3 uNormalMatrix;
|
|
11
|
-
|
|
12
|
-
uniform bool uUseVertexColor;
|
|
13
|
-
uniform vec4 uMaterialColor;
|
|
14
|
-
|
|
15
|
-
OUT highp vec2 vVertTexCoord;
|
|
16
|
-
OUT vec3 vDiffuseColor;
|
|
17
|
-
OUT vec3 vSpecularColor;
|
|
18
|
-
OUT vec4 vColor;
|
|
19
|
-
|
|
20
|
-
void main(void) {
|
|
21
|
-
|
|
22
|
-
vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);
|
|
23
|
-
gl_Position = uProjectionMatrix * viewModelPosition;
|
|
24
|
-
|
|
25
|
-
vec3 vertexNormal = normalize(uNormalMatrix * aNormal);
|
|
26
|
-
vVertTexCoord = aTexCoord;
|
|
27
|
-
|
|
28
|
-
totalLight(viewModelPosition.xyz, vertexNormal, vDiffuseColor, vSpecularColor);
|
|
29
|
-
|
|
30
|
-
for (int i = 0; i < 8; i++) {
|
|
31
|
-
if (i < uAmbientLightCount) {
|
|
32
|
-
vDiffuseColor += uAmbientColor[i];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
vColor = ((uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor);
|
|
37
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
uniform vec4 uTint;
|
|
2
|
-
uniform sampler2D uSampler;
|
|
3
|
-
uniform bool isTexture;
|
|
4
|
-
uniform bool uEmissive;
|
|
5
|
-
|
|
6
|
-
IN highp vec2 vVertTexCoord;
|
|
7
|
-
IN vec3 vDiffuseColor;
|
|
8
|
-
IN vec3 vSpecularColor;
|
|
9
|
-
IN vec4 vColor;
|
|
10
|
-
|
|
11
|
-
void main(void) {
|
|
12
|
-
if(uEmissive && !isTexture) {
|
|
13
|
-
OUT_COLOR = vColor;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
vec4 baseColor = isTexture
|
|
17
|
-
// Textures come in with premultiplied alpha. To apply tint and still have
|
|
18
|
-
// premultiplied alpha output, we need to multiply the RGB channels by the
|
|
19
|
-
// tint RGB, and all channels by the tint alpha.
|
|
20
|
-
? TEXTURE(uSampler, vVertTexCoord) * vec4(uTint.rgb/255., 1.) * (uTint.a/255.)
|
|
21
|
-
// Colors come in with unmultiplied alpha, so we need to multiply the RGB
|
|
22
|
-
// channels by alpha to convert it to premultiplied alpha.
|
|
23
|
-
: vec4(vColor.rgb * vColor.a, vColor.a);
|
|
24
|
-
OUT_COLOR = vec4(baseColor.rgb * vDiffuseColor + vSpecularColor, baseColor.a);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
#define PI 3.141592
|
|
2
|
-
|
|
3
|
-
precision highp float;
|
|
4
|
-
precision highp int;
|
|
5
|
-
|
|
6
|
-
uniform mat4 uViewMatrix;
|
|
7
|
-
|
|
8
|
-
uniform bool uUseLighting;
|
|
9
|
-
|
|
10
|
-
uniform int uAmbientLightCount;
|
|
11
|
-
uniform vec3 uAmbientColor[5];
|
|
12
|
-
uniform mat3 uCameraRotation;
|
|
13
|
-
uniform int uDirectionalLightCount;
|
|
14
|
-
uniform vec3 uLightingDirection[5];
|
|
15
|
-
uniform vec3 uDirectionalDiffuseColors[5];
|
|
16
|
-
uniform vec3 uDirectionalSpecularColors[5];
|
|
17
|
-
|
|
18
|
-
uniform int uPointLightCount;
|
|
19
|
-
uniform vec3 uPointLightLocation[5];
|
|
20
|
-
uniform vec3 uPointLightDiffuseColors[5];
|
|
21
|
-
uniform vec3 uPointLightSpecularColors[5];
|
|
22
|
-
|
|
23
|
-
uniform int uSpotLightCount;
|
|
24
|
-
uniform float uSpotLightAngle[5];
|
|
25
|
-
uniform float uSpotLightConc[5];
|
|
26
|
-
uniform vec3 uSpotLightDiffuseColors[5];
|
|
27
|
-
uniform vec3 uSpotLightSpecularColors[5];
|
|
28
|
-
uniform vec3 uSpotLightLocation[5];
|
|
29
|
-
uniform vec3 uSpotLightDirection[5];
|
|
30
|
-
|
|
31
|
-
uniform bool uSpecular;
|
|
32
|
-
uniform float uShininess;
|
|
33
|
-
uniform float uMetallic;
|
|
34
|
-
|
|
35
|
-
uniform float uConstantAttenuation;
|
|
36
|
-
uniform float uLinearAttenuation;
|
|
37
|
-
uniform float uQuadraticAttenuation;
|
|
38
|
-
|
|
39
|
-
// setting from _setImageLightUniforms()
|
|
40
|
-
// boolean to initiate the calculateImageDiffuse and calculateImageSpecular
|
|
41
|
-
uniform bool uUseImageLight;
|
|
42
|
-
// texture for use in calculateImageDiffuse
|
|
43
|
-
uniform sampler2D environmentMapDiffused;
|
|
44
|
-
// texture for use in calculateImageSpecular
|
|
45
|
-
uniform sampler2D environmentMapSpecular;
|
|
46
|
-
|
|
47
|
-
const float specularFactor = 2.0;
|
|
48
|
-
const float diffuseFactor = 0.73;
|
|
49
|
-
|
|
50
|
-
struct LightResult {
|
|
51
|
-
float specular;
|
|
52
|
-
float diffuse;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
float _phongSpecular(
|
|
56
|
-
vec3 lightDirection,
|
|
57
|
-
vec3 viewDirection,
|
|
58
|
-
vec3 surfaceNormal,
|
|
59
|
-
float shininess) {
|
|
60
|
-
|
|
61
|
-
vec3 R = reflect(lightDirection, surfaceNormal);
|
|
62
|
-
return pow(max(0.0, dot(R, viewDirection)), shininess);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
float _lambertDiffuse(vec3 lightDirection, vec3 surfaceNormal) {
|
|
66
|
-
return max(0.0, dot(-lightDirection, surfaceNormal));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
LightResult _light(vec3 viewDirection, vec3 normal, vec3 lightVector, float shininess, float metallic) {
|
|
70
|
-
|
|
71
|
-
vec3 lightDir = normalize(lightVector);
|
|
72
|
-
|
|
73
|
-
//compute our diffuse & specular terms
|
|
74
|
-
LightResult lr;
|
|
75
|
-
float specularIntensity = mix(1.0, 0.4, metallic);
|
|
76
|
-
float diffuseIntensity = mix(1.0, 0.1, metallic);
|
|
77
|
-
if (uSpecular)
|
|
78
|
-
lr.specular = (_phongSpecular(lightDir, viewDirection, normal, shininess)) * specularIntensity;
|
|
79
|
-
lr.diffuse = _lambertDiffuse(lightDir, normal) * diffuseIntensity;
|
|
80
|
-
return lr;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// converts the range of "value" from [min1 to max1] to [min2 to max2]
|
|
84
|
-
float map(float value, float min1, float max1, float min2, float max2) {
|
|
85
|
-
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
vec2 mapTextureToNormal( vec3 v ){
|
|
89
|
-
// x = r sin(phi) cos(theta)
|
|
90
|
-
// y = r cos(phi)
|
|
91
|
-
// z = r sin(phi) sin(theta)
|
|
92
|
-
float phi = acos( v.y );
|
|
93
|
-
// if phi is 0, then there are no x, z components
|
|
94
|
-
float theta = 0.0;
|
|
95
|
-
// else
|
|
96
|
-
theta = acos(v.x / sin(phi));
|
|
97
|
-
float sinTheta = v.z / sin(phi);
|
|
98
|
-
if (sinTheta < 0.0) {
|
|
99
|
-
// Turn it into -theta, but in the 0-2PI range
|
|
100
|
-
theta = 2.0 * PI - theta;
|
|
101
|
-
}
|
|
102
|
-
theta = theta / (2.0 * 3.14159);
|
|
103
|
-
phi = phi / 3.14159 ;
|
|
104
|
-
|
|
105
|
-
vec2 angles = vec2( fract(theta + 0.25), 1.0 - phi );
|
|
106
|
-
return angles;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
vec3 calculateImageDiffuse(vec3 vNormal, vec3 vViewPosition, float metallic){
|
|
111
|
-
// make 2 seperate builds
|
|
112
|
-
vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0); // hardcoded world camera position
|
|
113
|
-
vec3 worldNormal = normalize(vNormal * uCameraRotation);
|
|
114
|
-
vec2 newTexCoor = mapTextureToNormal( worldNormal );
|
|
115
|
-
vec4 texture = TEXTURE( environmentMapDiffused, newTexCoor );
|
|
116
|
-
// this is to make the darker sections more dark
|
|
117
|
-
// png and jpg usually flatten the brightness so it is to reverse that
|
|
118
|
-
return mix(smoothstep(vec3(0.0), vec3(1.0), texture.xyz), vec3(0.0), metallic);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
vec3 calculateImageSpecular(vec3 vNormal, vec3 vViewPosition, float shininess, float metallic){
|
|
122
|
-
vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0);
|
|
123
|
-
vec3 worldNormal = normalize(vNormal);
|
|
124
|
-
vec3 lightDirection = normalize( vViewPosition - worldCameraPosition );
|
|
125
|
-
vec3 R = reflect(lightDirection, worldNormal) * uCameraRotation;
|
|
126
|
-
vec2 newTexCoor = mapTextureToNormal( R );
|
|
127
|
-
#ifdef WEBGL2
|
|
128
|
-
// In p5js the range of shininess is >= 1,
|
|
129
|
-
// Therefore roughness range will be ([0,1]*8)*20 or [0, 160]
|
|
130
|
-
// The factor of 8 is because currently the getSpecularTexture
|
|
131
|
-
// only calculated 8 different levels of roughness
|
|
132
|
-
// The factor of 20 is just to spread up this range so that,
|
|
133
|
-
// [1, max] of shininess is converted to [0,160] of roughness
|
|
134
|
-
float roughness = 20. / shininess;
|
|
135
|
-
vec4 outColor = textureLod(environmentMapSpecular, newTexCoor, roughness * 8.);
|
|
136
|
-
#else
|
|
137
|
-
vec4 outColor = TEXTURE(environmentMapSpecular, newTexCoor);
|
|
138
|
-
#endif
|
|
139
|
-
// this is to make the darker sections more dark
|
|
140
|
-
// png and jpg usually flatten the brightness so it is to reverse that
|
|
141
|
-
return mix(
|
|
142
|
-
pow(outColor.xyz, vec3(10)),
|
|
143
|
-
pow(outColor.xyz, vec3(1.2)),
|
|
144
|
-
metallic
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
void totalLight(
|
|
149
|
-
vec3 modelPosition,
|
|
150
|
-
vec3 normal,
|
|
151
|
-
float shininess,
|
|
152
|
-
float metallic,
|
|
153
|
-
out vec3 totalDiffuse,
|
|
154
|
-
out vec3 totalSpecular
|
|
155
|
-
) {
|
|
156
|
-
|
|
157
|
-
totalSpecular = vec3(0.0);
|
|
158
|
-
|
|
159
|
-
if (!uUseLighting) {
|
|
160
|
-
totalDiffuse = vec3(1.0);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
totalDiffuse = vec3(0.0);
|
|
165
|
-
|
|
166
|
-
vec3 viewDirection = normalize(-modelPosition);
|
|
167
|
-
|
|
168
|
-
for (int j = 0; j < 5; j++) {
|
|
169
|
-
if (j < uDirectionalLightCount) {
|
|
170
|
-
vec3 lightVector = (uViewMatrix * vec4(uLightingDirection[j], 0.0)).xyz;
|
|
171
|
-
vec3 lightColor = uDirectionalDiffuseColors[j];
|
|
172
|
-
vec3 specularColor = uDirectionalSpecularColors[j];
|
|
173
|
-
LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
|
|
174
|
-
totalDiffuse += result.diffuse * lightColor;
|
|
175
|
-
totalSpecular += result.specular * lightColor * specularColor;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (j < uPointLightCount) {
|
|
179
|
-
vec3 lightPosition = (uViewMatrix * vec4(uPointLightLocation[j], 1.0)).xyz;
|
|
180
|
-
vec3 lightVector = modelPosition - lightPosition;
|
|
181
|
-
//calculate attenuation
|
|
182
|
-
float lightDistance = length(lightVector);
|
|
183
|
-
float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);
|
|
184
|
-
vec3 lightColor = lightFalloff * uPointLightDiffuseColors[j];
|
|
185
|
-
vec3 specularColor = lightFalloff * uPointLightSpecularColors[j];
|
|
186
|
-
|
|
187
|
-
LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
|
|
188
|
-
totalDiffuse += result.diffuse * lightColor;
|
|
189
|
-
totalSpecular += result.specular * lightColor * specularColor;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if(j < uSpotLightCount) {
|
|
193
|
-
vec3 lightPosition = (uViewMatrix * vec4(uSpotLightLocation[j], 1.0)).xyz;
|
|
194
|
-
vec3 lightVector = modelPosition - lightPosition;
|
|
195
|
-
|
|
196
|
-
float lightDistance = length(lightVector);
|
|
197
|
-
float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);
|
|
198
|
-
|
|
199
|
-
vec3 lightDirection = (uViewMatrix * vec4(uSpotLightDirection[j], 0.0)).xyz;
|
|
200
|
-
float spotDot = dot(normalize(lightVector), normalize(lightDirection));
|
|
201
|
-
float spotFalloff;
|
|
202
|
-
if(spotDot < uSpotLightAngle[j]) {
|
|
203
|
-
spotFalloff = 0.0;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
spotFalloff = pow(spotDot, uSpotLightConc[j]);
|
|
207
|
-
}
|
|
208
|
-
lightFalloff *= spotFalloff;
|
|
209
|
-
|
|
210
|
-
vec3 lightColor = uSpotLightDiffuseColors[j];
|
|
211
|
-
vec3 specularColor = uSpotLightSpecularColors[j];
|
|
212
|
-
|
|
213
|
-
LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
|
|
214
|
-
|
|
215
|
-
totalDiffuse += result.diffuse * lightColor * lightFalloff;
|
|
216
|
-
totalSpecular += result.specular * lightColor * specularColor * lightFalloff;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if( uUseImageLight ){
|
|
221
|
-
totalDiffuse += calculateImageDiffuse(normal, modelPosition, metallic);
|
|
222
|
-
totalSpecular += calculateImageSpecular(normal, modelPosition, shininess, metallic);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
totalDiffuse *= diffuseFactor;
|
|
226
|
-
totalSpecular *= specularFactor;
|
|
227
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
precision highp int;
|
|
2
|
-
precision highp float;
|
|
3
|
-
|
|
4
|
-
uniform vec4 uMaterialColor;
|
|
5
|
-
uniform int uStrokeCap;
|
|
6
|
-
uniform int uStrokeJoin;
|
|
7
|
-
|
|
8
|
-
IN vec4 vColor;
|
|
9
|
-
IN vec2 vTangent;
|
|
10
|
-
IN vec2 vCenter;
|
|
11
|
-
IN vec2 vPosition;
|
|
12
|
-
IN float vStrokeWeight;
|
|
13
|
-
IN float vMaxDist;
|
|
14
|
-
IN float vCap;
|
|
15
|
-
IN float vJoin;
|
|
16
|
-
|
|
17
|
-
float distSquared(vec2 a, vec2 b) {
|
|
18
|
-
vec2 aToB = b - a;
|
|
19
|
-
return dot(aToB, aToB);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
struct Inputs {
|
|
23
|
-
vec4 color;
|
|
24
|
-
vec2 tangent;
|
|
25
|
-
vec2 center;
|
|
26
|
-
vec2 position;
|
|
27
|
-
float strokeWeight;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
void main() {
|
|
31
|
-
HOOK_beforeFragment();
|
|
32
|
-
|
|
33
|
-
Inputs inputs;
|
|
34
|
-
inputs.color = vColor;
|
|
35
|
-
inputs.tangent = vTangent;
|
|
36
|
-
inputs.center = vCenter;
|
|
37
|
-
inputs.position = vPosition;
|
|
38
|
-
inputs.strokeWeight = vStrokeWeight;
|
|
39
|
-
inputs = HOOK_getPixelInputs(inputs);
|
|
40
|
-
|
|
41
|
-
if (vCap > 0.) {
|
|
42
|
-
if (
|
|
43
|
-
uStrokeCap == STROKE_CAP_ROUND &&
|
|
44
|
-
HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)
|
|
45
|
-
) {
|
|
46
|
-
discard;
|
|
47
|
-
} else if (
|
|
48
|
-
uStrokeCap == STROKE_CAP_SQUARE &&
|
|
49
|
-
HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)
|
|
50
|
-
) {
|
|
51
|
-
discard;
|
|
52
|
-
// Use full area for PROJECT
|
|
53
|
-
} else if (HOOK_shouldDiscard(false)) {
|
|
54
|
-
discard;
|
|
55
|
-
}
|
|
56
|
-
} else if (vJoin > 0.) {
|
|
57
|
-
if (
|
|
58
|
-
uStrokeJoin == STROKE_JOIN_ROUND &&
|
|
59
|
-
HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)
|
|
60
|
-
) {
|
|
61
|
-
discard;
|
|
62
|
-
} else if (uStrokeJoin == STROKE_JOIN_BEVEL) {
|
|
63
|
-
vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);
|
|
64
|
-
if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {
|
|
65
|
-
discard;
|
|
66
|
-
}
|
|
67
|
-
// Use full area for MITER
|
|
68
|
-
} else if (HOOK_shouldDiscard(false)) {
|
|
69
|
-
discard;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a);
|
|
73
|
-
HOOK_afterFragment();
|
|
74
|
-
}
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Part of the Processing project - http://processing.org
|
|
3
|
-
Copyright (c) 2012-15 The Processing Foundation
|
|
4
|
-
Copyright (c) 2004-12 Ben Fry and Casey Reas
|
|
5
|
-
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
|
6
|
-
This library is free software; you can redistribute it and/or
|
|
7
|
-
modify it under the terms of the GNU Lesser General Public
|
|
8
|
-
License as published by the Free Software Foundation, version 2.1.
|
|
9
|
-
This library is distributed in the hope that it will be useful,
|
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12
|
-
Lesser General Public License for more details.
|
|
13
|
-
You should have received a copy of the GNU Lesser General
|
|
14
|
-
Public License along with this library; if not, write to the
|
|
15
|
-
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
16
|
-
Boston, MA 02111-1307 USA
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
#define PROCESSING_LINE_SHADER
|
|
20
|
-
|
|
21
|
-
#define HOOK_DEFINES
|
|
22
|
-
|
|
23
|
-
precision highp int;
|
|
24
|
-
precision highp float;
|
|
25
|
-
|
|
26
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
27
|
-
uniform mat4 uModelMatrix;
|
|
28
|
-
uniform mat4 uViewMatrix;
|
|
29
|
-
#else
|
|
30
|
-
uniform mat4 uModelViewMatrix;
|
|
31
|
-
#endif
|
|
32
|
-
|
|
33
|
-
uniform mat4 uProjectionMatrix;
|
|
34
|
-
uniform float uStrokeWeight;
|
|
35
|
-
|
|
36
|
-
uniform bool uUseLineColor;
|
|
37
|
-
uniform bool uSimpleLines;
|
|
38
|
-
uniform vec4 uMaterialColor;
|
|
39
|
-
|
|
40
|
-
uniform vec4 uViewport;
|
|
41
|
-
uniform int uPerspective;
|
|
42
|
-
uniform int uStrokeJoin;
|
|
43
|
-
|
|
44
|
-
IN vec3 aPosition;
|
|
45
|
-
IN vec3 aTangentIn;
|
|
46
|
-
IN vec3 aTangentOut;
|
|
47
|
-
IN float aSide;
|
|
48
|
-
IN vec4 aVertexColor;
|
|
49
|
-
|
|
50
|
-
OUT vec4 vColor;
|
|
51
|
-
OUT vec2 vTangent;
|
|
52
|
-
OUT vec2 vCenter;
|
|
53
|
-
OUT vec2 vPosition;
|
|
54
|
-
OUT float vMaxDist;
|
|
55
|
-
OUT float vCap;
|
|
56
|
-
OUT float vJoin;
|
|
57
|
-
OUT float vStrokeWeight;
|
|
58
|
-
|
|
59
|
-
vec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {
|
|
60
|
-
// Rotate and translate so a starts at the origin and goes out to the right
|
|
61
|
-
bPoint -= aPoint;
|
|
62
|
-
vec2 rotatedBFrom = vec2(
|
|
63
|
-
bPoint.x*aDir.x + bPoint.y*aDir.y,
|
|
64
|
-
bPoint.y*aDir.x - bPoint.x*aDir.y
|
|
65
|
-
);
|
|
66
|
-
vec2 bTo = bPoint + bDir;
|
|
67
|
-
vec2 rotatedBTo = vec2(
|
|
68
|
-
bTo.x*aDir.x + bTo.y*aDir.y,
|
|
69
|
-
bTo.y*aDir.x - bTo.x*aDir.y
|
|
70
|
-
);
|
|
71
|
-
float intersectionDistance =
|
|
72
|
-
rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /
|
|
73
|
-
(rotatedBTo.y - rotatedBFrom.y);
|
|
74
|
-
return aPoint + aDir * intersectionDistance;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
struct StrokeVertex {
|
|
78
|
-
vec3 position;
|
|
79
|
-
vec3 tangentIn;
|
|
80
|
-
vec3 tangentOut;
|
|
81
|
-
vec4 color;
|
|
82
|
-
float weight;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
void main() {
|
|
86
|
-
HOOK_beforeVertex();
|
|
87
|
-
|
|
88
|
-
if (!uSimpleLines) {
|
|
89
|
-
// Caps have one of either the in or out tangent set to 0
|
|
90
|
-
vCap = (aTangentIn == vec3(0.)) != (aTangentOut == vec3(0.)) ? 1. : 0.;
|
|
91
|
-
|
|
92
|
-
// Joins have two unique, defined tangents
|
|
93
|
-
vJoin = (
|
|
94
|
-
aTangentIn != vec3(0.) &&
|
|
95
|
-
aTangentOut != vec3(0.) &&
|
|
96
|
-
aTangentIn != aTangentOut
|
|
97
|
-
) ? 1. : 0.;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
StrokeVertex inputs;
|
|
101
|
-
inputs.position = aPosition.xyz;
|
|
102
|
-
inputs.color = uUseLineColor ? aVertexColor : uMaterialColor;
|
|
103
|
-
inputs.weight = uStrokeWeight;
|
|
104
|
-
inputs.tangentIn = aTangentIn;
|
|
105
|
-
inputs.tangentOut = aTangentOut;
|
|
106
|
-
|
|
107
|
-
#ifdef AUGMENTED_HOOK_getObjectInputs
|
|
108
|
-
inputs = HOOK_getObjectInputs(inputs);
|
|
109
|
-
#endif
|
|
110
|
-
|
|
111
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
112
|
-
inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
|
|
113
|
-
inputs.tangentIn = (uModelMatrix * vec4(aTangentIn, 0.)).xyz;
|
|
114
|
-
inputs.tangentOut = (uModelMatrix * vec4(aTangentOut, 0.)).xyz;
|
|
115
|
-
inputs = HOOK_getWorldInputs(inputs);
|
|
116
|
-
#endif
|
|
117
|
-
|
|
118
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
119
|
-
// Already multiplied by the model matrix, just apply view
|
|
120
|
-
inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
121
|
-
inputs.tangentIn = (uViewMatrix * vec4(aTangentIn, 0.)).xyz;
|
|
122
|
-
inputs.tangentOut = (uViewMatrix * vec4(aTangentOut, 0.)).xyz;
|
|
123
|
-
#else
|
|
124
|
-
// Apply both at once
|
|
125
|
-
inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
126
|
-
inputs.tangentIn = (uModelViewMatrix * vec4(aTangentIn, 0.)).xyz;
|
|
127
|
-
inputs.tangentOut = (uModelViewMatrix * vec4(aTangentOut, 0.)).xyz;
|
|
128
|
-
#endif
|
|
129
|
-
#ifdef AUGMENTED_HOOK_getCameraInputs
|
|
130
|
-
inputs = hook_getCameraInputs(inputs);
|
|
131
|
-
#endif
|
|
132
|
-
|
|
133
|
-
vec4 posp = vec4(inputs.position, 1.);
|
|
134
|
-
vec4 posqIn = vec4(inputs.position + inputs.tangentIn, 1.);
|
|
135
|
-
vec4 posqOut = vec4(inputs.position + inputs.tangentOut, 1.);
|
|
136
|
-
vStrokeWeight = inputs.weight;
|
|
137
|
-
|
|
138
|
-
float facingCamera = pow(
|
|
139
|
-
// The word space tangent's z value is 0 if it's facing the camera
|
|
140
|
-
abs(normalize(posqIn-posp).z),
|
|
141
|
-
|
|
142
|
-
// Using pow() here to ramp `facingCamera` up from 0 to 1 really quickly
|
|
143
|
-
// so most lines get scaled and don't get clipped
|
|
144
|
-
0.25
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// Moving vertices slightly toward the camera
|
|
148
|
-
// to avoid depth-fighting with the fill triangles.
|
|
149
|
-
// A mix of scaling and offsetting is used based on distance
|
|
150
|
-
// Discussion here:
|
|
151
|
-
// https://github.com/processing/p5.js/issues/7200
|
|
152
|
-
|
|
153
|
-
// using a scale <1 moves the lines towards nearby camera
|
|
154
|
-
// in order to prevent popping effects due to half of
|
|
155
|
-
// the line disappearing behind the geometry faces.
|
|
156
|
-
float zDistance = -posp.z;
|
|
157
|
-
float distanceFactor = smoothstep(0.0, 800.0, zDistance);
|
|
158
|
-
|
|
159
|
-
// Discussed here:
|
|
160
|
-
// http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848
|
|
161
|
-
float scale = mix(1., 0.995, facingCamera);
|
|
162
|
-
float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less
|
|
163
|
-
|
|
164
|
-
posp.xyz = posp.xyz * dynamicScale;
|
|
165
|
-
posqIn.xyz = posqIn.xyz * dynamicScale;
|
|
166
|
-
posqOut.xyz = posqOut.xyz * dynamicScale;
|
|
167
|
-
|
|
168
|
-
// Moving vertices slightly toward camera when far away
|
|
169
|
-
// https://github.com/processing/p5.js/issues/6956
|
|
170
|
-
float zOffset = mix(0., -1., facingCamera);
|
|
171
|
-
float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more
|
|
172
|
-
|
|
173
|
-
posp.z -= dynamicZAdjustment;
|
|
174
|
-
posqIn.z -= dynamicZAdjustment;
|
|
175
|
-
posqOut.z -= dynamicZAdjustment;
|
|
176
|
-
|
|
177
|
-
vec4 p = uProjectionMatrix * posp;
|
|
178
|
-
vec4 qIn = uProjectionMatrix * posqIn;
|
|
179
|
-
vec4 qOut = uProjectionMatrix * posqOut;
|
|
180
|
-
|
|
181
|
-
// formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
|
|
182
|
-
// screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw
|
|
183
|
-
|
|
184
|
-
// prevent division by W by transforming the tangent formula (div by 0 causes
|
|
185
|
-
// the line to disappear, see https://github.com/processing/processing/issues/5183)
|
|
186
|
-
// t = screen_q - screen_p
|
|
187
|
-
//
|
|
188
|
-
// tangent is normalized and we don't care which aDirection it points to (+-)
|
|
189
|
-
// t = +- normalize( screen_q - screen_p )
|
|
190
|
-
// t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )
|
|
191
|
-
//
|
|
192
|
-
// extract common factor, <1,1> - <1,1> cancels out
|
|
193
|
-
// t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )
|
|
194
|
-
//
|
|
195
|
-
// convert to common divisor
|
|
196
|
-
// t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )
|
|
197
|
-
//
|
|
198
|
-
// remove the common scalar divisor/factor, not needed due to normalize and +-
|
|
199
|
-
// (keep uViewport - can't remove because it has different components for x and y
|
|
200
|
-
// and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)
|
|
201
|
-
// t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )
|
|
202
|
-
|
|
203
|
-
vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);
|
|
204
|
-
vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);
|
|
205
|
-
|
|
206
|
-
vec2 curPerspScale;
|
|
207
|
-
if(uPerspective == 1) {
|
|
208
|
-
// Perspective ---
|
|
209
|
-
// convert from world to clip by multiplying with projection scaling factor
|
|
210
|
-
// to get the right thickness (see https://github.com/processing/processing/issues/5182)
|
|
211
|
-
|
|
212
|
-
// The y value of the projection matrix may be flipped if rendering to a Framebuffer.
|
|
213
|
-
// Multiplying again by its sign here negates the flip to get just the scale.
|
|
214
|
-
curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;
|
|
215
|
-
} else {
|
|
216
|
-
// No Perspective ---
|
|
217
|
-
// multiply by W (to cancel out division by W later in the pipeline) and
|
|
218
|
-
// convert from screen to clip (derived from clip to screen above)
|
|
219
|
-
curPerspScale = p.w / (0.5 * uViewport.zw);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
vec2 offset;
|
|
223
|
-
if (vJoin == 1. && !uSimpleLines) {
|
|
224
|
-
vTangent = normalize(tangentIn + tangentOut);
|
|
225
|
-
vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);
|
|
226
|
-
vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);
|
|
227
|
-
float side = sign(aSide);
|
|
228
|
-
float sideEnum = abs(aSide);
|
|
229
|
-
|
|
230
|
-
// We generate vertices for joins on either side of the centerline, but
|
|
231
|
-
// the "elbow" side is the only one needing a join. By not setting the
|
|
232
|
-
// offset for the other side, all its vertices will end up in the same
|
|
233
|
-
// spot and not render, effectively discarding it.
|
|
234
|
-
if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {
|
|
235
|
-
// Side enums:
|
|
236
|
-
// 1: the side going into the join
|
|
237
|
-
// 2: the middle of the join
|
|
238
|
-
// 3: the side going out of the join
|
|
239
|
-
if (sideEnum == 2.) {
|
|
240
|
-
// Calculate the position + tangent on either side of the join, and
|
|
241
|
-
// find where the lines intersect to find the elbow of the join
|
|
242
|
-
vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;
|
|
243
|
-
vec2 intersection = lineIntersection(
|
|
244
|
-
c + (side * normalIn * inputs.weight / 2.),
|
|
245
|
-
tangentIn,
|
|
246
|
-
c + (side * normalOut * inputs.weight / 2.),
|
|
247
|
-
tangentOut
|
|
248
|
-
);
|
|
249
|
-
offset = (intersection - c);
|
|
250
|
-
|
|
251
|
-
// When lines are thick and the angle of the join approaches 180, the
|
|
252
|
-
// elbow might be really far from the center. We'll apply a limit to
|
|
253
|
-
// the magnitude to avoid lines going across the whole screen when this
|
|
254
|
-
// happens.
|
|
255
|
-
float mag = length(offset);
|
|
256
|
-
float maxMag = 3. * inputs.weight;
|
|
257
|
-
if (mag > maxMag) {
|
|
258
|
-
offset *= maxMag / mag;
|
|
259
|
-
}
|
|
260
|
-
} else if (sideEnum == 1.) {
|
|
261
|
-
offset = side * normalIn * inputs.weight / 2.;
|
|
262
|
-
} else if (sideEnum == 3.) {
|
|
263
|
-
offset = side * normalOut * inputs.weight / 2.;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (uStrokeJoin == STROKE_JOIN_BEVEL) {
|
|
267
|
-
vec2 avgNormal = vec2(-vTangent.y, vTangent.x);
|
|
268
|
-
vMaxDist = abs(dot(avgNormal, normalIn * inputs.weight / 2.));
|
|
269
|
-
} else {
|
|
270
|
-
vMaxDist = inputs.weight / 2.;
|
|
271
|
-
}
|
|
272
|
-
} else {
|
|
273
|
-
vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;
|
|
274
|
-
vTangent = tangent;
|
|
275
|
-
vec2 normal = vec2(-tangent.y, tangent.x);
|
|
276
|
-
|
|
277
|
-
float normalOffset = sign(aSide);
|
|
278
|
-
// Caps will have side values of -2 or 2 on the edge of the cap that
|
|
279
|
-
// extends out from the line
|
|
280
|
-
float tangentOffset = abs(aSide) - 1.;
|
|
281
|
-
offset = (normal * normalOffset + tangent * tangentOffset) *
|
|
282
|
-
inputs.weight * 0.5;
|
|
283
|
-
vMaxDist = inputs.weight / 2.;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
vCenter = p.xy;
|
|
287
|
-
vPosition = vCenter + offset;
|
|
288
|
-
vColor = inputs.color;
|
|
289
|
-
|
|
290
|
-
gl_Position.xy = p.xy + offset.xy * curPerspScale;
|
|
291
|
-
gl_Position.zw = p.zw;
|
|
292
|
-
|
|
293
|
-
HOOK_afterVertex();
|
|
294
|
-
}
|