Skip to content

Instantly share code, notes, and snippets.

@Fraktality
Fraktality / NaturalSplines.lua
Created July 3, 2023 01:31
Find the acceleration-minimizing curve between a list of points
-- Given a knot sequence p[1<=i<=n], solve for a sequence of cubic
-- splines s[1<=i<=n-1] such that the square of acceleration is minimized.
local gamma = {
0.50000000000000000, 0.28571428571428571, 0.26923076923076923, 0.26804123711340206,
0.26795580110497238, 0.26794966691339748, 0.26794922649742166, 0.26794919487697295,
0.26794919260672685, 0.26794919244373052, 0.26794919243202791, 0.26794919243118770,
0.26794919243112737, 0.26794919243112304, 0.26794919243112273, 0.26794919243112271,
}
local gammaLimit = gamma[#gamma]
@Fraktality
Fraktality / Zones.lua
Last active August 6, 2025 20:37
Fast trigger volumes
local RunService = game:GetService("RunService")
-- compile an oriented bounding box into a scaled CFrame
local function compileBBox(cframe: CFrame, size: Vector3)
return CFrame.fromMatrix(
cframe.Position,
cframe.XVector/size.X,
cframe.YVector/size.Y,
cframe.ZVector/size.Z
):Inverse()
@SugoiDev
SugoiDev / update-unity-compiler.cmd
Created July 24, 2018 08:26 — forked from zoon/update-unity-compiler.cmd
Latest version of Roslyn for unity.incrementalcompiler
@rem update-unity-compiler.cmd
@rem start in */[email protected] folder
@echo off
@rem NOTE: FIND.EXE can clash with git/msys/cygwin's find
for %%a in (%ComSpec%) do set __system=%%~dpa
%__system%FIND.EXE /i "com.unity.incrementalcompiler" package.json 1> NUL
if %errorlevel% neq 0 goto :not_found
nuget install Microsoft.Net.Compilers -verbosity quiet
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active September 13, 2025 07:41
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@joethephish
joethephish / Exp_for_zooming.md
Last active March 12, 2018 01:36
Using Mathf.Exp for zooming

Using Exp for zooming

One of the things I’m happiest to have learned in the past few months is a great use for Log + Exp in games when zooming in and out.

You may have already know that linear speeds work horribly for zooming, e.g.:

void Update() {
    scale = scale + speed * Time.deltaTime;
}
@tomkail
tomkail / DefaultAssetEditor.cs
Last active August 21, 2024 10:41
Draws inspectors for any file type Unity doesn't draw by default
/// Used to draw custom inspectors for unrecognised file types, which Unity imports as "DefaultAsset"
/// To do this, create a new editor class extending DefaultAssetInspector
/// Return true in the IsValid function if the file extension of the file matches the type you'd like to draw.
/// The DefaultAssetEditor class will then hold a reference to the new instance of your editor class and call the appropriate methods for drawing.
/// An example can be found at the bottom of the file.
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
@lbruder
lbruder / lbForth.c
Created April 6, 2014 15:21
A minimal Forth compiler in ANSI C
/*******************************************************************************
*
* A minimal Forth compiler in C
* By Leif Bruder <leifbruder@gmail.com> http://defineanswer42.wordpress.com
* Release 2014-04-04
*
* Based on Richard W.M. Jones' excellent Jonesforth sources/tutorial
*
* PUBLIC DOMAIN
*