Skip to content

Instantly share code, notes, and snippets.

View ccincotti3's full-sized avatar

Carmen Cincotti ccincotti3

View GitHub Profile
@ccincotti3
ccincotti3 / index.html
Last active January 19, 2024 22:29
WebGPU Triangle 2022
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Carmen Cincotti - WebGPU Triangle</title>
<style>
canvas {
width: 100%;
@ccincotti3
ccincotti3 / lookat.js
Created April 21, 2022 03:19
LookAt Matrix Calculation
const { vec3, mat4 } = glMatrix // from gl-matrix library
const lookAtMatrix = mat4.create();
{
const forwardVector = vec3.create();
const positionOfCamera = vec3.fromValues(0, 4, 4);
{
const positionOfTarget = vec3.fromValues(0, 0, 0);
vec3.subtract(forwardVector, positionOfCamera, positionOfTarget);
vec3.normalize(forwardVector, forwardVector);
}
@ccincotti3
ccincotti3 / obj_loader_web_gpu.ts
Last active September 9, 2022 14:19
obj_loader
interface Mesh {
positions: Float32Array;
uvs: Float32Array;
normals: Float32Array;
indices: Uint16Array;
}
type ObjFile = string
type FilePath = string
prometheus:
prometheusSpec:
additionalScrapeConfigs:
- job_name: blackbox
metrics_path: /probe
scrape_interval: 30s
scrape_timeout: 20s
params:
module: [http_2xx]
kubernetes_sd_configs:
modules:
http_2xx:
prober: http
timeout: 20s
http:
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
follow_redirects: false
preferred_ip_protocol: "ip4"
@ccincotti3
ccincotti3 / distanceConstraint.js
Last active August 23, 2022 14:02
Solving a distance constraint with XPBD and small steps. https://carmencincotti.com
// Accompanying article can be found at https://carmencincotti.com
const TIME_STEP = 0.01; // Hard code for now
const STEPS = 500; // number of substeps
const particles = [
{
m: 1, // mass
w: 1, // hard code mass inverse
x: [2, 2, 0], // position
@ccincotti3
ccincotti3 / isometricBendingConstraint.js
Last active August 31, 2022 13:36
Isometric Bending Constraint for XPBD, accompanying article at https://www.carmencincotti.com
// Isometric Bending Constraint for XPBD, accompanying article at https://www.carmencincotti.com
const TIME_STEP = 0.01; // Hard code for now
const STEPS = 1000; // number of substeps
const particles = [
{
m: 2.0, //mass
x: [0, 0, 0], // position
p: [0, 0, 0], // temp position,
f: [0, 0, 0], // force
@ccincotti3
ccincotti3 / findTriNeighbors.ts
Last active August 30, 2022 14:03
findTriNeighbors from Matthias Müller, commented for my blog use - at www.carmencincotti.com
// Find neighbor triangles by using an edge list that keeps track of shared edges.
// This is taken from Matthias Müller - source: https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/14-cloth.html
// I've gone ahead and added in some comments / and typed the function for my own use.
// You can find an accompanying article at https://www.carmencincotti.com
function findTriNeighbors(indices: Uint16Array): Float32Array {
const edges = [];
const numTris = indices.length / 3;
for (let i = 0; i < numTris; i++) {
@ccincotti3
ccincotti3 / getTriPairs.ts
Last active August 30, 2022 14:14
getTriPairs from Matthias Müller, commented for my blog use - at www.carmencincotti.com
// This is taken from Matthias Müller - source: https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/14-cloth.html
// I've gone ahead and added in some comments / and typed the function for my own use.
// You can find an accompanying article at https://www.carmencincotti.com
// Find four points that make up two adjacent triangles
// id2
// / \
// / \
// id0 --- id1
// \ /
@ccincotti3
ccincotti3 / bendingConstraint.js
Created August 31, 2022 13:37
Performant Bending Constraint for XPBD, accompanying article at https://www.carmencincotti.com
// More performant Bending Constraint for XPBD, accompanying article at https://www.carmencincotti.com
const particles = [
{
m: 1.0, //mass
x: [-0.98, -1.00, 0.00], // position
p: [-0.98, -1.00, 0.00], // temp position,
f: [0, 0, 0], // force
v: [0, 0, 0], // velocity
w: 1.0,