Skip to content

Instantly share code, notes, and snippets.

View munrocket's full-sized avatar

munrocket

View GitHub Profile
@munrocket
munrocket / webgpu_metal_capture.txt
Created May 13, 2024 18:25 — forked from slimbuck/webgpu_metal_capture.txt
Capturing WebGPU metal trace on MacOS
1) Clone and build WebKit
git clone https://github.com/WebKit/WebKit.git WebKit
cd WebKit
Tools/Scripts/build-webkit -cmakeargs="-DENABLE_WEBGPU_BY_DEFAULT=1" --debug
2) Run your app
__XPC_METAL_CAPTURE_ENABLED=1 Tools/Scripts/run-minibrowser --debug --url http://localhost:5000/index.html#/loaders/gsplat
@munrocket
munrocket / wgsl_2d_sdf.md
Last active September 13, 2024 06:29
WGSL 2D SDF Primitives

WGSL 2D SDF Primitives

Revision: 06.08.2023, https://compute.toys/view/398

Circle - exact

fn sdCircle(p: vec2f, r: f32) -> f32 {
  return length(p) - r;
}
@munrocket
munrocket / wgsl_3d_sdf.md
Last active September 15, 2024 15:11
WGSL 3D SDF Primitives

WGSL 3D SDF Primitives

Revision: 06.08.2023, https://compute.toys/view/407

Sphere - exact

fn sdSphere(p: vec3f, r: f32) -> f32 {
  return length(p) - r;
}
@munrocket
munrocket / wgsl_noise.md
Last active October 12, 2024 11:54
WGSL Noise Algorithms

WGSL Noise Algorithms

Good and fast integer hash

// https://www.pcg-random.org/
fn pcg(n: u32) -> u32 {
    var h = n * 747796405u + 2891336453u;
    h = ((h >> ((h >> 28u) + 4u)) ^ h) * 277803737u;
    return (h >> 22u) ^ h;
}
@munrocket
munrocket / shadertoy_exporter.js
Last active November 14, 2023 18:51
How to record cycled video from shadertoy
// copy paste this in console
function shader_exporter(duration, width, heigth, paused) {
document.getElementById('demogl').style.width = width + 'px';
document.getElementById('demogl').style.height = heigth + 'px';
document.getElementById('myResetButton').click();
document.getElementById('myRecord').click();
if (paused) document.getElementById('myPauseButton').click();
let t0 = performance.now();
function loop(){
if (performance.now() - t0 > duration * 1000) {
@munrocket
munrocket / canary.md
Last active September 3, 2024 16:22
Chrome Canary with WebGPU (for macos or linux)
// This simple snippet is a good start for FMA emulation in javascript.
// It pass a LOT of accuracy tests but can't handle cases with overflows and odd rounding
// IEEE compliant version is developed here: https://github.com/munsocket/proposal-fma/
export function fma(a, b, c) {
let LO;
function twoSum(a, b) {
let s = a + b;
let a1 = s - b;
@munrocket
munrocket / webm_conversion.md
Last active March 4, 2024 01:37
webm2gif converter for shadertoy

N png -> mp4

ffmpeg -r 30 -i "img%02d.png" -pix_fmt yuv420p -movflags +faststart perfectloop.mp4

trim first 5 second

ffmpeg -ss 00:00:05 -t 00:00:10 -i 1.mov 2.mov
@munrocket
munrocket / ios-web-testing.md
Last active October 23, 2022 19:30
Linux/Windows iOS testing

Console On Screen Universal Solution

const scrConsole = document.createElement('div');
scrConsole.id = 'screenConsole';
scrConsole.style.position = 'absolute';
scrConsole.style.zIndex = 9e9;
scrConsole.style.bottom = '5px';
scrConsole.style.left = '5px';
scrConsole.style.color = 'white'; 
scrConsole.style.fontSize = '.8em'; 
@munrocket
munrocket / ccxt.mini.js
Created September 25, 2018 16:28
Minimal version of CCXT library with only 11 stock exchanges
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/* A entry point for the browser bundle version. This gets compiled by:
browserify --debug ./ccxt.browser.js > ./build/ccxt.browser.js
*/
window.ccxt = require ('./ccxt')
},{"./ccxt":2}],2:[function(require,module,exports){
"use strict";