Skip to content

Instantly share code, notes, and snippets.

@CornuAmmonis
CornuAmmonis / colorspace.wgsl
Last active April 13, 2022 20:12
Project a texture into a 3D colorspace histogram
type float4x4 = mat4x4<f32>;
fn rotXW(t: float) -> float4x4 {
return float4x4(
1.0, 0.0, 0.0, 0.0,
0.0, cos(t), sin(t), 0.0,
0.0, - sin(t), cos(t), 0.0,
0.0, 0.0, 0.0, 1.0
);
}
@CornuAmmonis
CornuAmmonis / glider-distance
Last active December 4, 2015 00:17
gliders and a propagating distance field
__kernel void rd_compute(__global float4 *a_in,__global float4 *b_in,__global float4 *c_in,__global float4 *d_in,__global float4 *e_in,__global float4 *a_out,__global float4 *b_out,__global float4 *c_out,__global float4 *d_out,__global float4 *e_out)
{
const int index_x = get_global_id(0);
const int index_y = get_global_id(1);
const int index_z = get_global_id(2);
const int X = get_global_size(0);
const int Y = get_global_size(1);
const int Z = get_global_size(2);
const int index_here = X*(Y*index_z + index_y) + index_x;
@CornuAmmonis
CornuAmmonis / splittwit.sh
Last active June 17, 2018 17:08
Shell script that uses twurl to upload a chunked native video to Twitter.
file=""
tweet=""
if [ -n "$1" ]
then
file="$1"
else
echo "Usage: splittwit /path/to/video.mp4 \"My tweet goes here!\""
exit
fi
float[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);