From: Chris Duncan Date: Sun, 15 Dec 2024 08:38:44 +0000 (-0800) Subject: Assign bytes in loop. Assign frag color with multiplication instead of branching... X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=1f51d8d90bcf8bf8586f257599da9b3d40a4be69;p=libnemo.git Assign bytes in loop. Assign frag color with multiplication instead of branching if statement. --- diff --git a/src/lib/workers/pow.ts b/src/lib/workers/pow.ts index a5f6588..7c7ee1e 100644 --- a/src/lib/workers/pow.ts +++ b/src/lib/workers/pow.ts @@ -168,14 +168,9 @@ void main() { m[1] = (u_work1.r ^ (u_work1.g << 8) ^ (u_work1.b << 16) ^ (u_work1.a << 24)); // Block hash - m[2] = blockHash[0]; - m[3] = blockHash[1]; - m[4] = blockHash[2]; - m[5] = blockHash[3]; - m[6] = blockHash[4]; - m[7] = blockHash[5]; - m[8] = blockHash[6]; - m[9] = blockHash[7]; + for (i=0;i<8;i++) { + m[i+2] = blockHash[i]; + } // twelve rounds of mixing for(i=0;i<12;i++) { @@ -191,15 +186,19 @@ void main() { // Threshold test, first 4 bytes not significant, // only calculate digest of the second 4 bytes - if((BLAKE2B_IV32_1 ^ v[1] ^ v[17]) > threshold) { - // Success found, return pixel data so work value can be constructed - fragColor = vec4( - float(x_index + 1u)/255., // +1 to distinguish from 0 (unsuccessful) pixels - float(y_index + 1u)/255., // Same as previous - float(x_pos)/255., // Return the 2 custom bytes used in work value - float(y_pos)/255. // Second custom byte + //if((BLAKE2B_IV32_1 ^ v[1] ^ v[17]) > threshold) { + // Success found, set pixel data so work value can be constructed + fragColor = mix( + fragColor, + vec4( + float(x_index + 1u)/255., // +1 to distinguish from 0 (unsuccessful) pixels + float(y_index + 1u)/255., // Same as previous + float(x_pos)/255., // Return the 2 custom bytes used in work value + float(y_pos)/255. // Second custom byte + ), + float((BLAKE2B_IV32_1 ^ v[1] ^ v[17]) > threshold) ); - } + //} }` /** Used to set canvas size. Must be a multiple of 256. */