@blakron/core 0.5.5 → 0.5.6
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.
|
@@ -8,10 +8,10 @@ export declare const ShaderLib2: {
|
|
|
8
8
|
readonly multi_frag: "#version 300 es\nprecision lowp float;\nin vec2 vTextureCoord;\nin vec4 vColor;\nin float vTextureId;\nuniform sampler2D uSamplers[8];\nout vec4 fragColor;\nvoid main(void) {\n vec4 color;\n int id = int(vTextureId + 0.5);\n if (id == 0) color = texture(uSamplers[0], vTextureCoord);\n else if (id == 1) color = texture(uSamplers[1], vTextureCoord);\n else if (id == 2) color = texture(uSamplers[2], vTextureCoord);\n else if (id == 3) color = texture(uSamplers[3], vTextureCoord);\n else if (id == 4) color = texture(uSamplers[4], vTextureCoord);\n else if (id == 5) color = texture(uSamplers[5], vTextureCoord);\n else if (id == 6) color = texture(uSamplers[6], vTextureCoord);\n else color = texture(uSamplers[7], vTextureCoord);\n fragColor = color * vColor;\n}";
|
|
9
9
|
readonly texture_frag: "#version 300 es\nprecision lowp float;\nin vec2 vTextureCoord;\nin vec4 vColor;\nuniform sampler2D uSampler;\nout vec4 fragColor;\nvoid main(void) {\n fragColor = texture(uSampler, vTextureCoord) * vColor;\n}";
|
|
10
10
|
readonly primitive_frag: "#version 300 es\nprecision lowp float;\nin vec2 vTextureCoord;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\n fragColor = vColor;\n}";
|
|
11
|
-
readonly blur_frag: "#version 300 es\nprecision mediump float;\nuniform vec2 blur;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nout vec4 fragColor;\nvoid main() {\n const int sampleRadius = 5;\n const int samples = sampleRadius * 2 + 1;\n vec2 blurUv = blur / uTextureSize;\n vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n vec2 uv = vec2(0.0, 0.0);\n blurUv /= float(sampleRadius);\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\n color += texture(uSampler, uv);\n }\n color /= float(samples);\n fragColor = color;\n}";
|
|
12
|
-
readonly blur_h_frag: "#version 300 es\nprecision mediump float;\nuniform float blurX;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nout vec4 fragColor;\nvoid main() {\n float step = 1.0 / uTextureSize.x;\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (int i = -8; i <= 8; i++) {\n if (abs(float(i)) > blurX) continue;\n float weight = 1.0 - abs(float(i)) / (blurX + 1.0);\n color += texture(uSampler, vTextureCoord + vec2(float(i) * step, 0.0)) * weight;\n total += weight;\n }\n fragColor = color / total;\n}";
|
|
13
|
-
readonly blur_v_frag: "#version 300 es\nprecision mediump float;\nuniform float blurY;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nout vec4 fragColor;\nvoid main() {\n float step = 1.0 / uTextureSize.y;\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (int i = -8; i <= 8; i++) {\n if (abs(float(i)) > blurY) continue;\n float weight = 1.0 - abs(float(i)) / (blurY + 1.0);\n color += texture(uSampler, vTextureCoord + vec2(0.0, float(i) * step)) * weight;\n total += weight;\n }\n fragColor = color / total;\n}";
|
|
14
|
-
readonly glow_frag: "#version 300 es\nprecision highp float;\nin vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float dist;\nuniform float angle;\nuniform vec4 color;\nuniform float alpha;\nuniform float blurX;\nuniform float blurY;\nuniform float strength;\nuniform float inner;\nuniform float knockout;\nuniform float hideObject;\nout vec4 fragColor;\nfloat random(vec2 scale) {\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\n}\nvoid main(void) {\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\n const float linearSamplingTimes = 7.0;\n const float circleSamplingTimes = 12.0;\n vec4 ownColor = texture(uSampler, vTextureCoord);\n vec4 curColor;\n float totalAlpha = 0.0;\n float maxTotalAlpha = 0.0;\n float offsetX = dist * cos(angle) * px.x;\n float offsetY = dist * sin(angle) * px.y;\n const float PI = 3.14159265358979323846264;\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\n float stepX = blurX * px.x / linearSamplingTimes;\n float stepY = blurY * px.y / linearSamplingTimes;\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\n float cosAngle = cos(a + offset);\n float sinAngle = sin(a + offset);\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\n float curDistanceX = i * stepX * cosAngle;\n float curDistanceY = i * stepY * sinAngle;\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0) {\n curColor = texture(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\n }\n maxTotalAlpha += (linearSamplingTimes - i);\n }\n }\n ownColor.a = max(ownColor.a, 0.0001);\n ownColor.rgb = ownColor.rgb / ownColor.a;\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1.0 - inner) * max(min(hideObject, knockout), 1.0 - ownColor.a);\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\n ownColor.a = max(ownColor.a * knockout * (1.0 - hideObject), 0.0001);\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.0);\n fragColor = vec4(mix2 * resultAlpha, resultAlpha);\n}";
|
|
11
|
+
readonly blur_frag: "#version 300 es\nprecision mediump float;\nuniform vec2 blur;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nuniform vec2 uTextureSize;\nout vec4 fragColor;\nvoid main() {\n const int sampleRadius = 5;\n const int samples = sampleRadius * 2 + 1;\n vec2 blurUv = blur / uTextureSize;\n vec4 color = vec4(0.0, 0.0, 0.0, 0.0);\n vec2 uv = vec2(0.0, 0.0);\n blurUv /= float(sampleRadius);\n for (int i = -sampleRadius; i <= sampleRadius; i++) {\n uv.x = vTextureCoord.x + float(i) * blurUv.x;\n uv.y = vTextureCoord.y + float(i) * blurUv.y;\n color += texture(uSampler, uv);\n }\n color /= float(samples);\n fragColor = color;\n}";
|
|
12
|
+
readonly blur_h_frag: "#version 300 es\nprecision mediump float;\nuniform float blurX;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nuniform vec2 uTextureSize;\nout vec4 fragColor;\nvoid main() {\n float step = 1.0 / uTextureSize.x;\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (int i = -8; i <= 8; i++) {\n if (abs(float(i)) > blurX) continue;\n float weight = 1.0 - abs(float(i)) / (blurX + 1.0);\n color += texture(uSampler, vTextureCoord + vec2(float(i) * step, 0.0)) * weight;\n total += weight;\n }\n fragColor = color / total;\n}";
|
|
13
|
+
readonly blur_v_frag: "#version 300 es\nprecision mediump float;\nuniform float blurY;\nuniform sampler2D uSampler;\nin vec2 vTextureCoord;\nuniform vec2 uTextureSize;\nout vec4 fragColor;\nvoid main() {\n float step = 1.0 / uTextureSize.y;\n vec4 color = vec4(0.0);\n float total = 0.0;\n for (int i = -8; i <= 8; i++) {\n if (abs(float(i)) > blurY) continue;\n float weight = 1.0 - abs(float(i)) / (blurY + 1.0);\n color += texture(uSampler, vTextureCoord + vec2(0.0, float(i) * step)) * weight;\n total += weight;\n }\n fragColor = color / total;\n}";
|
|
14
|
+
readonly glow_frag: "#version 300 es\nprecision highp float;\nin vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float dist;\nuniform float angle;\nuniform vec4 color;\nuniform float alpha;\nuniform float blurX;\nuniform float blurY;\nuniform float strength;\nuniform float inner;\nuniform float knockout;\nuniform float hideObject;\nuniform vec2 uTextureSize;\nout vec4 fragColor;\nfloat random(vec2 scale) {\n return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);\n}\nvoid main(void) {\n vec2 px = vec2(1.0 / uTextureSize.x, 1.0 / uTextureSize.y);\n const float linearSamplingTimes = 7.0;\n const float circleSamplingTimes = 12.0;\n vec4 ownColor = texture(uSampler, vTextureCoord);\n vec4 curColor;\n float totalAlpha = 0.0;\n float maxTotalAlpha = 0.0;\n float offsetX = dist * cos(angle) * px.x;\n float offsetY = dist * sin(angle) * px.y;\n const float PI = 3.14159265358979323846264;\n float offset = PI * 2.0 / circleSamplingTimes * random(vec2(12.9898, 78.233));\n float stepX = blurX * px.x / linearSamplingTimes;\n float stepY = blurY * px.y / linearSamplingTimes;\n for (float a = 0.0; a <= PI * 2.0; a += PI * 2.0 / circleSamplingTimes) {\n float cosAngle = cos(a + offset);\n float sinAngle = sin(a + offset);\n for (float i = 1.0; i <= linearSamplingTimes; i++) {\n float curDistanceX = i * stepX * cosAngle;\n float curDistanceY = i * stepY * sinAngle;\n if (vTextureCoord.x + curDistanceX - offsetX >= 0.0 && vTextureCoord.y + curDistanceY + offsetY <= 1.0) {\n curColor = texture(uSampler, vec2(vTextureCoord.x + curDistanceX - offsetX, vTextureCoord.y + curDistanceY + offsetY));\n totalAlpha += (linearSamplingTimes - i) * curColor.a;\n }\n maxTotalAlpha += (linearSamplingTimes - i);\n }\n }\n ownColor.a = max(ownColor.a, 0.0001);\n ownColor.rgb = ownColor.rgb / ownColor.a;\n float outerGlowAlpha = (totalAlpha / maxTotalAlpha) * strength * alpha * (1.0 - inner) * max(min(hideObject, knockout), 1.0 - ownColor.a);\n float innerGlowAlpha = ((maxTotalAlpha - totalAlpha) / maxTotalAlpha) * strength * alpha * inner * ownColor.a;\n ownColor.a = max(ownColor.a * knockout * (1.0 - hideObject), 0.0001);\n vec3 mix1 = mix(ownColor.rgb, color.rgb, innerGlowAlpha / (innerGlowAlpha + ownColor.a));\n vec3 mix2 = mix(mix1, color.rgb, outerGlowAlpha / (innerGlowAlpha + ownColor.a + outerGlowAlpha));\n float resultAlpha = min(ownColor.a + outerGlowAlpha + innerGlowAlpha, 1.0);\n fragColor = vec4(mix2 * resultAlpha, resultAlpha);\n}";
|
|
15
15
|
readonly colorTransform_frag: "#version 300 es\nprecision mediump float;\nin vec2 vTextureCoord;\nin vec4 vColor;\nuniform mat4 matrix;\nuniform vec4 colorAdd;\nuniform sampler2D uSampler;\nout vec4 fragColor;\nvoid main(void) {\n vec4 texColor = texture(uSampler, vTextureCoord);\n if (texColor.a > 0.0) {\n texColor = vec4(texColor.rgb / texColor.a, texColor.a);\n }\n vec4 locColor = clamp(texColor * matrix + colorAdd, 0.0, 1.0);\n fragColor = vColor * vec4(locColor.rgb * locColor.a, locColor.a);\n}";
|
|
16
16
|
};
|
|
17
17
|
export declare const BLUR_TIERS2: readonly [4, 8, 16, 32];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderLib2.d.ts","sourceRoot":"","sources":["../../../../../src/blakron/player/webgl/shaders/ShaderLib2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ShaderLib2.d.ts","sourceRoot":"","sources":["../../../../../src/blakron/player/webgl/shaders/ShaderLib2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;CA8Nb,CAAC;AAIX,eAAO,MAAM,WAAW,yBAA0B,CAAC;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAKtD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAoBtD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAoBtD"}
|
|
@@ -86,6 +86,7 @@ precision mediump float;
|
|
|
86
86
|
uniform vec2 blur;
|
|
87
87
|
uniform sampler2D uSampler;
|
|
88
88
|
in vec2 vTextureCoord;
|
|
89
|
+
uniform vec2 uTextureSize;
|
|
89
90
|
out vec4 fragColor;
|
|
90
91
|
void main() {
|
|
91
92
|
const int sampleRadius = 5;
|
|
@@ -108,6 +109,7 @@ precision mediump float;
|
|
|
108
109
|
uniform float blurX;
|
|
109
110
|
uniform sampler2D uSampler;
|
|
110
111
|
in vec2 vTextureCoord;
|
|
112
|
+
uniform vec2 uTextureSize;
|
|
111
113
|
out vec4 fragColor;
|
|
112
114
|
void main() {
|
|
113
115
|
float step = 1.0 / uTextureSize.x;
|
|
@@ -127,6 +129,7 @@ precision mediump float;
|
|
|
127
129
|
uniform float blurY;
|
|
128
130
|
uniform sampler2D uSampler;
|
|
129
131
|
in vec2 vTextureCoord;
|
|
132
|
+
uniform vec2 uTextureSize;
|
|
130
133
|
out vec4 fragColor;
|
|
131
134
|
void main() {
|
|
132
135
|
float step = 1.0 / uTextureSize.y;
|
|
@@ -154,6 +157,7 @@ uniform float strength;
|
|
|
154
157
|
uniform float inner;
|
|
155
158
|
uniform float knockout;
|
|
156
159
|
uniform float hideObject;
|
|
160
|
+
uniform vec2 uTextureSize;
|
|
157
161
|
out vec4 fragColor;
|
|
158
162
|
float random(vec2 scale) {
|
|
159
163
|
return fract(sin(dot(gl_FragCoord.xy, scale)) * 43758.5453);
|
|
@@ -227,6 +231,7 @@ precision mediump float;
|
|
|
227
231
|
uniform float blurX;
|
|
228
232
|
uniform sampler2D uSampler;
|
|
229
233
|
in vec2 vTextureCoord;
|
|
234
|
+
uniform vec2 uTextureSize;
|
|
230
235
|
out vec4 fragColor;
|
|
231
236
|
void main() {
|
|
232
237
|
float step = 1.0 / uTextureSize.x;
|
|
@@ -247,6 +252,7 @@ precision mediump float;
|
|
|
247
252
|
uniform float blurY;
|
|
248
253
|
uniform sampler2D uSampler;
|
|
249
254
|
in vec2 vTextureCoord;
|
|
255
|
+
uniform vec2 uTextureSize;
|
|
250
256
|
out vec4 fragColor;
|
|
251
257
|
void main() {
|
|
252
258
|
float step = 1.0 / uTextureSize.y;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderLib2.js","sourceRoot":"","sources":["../../../../../src/blakron/player/webgl/shaders/ShaderLib2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,YAAY,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;EAiBxB;IAED,uEAAuE;IACvE,UAAU,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;EAmBtB;IAED,iCAAiC;IACjC,gFAAgF;IAChF,UAAU,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;EAmBtB;IAED,YAAY,EAAE,UAAU,CAAC;;;;;;;;EAQxB;IAED,cAAc,EAAE,UAAU,CAAC;;;;;;;EAO1B;IAED,SAAS,EAAE,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"ShaderLib2.js","sourceRoot":"","sources":["../../../../../src/blakron/player/webgl/shaders/ShaderLib2.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,YAAY,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;EAiBxB;IAED,uEAAuE;IACvE,UAAU,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;EAmBtB;IAED,iCAAiC;IACjC,gFAAgF;IAChF,UAAU,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;EAmBtB;IAED,YAAY,EAAE,UAAU,CAAC;;;;;;;;EAQxB;IAED,cAAc,EAAE,UAAU,CAAC;;;;;;;EAO1B;IAED,SAAS,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;EAqBrB;IAED,6DAA6D;IAC7D,WAAW,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;EAkBvB;IAED,2DAA2D;IAC3D,WAAW,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;EAkBvB;IAED,SAAS,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDrB;IAED,mBAAmB,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;EAe/B;CACQ,CAAC;AAEX,iFAAiF;AAEjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAU,CAAC;AAGnD,MAAM,UAAU,YAAY,CAAC,MAAc;IAC1C,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,MAAM,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACjC,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAe;IAC7C,OAAO,UAAU,CAAC;;;;;;;;;;;oBAWC,IAAI,UAAU,IAAI;;;;;;;EAOpC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAe;IAC7C,OAAO,UAAU,CAAC;;;;;;;;;;;oBAWC,IAAI,UAAU,IAAI;;;;;;;EAOpC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blakron/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Modern rewrite of the Egret game engine — WebGL multi-texture batching, instruction-driven render pipeline, strict TypeScript, Egret-compatible API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|