Skip to content

Instantly share code, notes, and snippets.

View moonraker22's full-sized avatar
πŸ’­
πŸŒ™ Above the clouds

MooNRakeR (Zac Kesler) moonraker22

πŸ’­
πŸŒ™ Above the clouds
View GitHub Profile
@moonraker22
moonraker22 / behaviors.ts
Last active June 10, 2023 15:27
A set of behavior creator functions for three-nebula in typescript so you get type hinting in ts
import {
Alpha,
Attraction,
Collision,
Color,
CrossZone,
Force,
Gravity,
RandomDrift,
Repulsion,
@moonraker22
moonraker22 / osx-for-hackers.sh
Created May 20, 2023 16:46 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@moonraker22
moonraker22 / revert.txt
Created May 20, 2023 16:41
revert commit safely
# Create a backup of master branch
git branch backup_master
# Point master to '56e05fce' and
# make working directory the same with '56e05fce'
git reset --hard 56e05fce
# Point master back to 'backup_master' and
# leave working directory the same with '56e05fce'.
git reset --soft backup_master
@moonraker22
moonraker22 / getWorldSpace.glsl
Created April 29, 2023 22:33
get world space in three js
vec3 worldCoordinatesFromDepth(float depth) {
float z = depth * 2.0 - 1.0;
vec4 clipSpaceCoordinate = vec4(vUv * 2.0 - 1.0, z, 1.0);
vec4 viewSpaceCoordinate = projectionMatrixInverse * clipSpaceCoordinate;
viewSpaceCoordinate /= viewSpaceCoordinate.w;
vec4 worldSpaceCoordinates = viewMatrixInverse * viewSpaceCoordinate;
@moonraker22
moonraker22 / curlNoise.glsl
Created April 16, 2023 03:58
Vec3 curl noise in glsl
float taylorInvSqrt(in float r) { return 1.79284291400159 - 0.85373472095314 * r; }
vec2 taylorInvSqrt(in vec2 r) { return 1.79284291400159 - 0.85373472095314 * r; }
vec3 taylorInvSqrt(in vec3 r) { return 1.79284291400159 - 0.85373472095314 * r; }
vec4 taylorInvSqrt(in vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }
float permute(const in float x) { return mod289(((x * 34.0) + 1.0) * x); }
vec2 permute(const in vec2 x) { return mod289(((x * 34.0) + 1.0) * x); }
vec3 permute(const in vec3 x) { return mod289(((x * 34.0) + 1.0) * x); }
vec4 permute(const in vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }
@moonraker22
moonraker22 / noise.glsl
Created April 16, 2023 02:23 — forked from akella/noise.glsl
noise.glsl
//
// GLSL textureless classic 3D noise "cnoise",
// with an RSL-style periodic variant "pnoise".
// Author: Stefan Gustavson ([email protected])
// Version: 2011-10-11
//
// Many thanks to Ian McEwan of Ashima Arts for the
// ideas for permutation and gradient selection.
//
// Copyright (c) 2011 Stefan Gustavson. All rights reserved.
@moonraker22
moonraker22 / noise.glsl
Created April 16, 2023 02:22 — forked from akella/noise.glsl
noise4d
//
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
//
@moonraker22
moonraker22 / cover.glsl
Last active April 16, 2023 01:25
An image cover glsl implementation
vec2 Cover(vec2 uv, vec2 screenSize, vec2 imageSize) {
vec2 s = screenSize;
vec2 i = imageSize;
float rs = s.x / s.y;
float ri = i.x / i.y;
vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);
vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;
vec2 st = uv * s / new + offset;
@moonraker22
moonraker22 / perlin.glsl
Created April 15, 2023 07:41
Classic Perlin 3D Noise in glsl
// Classic Perlin 3D Noise
// by Stefan Gustavson
//
vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}
vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}
float cnoise(vec3 P){
vec3 Pi0 = floor(P); // Integer part for indexing
vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
@moonraker22
moonraker22 / simplexNoise.js
Created April 9, 2023 00:20
simplex noise in js
/*
* A fast javascript implementation of simplex noise by Jonas Wagner
Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java.
Which is based on example code by Stefan Gustavson ([email protected]).
With Optimisations by Peter Eastman ([email protected]).
Better rank ordering method by Stefan Gustavson in 2012.
Copyright (c) 2021 Jonas Wagner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights