Skip to content

Instantly share code, notes, and snippets.


Tilman Schmidt KeyMaster-

View GitHub Profile
KeyMaster- / spriteGlitch.shader
Last active December 18, 2022 01:56
A glitch effect shader for Sprites in Unity3D
View spriteGlitch.shader
//Copyright (c) 2014 Tilman Schmidt (@KeyMaster_)
//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
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in
KeyMaster- / polarWarp.glsl
Created April 4, 2015 21:27
Cartesian to Polar coordinates warp shader, for
View polarWarp.glsl
//To be used on
//Uses the image at iChannel0 and warps it into polar coordinates
void mainImage( out vec4 fragColor, in vec2 fragCoord )
vec2 relativePos = fragCoord.xy - (iResolution.xy / 2.0);
vec2 polar;
polar.y = sqrt(relativePos.x * relativePos.x + relativePos.y * relativePos.y);
polar.y /= iResolution.x / 2.0;
polar.y = 1.0 - polar.y;
KeyMaster- /
Last active March 28, 2020 23:59
A simple harmonic oscillator simulation for testing out different numerical integration methods. Logs state at each step in CSV format.
// Just position and velocity along one dimension. We're assuming the particle has a mass of 1.
struct State {
x: f64,
v: f64,
trait Integrator {
fn step(&mut self, state: State, sim: &Simulation, dt: f64) -> State;
KeyMaster- / polarWarp.glsl
Last active November 20, 2019 15:00
Luxe polar warp shader
View polarWarp.glsl
//The source texture that will be transformed
uniform sampler2D tex0;
//The texture coordinate passed in from the vertex shader (the default luxe vertex shader is suffice)
varying vec2 tcoord;
//x: width of the texture divided by the radius that represents the top of the image (normally screen width / radius)
//y: height of the texture divided by the radius representing the top of the image (normally screen height / radius)
uniform vec2 sizeOverRadius;
KeyMaster- / WavePhys.hx
Created April 16, 2015 10:12
Code sample for doing wave spring physics
View WavePhys.hx
//Note: This does _not_ compile, it's just to demonstrate the relevant physics bits
class Main extends luxe.Game {
var fieldWidth:Int = 60;
var fieldDepth:Int = 60;
var physTimeStep:Float = 1 / 60;
var physTimeCounter:Float = 0;
var springK:Float = 100;
var springDampening:Float = 0.00;
KeyMaster- / IsoCamSetup
Created October 5, 2014 13:22
Isometric view in the luxe engine
View IsoCamSetup
//Rotate the camera such that z points up and x to the right
var o:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(-90, 0, 0).radians());
//Rotate by Arctan(sin(45°)) (grabbed from wikipedia) around x, to get the top-down part
var q:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(Math.atan(Math.sin(45 * Maths.DEG2RAD)), 0, 0));
//Rotate around z by -45° to get the side-on part
var p:Quaternion = new Quaternion().setFromEuler(new Vector().set_xyz(0, 0, -45).radians());
//Combine the rotations and apply to the camera
View Dodecahedron.hx
import luxe.GameConfig;
import luxe.Input;
import luxe.Vector;
class Main extends luxe.Game {
//--- The actual important stuff --
var verts:Array<Vector>; //Holds the '3D model' vertices, i.e. actual 3D coordinates
KeyMaster- / RotatingPyramid.hx
Last active October 19, 2016 12:00
A quick luxe program to demonstrate manual perspective projection of a rotating pyramid.
View RotatingPyramid.hx
import luxe.GameConfig;
import luxe.Input;
import luxe.Vector;
class Main extends luxe.Game {
//--- The actual important stuff --
var verts:Array<Vector>; //Holds the '3D model' vertices, i.e. actual 3D coordinates
KeyMaster- / to_hex.p8
Created September 24, 2016 13:45
Pico8 number-to-hex function
View to_hex.p8
hex_abc = '0123456789abcdef'
function to_hex(num)
local str = ''
for i=0,7 do --8 packs of 4 bits for 32 bit number
local digit = num
local shift = (i - 4)*4
if shift < 0 then digit = shl(digit, -shift)
else digit = shr(digit, shift) end
KeyMaster- / FunctionFinder.hx
Created February 12, 2016 23:26
A macro that extracts all static methods from a class that conform to a certain function signature, and returns an array with those functions.
View FunctionFinder.hx
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Type;
import haxe.macro.TypeTools;
import haxe.macro.MacroStringTools;
class FunctionFinder {
macro public static function get_functions(e:Expr, fun_signature:Expr) {
var function_type:Type = switch(fun_signature.expr) {
case EConst(c):