Revision: 06.08.2023, https://compute.toys/view/407
fn sdSphere(p: vec3f, r: f32) -> f32 {
return length(p) - r;
}
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class pipeGenerator : MonoBehaviour | |
{ | |
[SerializeField] Mesh straightMesh; | |
[SerializeField] Mesh elbowMesh; | |
[Space] | |
[SerializeField] Vector3[] pathPoints; |
// 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)) | |
); |
/* | |
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) { |
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)! | |
} |
/** | |
* 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++}:`) |
// | |
// 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 |
// | |
// 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; | |
} |
Revision: 06.08.2023, https://compute.toys/view/407
fn sdSphere(p: vec3f, r: f32) -> f32 {
return length(p) - r;
}
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): | |
""" |