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,72 +0,0 @@
|
|
|
1
|
-
IN vec3 aPosition;
|
|
2
|
-
IN vec3 aNormal;
|
|
3
|
-
IN vec2 aTexCoord;
|
|
4
|
-
IN vec4 aVertexColor;
|
|
5
|
-
|
|
6
|
-
#define HOOK_DEFINES
|
|
7
|
-
|
|
8
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
9
|
-
uniform mat4 uModelMatrix;
|
|
10
|
-
uniform mat4 uViewMatrix;
|
|
11
|
-
uniform mat3 uModelNormalMatrix;
|
|
12
|
-
uniform mat3 uCameraNormalMatrix;
|
|
13
|
-
#else
|
|
14
|
-
uniform mat4 uModelViewMatrix;
|
|
15
|
-
uniform mat3 uNormalMatrix;
|
|
16
|
-
#endif
|
|
17
|
-
uniform mat4 uProjectionMatrix;
|
|
18
|
-
|
|
19
|
-
uniform vec4 uMaterialColor;
|
|
20
|
-
uniform bool uUseVertexColor;
|
|
21
|
-
|
|
22
|
-
OUT vec3 vVertexNormal;
|
|
23
|
-
OUT highp vec2 vVertTexCoord;
|
|
24
|
-
OUT vec4 vColor;
|
|
25
|
-
|
|
26
|
-
struct Vertex {
|
|
27
|
-
vec3 position;
|
|
28
|
-
vec3 normal;
|
|
29
|
-
vec2 texCoord;
|
|
30
|
-
vec4 color;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
void main(void) {
|
|
34
|
-
HOOK_beforeVertex();
|
|
35
|
-
|
|
36
|
-
Vertex inputs;
|
|
37
|
-
inputs.position = aPosition;
|
|
38
|
-
inputs.normal = aNormal;
|
|
39
|
-
inputs.texCoord = aTexCoord;
|
|
40
|
-
inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;
|
|
41
|
-
#ifdef AUGMENTED_HOOK_getObjectInputs
|
|
42
|
-
inputs = HOOK_getObjectInputs(inputs);
|
|
43
|
-
#endif
|
|
44
|
-
|
|
45
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
46
|
-
inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
|
|
47
|
-
inputs.normal = uModelNormalMatrix * inputs.normal;
|
|
48
|
-
inputs = HOOK_getWorldInputs(inputs);
|
|
49
|
-
#endif
|
|
50
|
-
|
|
51
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
52
|
-
// Already multiplied by the model matrix, just apply view
|
|
53
|
-
inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
54
|
-
inputs.normal = uCameraNormalMatrix * inputs.normal;
|
|
55
|
-
#else
|
|
56
|
-
// Apply both at once
|
|
57
|
-
inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
58
|
-
inputs.normal = uNormalMatrix * inputs.normal;
|
|
59
|
-
#endif
|
|
60
|
-
#ifdef AUGMENTED_HOOK_getCameraInputs
|
|
61
|
-
inputs = HOOK_getCameraInputs(inputs);
|
|
62
|
-
#endif
|
|
63
|
-
|
|
64
|
-
// Pass varyings to fragment shader
|
|
65
|
-
vVertTexCoord = inputs.texCoord;
|
|
66
|
-
vVertexNormal = normalize(inputs.normal);
|
|
67
|
-
vColor = inputs.color;
|
|
68
|
-
|
|
69
|
-
gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);
|
|
70
|
-
|
|
71
|
-
HOOK_afterVertex();
|
|
72
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// include lighting.glsl
|
|
2
|
-
precision highp int;
|
|
3
|
-
|
|
4
|
-
uniform bool uHasSetAmbient;
|
|
5
|
-
uniform vec4 uSpecularMatColor;
|
|
6
|
-
uniform vec4 uAmbientMatColor;
|
|
7
|
-
uniform vec4 uEmissiveMatColor;
|
|
8
|
-
|
|
9
|
-
uniform vec4 uTint;
|
|
10
|
-
uniform sampler2D uSampler;
|
|
11
|
-
uniform bool isTexture;
|
|
12
|
-
|
|
13
|
-
IN vec3 vNormal;
|
|
14
|
-
IN vec2 vTexCoord;
|
|
15
|
-
IN vec3 vViewPosition;
|
|
16
|
-
IN vec3 vAmbientColor;
|
|
17
|
-
IN vec4 vColor;
|
|
18
|
-
|
|
19
|
-
struct ColorComponents {
|
|
20
|
-
vec3 baseColor;
|
|
21
|
-
float opacity;
|
|
22
|
-
vec3 ambientColor;
|
|
23
|
-
vec3 specularColor;
|
|
24
|
-
vec3 diffuse;
|
|
25
|
-
vec3 ambient;
|
|
26
|
-
vec3 specular;
|
|
27
|
-
vec3 emissive;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
struct Inputs {
|
|
31
|
-
vec3 normal;
|
|
32
|
-
vec2 texCoord;
|
|
33
|
-
vec3 ambientLight;
|
|
34
|
-
vec3 ambientMaterial;
|
|
35
|
-
vec3 specularMaterial;
|
|
36
|
-
vec3 emissiveMaterial;
|
|
37
|
-
vec4 color;
|
|
38
|
-
float shininess;
|
|
39
|
-
float metalness;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
void main(void) {
|
|
43
|
-
HOOK_beforeFragment();
|
|
44
|
-
|
|
45
|
-
Inputs inputs;
|
|
46
|
-
inputs.normal = normalize(vNormal);
|
|
47
|
-
inputs.texCoord = vTexCoord;
|
|
48
|
-
inputs.ambientLight = vAmbientColor;
|
|
49
|
-
inputs.color = isTexture
|
|
50
|
-
? TEXTURE(uSampler, vTexCoord) * uTint/255.
|
|
51
|
-
: vColor;
|
|
52
|
-
if (isTexture && inputs.color.a > 0.0) {
|
|
53
|
-
// Textures come in with premultiplied alpha. Temporarily unpremultiply it
|
|
54
|
-
// so hooks users don't have to think about premultiplied alpha.
|
|
55
|
-
inputs.color.rgb /= inputs.color.a;
|
|
56
|
-
}
|
|
57
|
-
inputs.shininess = uShininess;
|
|
58
|
-
inputs.metalness = uMetallic;
|
|
59
|
-
inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;
|
|
60
|
-
inputs.specularMaterial = uSpecularMatColor.rgb;
|
|
61
|
-
inputs.emissiveMaterial = uEmissiveMatColor.rgb;
|
|
62
|
-
inputs = HOOK_getPixelInputs(inputs);
|
|
63
|
-
|
|
64
|
-
vec3 diffuse;
|
|
65
|
-
vec3 specular;
|
|
66
|
-
totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);
|
|
67
|
-
|
|
68
|
-
// Calculating final color as result of all lights (plus emissive term).
|
|
69
|
-
|
|
70
|
-
vec2 texCoord = inputs.texCoord;
|
|
71
|
-
vec4 baseColor = inputs.color;
|
|
72
|
-
ColorComponents c;
|
|
73
|
-
c.opacity = baseColor.a;
|
|
74
|
-
c.baseColor = baseColor.rgb;
|
|
75
|
-
c.ambientColor = inputs.ambientMaterial;
|
|
76
|
-
c.specularColor = inputs.specularMaterial;
|
|
77
|
-
c.diffuse = diffuse;
|
|
78
|
-
c.ambient = inputs.ambientLight;
|
|
79
|
-
c.specular = specular;
|
|
80
|
-
c.emissive = inputs.emissiveMaterial;
|
|
81
|
-
OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c));
|
|
82
|
-
OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering
|
|
83
|
-
HOOK_afterFragment();
|
|
84
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
precision highp int;
|
|
2
|
-
|
|
3
|
-
#define HOOK_DEFINES
|
|
4
|
-
|
|
5
|
-
IN vec3 aPosition;
|
|
6
|
-
IN vec3 aNormal;
|
|
7
|
-
IN vec2 aTexCoord;
|
|
8
|
-
IN vec4 aVertexColor;
|
|
9
|
-
|
|
10
|
-
uniform vec3 uAmbientColor[5];
|
|
11
|
-
|
|
12
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
13
|
-
uniform mat4 uModelMatrix;
|
|
14
|
-
uniform mat4 uViewMatrix;
|
|
15
|
-
uniform mat3 uModelNormalMatrix;
|
|
16
|
-
uniform mat3 uCameraNormalMatrix;
|
|
17
|
-
#else
|
|
18
|
-
uniform mat4 uModelViewMatrix;
|
|
19
|
-
uniform mat3 uNormalMatrix;
|
|
20
|
-
#endif
|
|
21
|
-
uniform mat4 uProjectionMatrix;
|
|
22
|
-
uniform int uAmbientLightCount;
|
|
23
|
-
|
|
24
|
-
uniform bool uUseVertexColor;
|
|
25
|
-
uniform vec4 uMaterialColor;
|
|
26
|
-
|
|
27
|
-
OUT vec3 vNormal;
|
|
28
|
-
OUT vec2 vTexCoord;
|
|
29
|
-
OUT vec3 vViewPosition;
|
|
30
|
-
OUT vec3 vAmbientColor;
|
|
31
|
-
OUT vec4 vColor;
|
|
32
|
-
|
|
33
|
-
struct Vertex {
|
|
34
|
-
vec3 position;
|
|
35
|
-
vec3 normal;
|
|
36
|
-
vec2 texCoord;
|
|
37
|
-
vec4 color;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
void main(void) {
|
|
41
|
-
HOOK_beforeVertex();
|
|
42
|
-
|
|
43
|
-
Vertex inputs;
|
|
44
|
-
inputs.position = aPosition;
|
|
45
|
-
inputs.normal = aNormal;
|
|
46
|
-
inputs.texCoord = aTexCoord;
|
|
47
|
-
inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;
|
|
48
|
-
#ifdef AUGMENTED_HOOK_getObjectInputs
|
|
49
|
-
inputs = HOOK_getObjectInputs(inputs);
|
|
50
|
-
#endif
|
|
51
|
-
|
|
52
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
53
|
-
inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
|
|
54
|
-
inputs.normal = uModelNormalMatrix * inputs.normal;
|
|
55
|
-
inputs = HOOK_getWorldInputs(inputs);
|
|
56
|
-
#endif
|
|
57
|
-
|
|
58
|
-
#ifdef AUGMENTED_HOOK_getWorldInputs
|
|
59
|
-
// Already multiplied by the model matrix, just apply view
|
|
60
|
-
inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
61
|
-
inputs.normal = uCameraNormalMatrix * inputs.normal;
|
|
62
|
-
#else
|
|
63
|
-
// Apply both at once
|
|
64
|
-
inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
|
|
65
|
-
inputs.normal = uNormalMatrix * inputs.normal;
|
|
66
|
-
#endif
|
|
67
|
-
#ifdef AUGMENTED_HOOK_getCameraInputs
|
|
68
|
-
inputs = HOOK_getCameraInputs(inputs);
|
|
69
|
-
#endif
|
|
70
|
-
|
|
71
|
-
// Pass varyings to fragment shader
|
|
72
|
-
vViewPosition = inputs.position;
|
|
73
|
-
vTexCoord = inputs.texCoord;
|
|
74
|
-
vNormal = inputs.normal;
|
|
75
|
-
vColor = inputs.color;
|
|
76
|
-
|
|
77
|
-
// TODO: this should be a uniform
|
|
78
|
-
vAmbientColor = vec3(0.0);
|
|
79
|
-
for (int i = 0; i < 5; i++) {
|
|
80
|
-
if (i < uAmbientLightCount) {
|
|
81
|
-
vAmbientColor += uAmbientColor[i];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);
|
|
86
|
-
HOOK_afterVertex();
|
|
87
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
precision mediump int;
|
|
2
|
-
uniform vec4 uMaterialColor;
|
|
3
|
-
IN float vStrokeWeight;
|
|
4
|
-
|
|
5
|
-
void main(){
|
|
6
|
-
HOOK_beforeFragment();
|
|
7
|
-
float mask = 0.0;
|
|
8
|
-
|
|
9
|
-
// make a circular mask using the gl_PointCoord (goes from 0 - 1 on a point)
|
|
10
|
-
// might be able to get a nicer edge on big strokeweights with smoothstep but slightly less performant
|
|
11
|
-
|
|
12
|
-
mask = step(0.98, length(gl_PointCoord * 2.0 - 1.0));
|
|
13
|
-
|
|
14
|
-
// if strokeWeight is 1 or less lets just draw a square
|
|
15
|
-
// this prevents weird artifacting from carving circles when our points are really small
|
|
16
|
-
// if strokeWeight is larger than 1, we just use it as is
|
|
17
|
-
|
|
18
|
-
mask = mix(0.0, mask, clamp(floor(vStrokeWeight - 0.5),0.0,1.0));
|
|
19
|
-
|
|
20
|
-
// throw away the borders of the mask
|
|
21
|
-
// otherwise we get weird alpha blending issues
|
|
22
|
-
|
|
23
|
-
if(HOOK_shouldDiscard(mask > 0.98)){
|
|
24
|
-
discard;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
OUT_COLOR = HOOK_getFinalColor(vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a);
|
|
28
|
-
HOOK_afterFragment();
|
|
29
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
IN vec3 aPosition;
|
|
2
|
-
uniform float uPointSize;
|
|
3
|
-
OUT float vStrokeWeight;
|
|
4
|
-
uniform mat4 uModelViewMatrix;
|
|
5
|
-
uniform mat4 uProjectionMatrix;
|
|
6
|
-
|
|
7
|
-
void main() {
|
|
8
|
-
HOOK_beforeVertex();
|
|
9
|
-
vec4 viewModelPosition = vec4(HOOK_getWorldPosition(
|
|
10
|
-
(uModelViewMatrix * vec4(HOOK_getLocalPosition(aPosition), 1.0)).xyz
|
|
11
|
-
), 1.);
|
|
12
|
-
gl_Position = uProjectionMatrix * viewModelPosition;
|
|
13
|
-
|
|
14
|
-
float pointSize = HOOK_getPointSize(uPointSize);
|
|
15
|
-
|
|
16
|
-
gl_PointSize = pointSize;
|
|
17
|
-
vStrokeWeight = pointSize;
|
|
18
|
-
HOOK_afterVertex();
|
|
19
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#define PI 3.141592
|
|
2
|
-
|
|
3
|
-
precision highp float;
|
|
4
|
-
|
|
5
|
-
uniform sampler2D uEnvMap;
|
|
6
|
-
uniform mat3 uNewNormalMatrix;
|
|
7
|
-
uniform float uFovY;
|
|
8
|
-
uniform float uAspect;
|
|
9
|
-
|
|
10
|
-
varying vec2 vTexCoord;
|
|
11
|
-
|
|
12
|
-
void main() {
|
|
13
|
-
float uFovX = uFovY * uAspect;
|
|
14
|
-
float angleY = mix(uFovY/2.0, -uFovY/2.0, vTexCoord.y);
|
|
15
|
-
float angleX = mix(uFovX/2.0, -uFovX/2.0, vTexCoord.x);
|
|
16
|
-
vec3 rotatedNormal = vec3( angleX, angleY, 1.0 );
|
|
17
|
-
rotatedNormal = uNewNormalMatrix * normalize(rotatedNormal);
|
|
18
|
-
float temp = rotatedNormal.z;
|
|
19
|
-
rotatedNormal.z = rotatedNormal.x;
|
|
20
|
-
rotatedNormal.x = -temp;
|
|
21
|
-
vec2 suv;
|
|
22
|
-
suv.y = 0.5 + 0.5 * (-rotatedNormal.y);
|
|
23
|
-
suv.x = atan(rotatedNormal.z, rotatedNormal.x) / (2.0 * PI) + 0.5;
|
|
24
|
-
vec4 newTexColor = texture2D(uEnvMap, suv.xy);
|
|
25
|
-
gl_FragColor = newTexColor;
|
|
26
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#ifdef WEBGL2
|
|
2
|
-
|
|
3
|
-
#define IN in
|
|
4
|
-
#define OUT out
|
|
5
|
-
|
|
6
|
-
#ifdef FRAGMENT_SHADER
|
|
7
|
-
out vec4 outColor;
|
|
8
|
-
#define OUT_COLOR outColor
|
|
9
|
-
#endif
|
|
10
|
-
#define TEXTURE texture
|
|
11
|
-
|
|
12
|
-
#else
|
|
13
|
-
|
|
14
|
-
#ifdef FRAGMENT_SHADER
|
|
15
|
-
#define IN varying
|
|
16
|
-
#else
|
|
17
|
-
#define IN attribute
|
|
18
|
-
#endif
|
|
19
|
-
#define OUT varying
|
|
20
|
-
#define TEXTURE texture2D
|
|
21
|
-
|
|
22
|
-
#ifdef FRAGMENT_SHADER
|
|
23
|
-
#define OUT_COLOR gl_FragColor
|
|
24
|
-
#endif
|
|
25
|
-
|
|
26
|
-
#endif
|
|
27
|
-
|
|
28
|
-
#ifdef FRAGMENT_SHADER
|
|
29
|
-
vec4 getTexture(in sampler2D content, vec2 coord) {
|
|
30
|
-
vec4 color = TEXTURE(content, coord);
|
|
31
|
-
color.rgb /= color.a;
|
|
32
|
-
return color;
|
|
33
|
-
}
|
|
34
|
-
#endif
|