Skip to content

Instantly share code, notes, and snippets.

View paulhayes's full-sized avatar

Paul Hayes paulhayes

View GitHub Profile
@paulhayes
paulhayes / fractalnoise.js
Created May 20, 2017 11:21
Fractal Noise using fluid dynamics equations
// Using Lorenz equations
// http://www.stsci.edu/~lbradley/seminar/attractors.html
// https://arxiv.org/ftp/math/papers/0305/0305212.pdf
x = 1.0;
y = -1.0;
z = 10.0;
P = 10.0;
R = 28.0;
B = 8.0/3;
@paulhayes
paulhayes / overlayImage.bash
Created May 6, 2017 17:19
FFMpeg Overlay Image function
function overlayImage(){
echo "overlayImage {input_video} {input_image} {output_video}"
ffmpeg -i "$1" -i "$2" -filter_complex "[0:v][1:v] overlay=0:0" "$3"
}
@paulhayes
paulhayes / FilterExample.cs
Last active April 5, 2017 21:59
An example of using events for accumulative modifier in CSharp
public class FilterExample()
{
public delegate void FilterFunc(ref keep);
public event FilterFunc EventFilter;
public bool Filter()
{
bool keep = true;
if( EventFilter != null ){
@paulhayes
paulhayes / Parabola.cs
Last active October 11, 2021 07:40
Calculate Trajectory Parabola in Unity3d
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Parabola {
Vector3 start;
Vector3 end;
Vector3 startVel;
Vector3 acceleration;
@paulhayes
paulhayes / RecordAnimation.cs
Last active March 22, 2017 17:09
Really simple, but useful motion capture script for use with OpenVR or Oculus tracking systems. Will work with anything though, even joystick controlled movement. Usage demo here: https://www.youtube.com/watch?v=wsCd0lkSdRY
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
[RequireComponent(typeof(Animator))]
public class RecordAnimation : MonoBehaviour
{
@paulhayes
paulhayes / ParabolaDrawer.cs
Created March 17, 2017 18:54
Parabola PhysicsRaycaster concept for Unity-VRInputModule
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(LineRenderer))]
[RequireComponent(typeof(ParabolaRaycaster))]
public class ParabolaDrawer : MonoBehaviour {
LineRenderer lineRenderer;
ParabolaRaycaster parabolaRaycaster;
@paulhayes
paulhayes / Sun.cs
Last active November 23, 2025 11:15
Rotates a Unity directional light based on location and time. Includes time scale, and frame stepping for continuous use.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Entropedia
{
[RequireComponent(typeof(Light))]
[ExecuteInEditMode]
@paulhayes
paulhayes / calcDeltaV.js
Last active February 1, 2017 13:44
Written for Kerbal Space Program.
var calcDeltaV = function(dryMass,wetMass,isp){ return Math.log(wetMass/dryMass)*isp*9.81 };
#include <PinChangeInt.h>
#define BTN 0
int lastRead;
void setup() {
BeanHid.enable();
Bean.setBeanName("Reset Button");
Bean.setPairingPin(162258);
Bean.enablePairingPin(true);
/*
* I've recorded this because it would be very useful when using shaders to do computation for game mechanics or effects.
* For instance I've made a shader based terrain deformation system, but it doesn't have physics. That's now possible
* while still being effcient
*/
[DllImport("opengl32")]
public static extern void glReadPixels (int x, int y, int width, int height, int format, int type, IntPtr buffer);