Skip to content

Instantly share code, notes, and snippets.

View Donnotron666's full-sized avatar

Don Bellenger Donnotron666

View GitHub Profile
@Donnotron666
Donnotron666 / Shake.cs
Created October 29, 2023 18:29
Shake Controller
using Core.Utils;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Core.Movement
{
public class ShakeController
{
private List<Shake> ActiveShakes = new List<Shake>();
@Donnotron666
Donnotron666 / EdgeMap.hlsl
Created September 24, 2023 17:27
Consume Edge Maps on the GPU
void getSpriteEdges_float(UnityTexture2D edgeMap, UnitySamplerState ss, float2 uv, out float top, out float right, out float left, out float bot) {
//MY COUNTERPART IS EdgeMapUtils.GetEdge
float4 color = edgeMap.Sample(ss, uv);
top = color.r;
right = color.g;
left = color.b;
bot = color.a;
@Donnotron666
Donnotron666 / EdgeMapUtils.cs
Created September 24, 2023 17:25
CPU-Based Edge Detection
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Editor.Utility
{
public static class EdgeMapUtils
{
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine;
namespace Editor.Assets
{
public class SpriteImporterAtlasRebuild : AssetPostprocessor
{
@Donnotron666
Donnotron666 / Easing.cs
Last active October 26, 2020 23:57
Simple controller for managing squash n stretch on transforms.
namespace Core.Utils
{
static public class Easing
{
/// <summary>
/// Constant Pi.
/// </summary>
private const float PI = Math.PI;
@Donnotron666
Donnotron666 / EffectTTL.cs
Created October 19, 2018 18:37
Softly killing particle systems
using Client.Game.Utils;
using System;
using UnityEngine;
namespace Client.Game.Abilities.Utils
{
public class EffectTTL : MonoBehaviour
{
public EffectTTL ()
{
@Donnotron666
Donnotron666 / EmissiveSpriteShaderClamped.shader
Last active May 15, 2019 03:06
A sprite shader with emission clamping. The EmissionClamping values keep the shader from creating emission under certain thresholds, so a texture of mostly dark colors with a few bright highlights can be kept as a single game sprite.
Shader "Sprites/EmissiveSpriteShaderClamped"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_SelfIllum("Self Illumination",Range(0.0,1.0)) = 0.0
_FlashAmount("Flash Amount",Range(0.0,1.0)) = 0.0
_Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
_EmissionMap("Emission Map", 2D) = "black"{}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace Client.Game.Abilities.Utils
{
public class ActionSequence : List<ActionElement>
{
using Client.Game.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
namespace Client.Game.Actors.Controllers {
public class VectorConsumer {
Shader "Sprites/EmissiveSpriteShader"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_SelfIllum("Self Illumination",Range(0.0,1.0)) = 0.0
_FlashAmount("Flash Amount",Range(0.0,1.0)) = 0.0
[PerRendererData] _Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
_EmissionMap("Emission Map", 2D) = "black"{}