Skip to content

Instantly share code, notes, and snippets.

View avrahamy's full-sized avatar

Or Avrahamy avrahamy

View GitHub Profile
@avrahamy
avrahamy / SpineRandomAnimationsSequence.cs
Last active November 11, 2021 10:33
Random animations sequence utility
using UnityEngine;
using System;
using Spine;
using Spine.Unity;
namespace GentleGiant.Animation {
public class SpineRandomAnimationsSequence : MonoBehaviour {
[Serializable]
public class AnimationChance {
[SpineAnimation(dataField = "skeletonAnimation")]
@avrahamy
avrahamy / SkeletonAnimationPreviewWindow.cs
Last active January 9, 2022 08:19
A tool to scrub Spine2D animations in Unity. Select a Game Object in the scene (or in Prefab Mode) with a SkeletonAnimation, select the animation to preview and use the slider to pick the time of the frame you want to see.
using UnityEditor;
using UnityEngine;
using Spine.Unity;
namespace Avrahamy.Animation {
public class SkeletonAnimationPreviewWindow : EditorWindow {
private const string WINDOW_TITLE = "Skeleton Animation Preview";
private string animationName;
private float time;
@avrahamy
avrahamy / LogarithmicBinning.hlsl
Last active January 2, 2024 09:52
Logarithmic Binning shader code to be used in a Custom Function Node in Shader Graph (in Unity). LogBinNoise_float uses Logarithmic Binning to calculate the weights of gradient noise functions with different scales. Implemented according to the description in this GDC talk by Sean Feeley on his work on God of War: https://www.youtube.com/watch?v…
// Taken from GradientNoiseNode.cs from the Shader Graph package.
float2 GradientNoise_Dir_float(float2 p) {
// Permutation and hashing used in webgl-nosie goo.gl/pX7HtC
p = p % 289;
// need full precision, otherwise half overflows when p > 1
float x = float(34 * p.x + 1) * p.x % 289 + p.y;
x = (34 * x + 1) * x % 289;
x = frac(x / 41) * 2 - 1;
return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
}