summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/main.js b/main.js
index d1e0684..513991e 100644
--- a/main.js
+++ b/main.js
@@ -91,18 +91,18 @@ function lensflare(pos_x, pos_y) {
const u = (x / canvas.width - .5) * aspect_ratio;
const v = y / canvas.height - .5;
- const intensity = 1.5;
- const uv_len = Math.sqrt(u * u + v * v);
+ const intensity = 1.5 * 255;
+ const uv_len = u * u + v * v;
const uvd_x = u * uv_len;
const uvd_y = v * uv_len;
- const uvd_len = Math.sqrt(uvd_x * uvd_x + uvd_y * uvd_y);
+ const uvd_len = uvd_x * uvd_x + uvd_y * uvd_y;
const uvd_pos_x = uvd_x + pos_x;
const uvd_pos_y = uvd_y + pos_y;
let temp = uvd_pos_x * uvd_pos_x + uvd_pos_y * uvd_pos_y
- const f2 = Math.max(1.0 / (1.0 + 32.0 * (temp * .64)), .0) * 0.1;
- const f22 = Math.max(1.0 / (1.0 + 32.0 * (temp * .72)), .0) * 0.08;
- const f23 = Math.max(1.0 / (1.0 + 32.0 * (temp * .81)), .0) * 0.06;
+ const f2 = Math.max(1.0 / (1.0 + 32.0 * temp * .64), .0) * 0.1;
+ const f22 = Math.max(1.0 / (1.0 + 32.0 * temp * .72), .0) * 0.08;
+ const f23 = Math.max(1.0 / (1.0 + 32.0 * temp * .81), .0) * 0.06;
let uvx_x = u * (1 + 0.5) + uvd_x * 0.5;
let uvx_y = v * (1 + 0.5) + uvd_y * 0.5;
@@ -110,9 +110,9 @@ function lensflare(pos_x, pos_y) {
let uvx_pos_y = uvx_y + pos_y;
temp = uvx_pos_x * uvx_pos_x + uvx_pos_y * uvx_pos_y
- const f4 = Math.max(0.01 - Math.pow((temp * .16), 1.2), .0) * 6.0;
- const f42 = Math.max(0.01 - Math.pow((temp * .2025), 1.2), .0) * 5.0;
- const f43 = Math.max(0.01 - Math.pow((temp * .25), 1.2), .0) * 3.0;
+ const f4 = Math.max(0.01 - temp * .16, .0) * 6.0;
+ const f42 = Math.max(0.01 - temp * .20, .0) * 5.0;
+ const f43 = Math.max(0.01 - temp * .25, .0) * 3.0;
uvx_x = u * (1 + 0.4) + uvd_x * 0.4;
uvx_y = v * (1 + 0.4) + uvd_y * 0.4;
@@ -120,9 +120,9 @@ function lensflare(pos_x, pos_y) {
uvx_pos_y = uvx_y + pos_y;
temp = uvx_pos_x * uvx_pos_x + uvx_pos_y * uvx_pos_y
- const f5 = Math.max(0.01 - Math.pow((temp * .04), 2.475), .0) * 2.0;
- const f52 = Math.max(0.01 - Math.pow((temp * .16), 2.475), .0) * 2.0;
- const f53 = Math.max(0.01 - Math.pow((temp * .36), 2.75), .0) * 2.0;
+ const f5 = Math.max(0.01 - temp * .04, .0) * 2.0;
+ const f52 = Math.max(0.01 - temp * .16, .0) * 2.0;
+ const f53 = Math.max(0.01 - temp * .36, .0) * 2.0;
uvx_x = u * (1 + 0.5) + uvd_x * 0.5;
uvx_y = v * (1 + 0.5) + uvd_y * 0.5;
@@ -130,13 +130,13 @@ function lensflare(pos_x, pos_y) {
uvx_pos_y = uvx_y - pos_y;
temp = uvx_pos_x * uvx_pos_x + uvx_pos_y * uvx_pos_y
- const f6 = Math.max(0.01 - Math.pow(temp * .9, 0.8), .0) * 6.0;
- const f62 = Math.max(0.01 - Math.pow(temp * .1, 0.8), .0) * 3.0;
- const f63 = Math.max(0.01 - Math.pow(temp * .12, 0.8), .0) * 5.0;
+ const f6 = Math.max(0.01 - temp * .9, .0) * 6.0;
+ const f62 = Math.max(0.01 - temp * .1, .0) * 3.0;
+ const f63 = Math.max(0.01 - temp * .12, .0) * 5.0;
- imgdata.data[4 * i + 0] += 1.2 * ((f2 + f4 + f5 + f6) * 1.3 - uvd_len * .05) * intensity * 255;
- imgdata.data[4 * i + 1] += 1.5 * ((f22 + f42 + f52 + f62) * 1.3 - uvd_len * .05) * intensity * 255;
- imgdata.data[4 * i + 2] += 1.3 * ((f23 + f43 + f53 + f63) * 1.3 - uvd_len * .05) * intensity * 255;
+ imgdata.data[4 * i + 0] += 1.2 * ((f2 + f4 + f5 + f6) * 1.3 - uvd_len * .05) * intensity;
+ imgdata.data[4 * i + 1] += 1.5 * ((f22 + f42 + f52 + f62) * 1.3 - uvd_len * .05) * intensity;
+ imgdata.data[4 * i + 2] += 1.3 * ((f23 + f43 + f53 + f63) * 1.3 - uvd_len * .05) * intensity;
imgdata.data[4 * i + 3] = 255;
}
ctx.putImageData(imgdata, 0, 0);
@@ -161,6 +161,5 @@ function draw(viewport_scale) {
ctx.filter = '';
lensflare(.3,.3);
-
}