Skip to content

Instantly share code, notes, and snippets.

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

Pedro sketchpunk

🏠
Working from home
View GitHub Profile
@kenjinp
kenjinp / NOAAColorRamp.ts
Created February 25, 2025 08:20
This is the color schema I use in https://geomancer.kenny.wtf/
export const noaaRamp = [
{ color: "#ffffff", elevation: 8000 },
{ color: "#E0D7D0", elevation: 4000 },
{ color: "#CDB99C", elevation: 2000 },
{ color: "#BA9468", elevation: 1000 },
{ color: "#9B7E43", elevation: 500 },
{ color: "#75752D", elevation: 250 },
{ color: "#456C18", elevation: 50 },
{ color: "#175515", elevation: 10 },
{ color: "#004023", elevation: 0.1 },
@FreyaHolmer
FreyaHolmer / GpuPrinter.cginc
Last active March 16, 2025 05:51
A unity shader .cginc to draw numbers in the fragment shader - see the first comment below for example usage!
///////////////////////////////////////////////////////////////////////////////
// ABOUT: A unity Shader .cginc to draw numbers in the fragment shader
// AUTHOR: Freya Holmér
// LICENSE: Use for whatever, commercial or otherwise!
// Don't hold me liable for issues though
// But pls credit me if it works super well <3
// LIMITATIONS: There's some precision loss beyond 3 decimal places
// CONTRIBUTORS: yes please! if you know a more precise way to get
// decimal digits then pls lemme know!
// GetDecimalSymbolAt() could use some more love/precision
@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 February 14, 2025 06:56
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;
}