Skip to content

Instantly share code, notes, and snippets.

View sketchpunk's full-sized avatar
🏠
Working from home

SketchPunk sketchpunk

🏠
Working from home
View GitHub Profile
@antonkudin
antonkudin / pipeGenerator.cs
Created September 26, 2023 13:48
Generates pipe mesh from mesh segments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipeGenerator : MonoBehaviour
{
[SerializeField] Mesh straightMesh;
[SerializeField] Mesh elbowMesh;
[Space]
[SerializeField] Vector3[] pathPoints;
@williamchange
williamchange / tri_voronoi.hlsl
Last active February 21, 2023 15:51
Triangle Voronoi Borders HLSL UE (Custom Node)
// Based on "Triangle Voronoi Borders" by Thomas Hooper (@tdhooper)
// https://www.shadertoy.com/view/ss3fW4
struct Functions
{
float3 sdTriEdges(float2 p) {
return float3(
dot(p, float2(0.,-1.)),
dot(p, float2(.866025, .5)),
dot(p, float2(-.866025, .5))
);
@williamchange
williamchange / tri_voronoi.osl
Created February 19, 2023 05:38
Triangle Voronoi Blender OSL
/*
OSL Triangle Voronoi Borders
Based on a shadertoy by Thomas Hooper(tdhooper):
https://www.shadertoy.com/view/ss3fW4
*/
vector fract(vector v) { return mod(v*.5,.5)*2.; }
vector vstep(vector a, vector b) {
@steveruizok
steveruizok / cache.ts
Last active March 31, 2023 14:43
weak map gist
export class Cache<T extends object, K> {
items = new WeakMap<T, K>()
get<P extends T>(item: P, cb: (item: P) => K) {
if (!this.items.has(item)) {
this.items.set(item, cb(item))
}
return this.items.get(item)!
}
@CodyJasonBennett
CodyJasonBennett / index.ts
Last active May 31, 2023 07:59
WebGL 2 Compute via Transform Feedback
/**
* Matches against GLSL shader outputs.
*/
const VARYING_REGEX = /[^\w](?:varying|out)\s+\w+\s+(\w+)\s*;/g
/**
* Adds line numbers to a string with an optional starting offset.
*/
const lineNumbers = (source: string, offset = 0): string => source.replace(/^/gm, () => `${offset++}:`)
@dwilliamson
dwilliamson / ModifiedMarchingCubes.js
Created February 8, 2022 16:20
Transvoxel's Modified Marching Cubes Lookup Tables
//
// Lookup Tables for Transvoxel's Modified Marching Cubes
//
// Unlike the original paper (Marching Cubes: A High Resolution 3D Surface Construction Algorithm), these tables guarantee
// a closed mesh "whose connected components are continuous and free of holes."
//
// Rotations are prioritised over inversions so that 3 of the 6 cases containing ambiguous faces are never added. 3 extra
// cases are added as a post-process, overriding inverses through custom-build rotations to eliminate the rest.
//
// Uses the exact same co-ordinate system as https://gist.github.com/dwilliamson/c041e3454a713e58baf6e4f8e5fffecd
@dwilliamson
dwilliamson / MarchingCubes.js
Last active July 1, 2024 11:43
Marching Cubes Lookup Tables
//
// Lookup Tables for Marching Cubes
//
// These tables differ from the original paper (Marching Cubes: A High Resolution 3D Surface Construction Algorithm)
//
// The co-ordinate system has the more convenient properties:
//
// i = cube index [0, 7]
// x = (i & 1) >> 0
// y = (i & 2) >> 1
// Processing code by Etienne JACOB
// motion blur template by beesandbombs
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
@munrocket
munrocket / wgsl_3d_sdf.md
Last active June 28, 2024 17:29
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;
}
@chris-lesage
chris-lesage / calculate_pole_vector.py
Last active April 20, 2024 14:07
Autodesk Maya script to calculate pole vector position based on 3 input objects
import pymel.core as pm
'''
An Autodesk Maya PyMEL script that calculates a pole vector position
based on 3 input PyNode objects. example: leg, knee, ankle bones.
Chris Lesage chris@rigmarolestudio.com
'''
def calculate_pole_vector(p1, p2, p3, poleDistance=1):
"""