Skip to content

Instantly share code, notes, and snippets.

View longde123's full-sized avatar
:octocat:
Working from home

paling longde123

:octocat:
Working from home
View GitHub Profile
@longde123
longde123 / Map.hx
Created June 10, 2014 01:38 — forked from m2ym/Map.hx
private enum Color { Red; Black; }
private enum TreeT<T> {
Leaf;
Node(color: Color, left: TreeT<T>, label: T, right: TreeT<T>);
}
private class TreeF {
private function new() {}
@longde123
longde123 / Map.hx
Created June 11, 2014 04:51 — forked from m2ym/Map.hx
private enum Color { Red; Black; }
private enum TreeT<T> {
Leaf;
Node(color: Color, left: TreeT<T>, label: T, right: TreeT<T>);
}
private class TreeF {
private function new() {}
@longde123
longde123 / GLSL-Noise.md
Created September 28, 2016 03:39 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
vec4 pack (float depth)
{
const vec4 bitSh = vec4(256 * 256 * 256,
256 * 256,
256,
1.0);
const vec4 bitMsk = vec4(0,
1.0 / 256.0,
1.0 / 256.0,
1.0 / 256.0);
@longde123
longde123 / gist:acec7c83caf4f6f725dc82f6ec6acac2
Created September 28, 2016 04:28 — forked from Flexi23/gist:1713774
GLSL 2D vector buffer in a texture with a custom floating point precision
/*
These are the helper functions to store and to restore a 2D vector with a custom 16 floating point precision in a texture.
The 16 bit are used as follows: 1 bit is for the sign, 4 bits are used for the exponent, the remaining 11 bit are for the mantissa.
The exponent bias is asymmetric so that the maximum representable number is 2047 (and bigger numbers will be cut)
the accuracy from 1024 - 2047 is one integer
512-1023 it's 1/2 int
256-511 it's 1/4 int and so forth...
between 0 and 1/16 the accuracy is the highest with 1/2048 (which makes 1/32768 the minimum representable number)
@longde123
longde123 / testkeys.c
Created October 22, 2016 10:05 — forked from DopefishJustin/testkeys.c
testkeys.c modified for emscripten
//============================================================
//
// testkey.c - A small utility to analyze SDL keycodes
//
// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team.
// Visit http://mamedev.org for licensing and usage restrictions.
//
// SDLMAME by Olivier Galibert and R. Belmont
// testkeys by couriersud
//
@longde123
longde123 / sdl_key_translation_sample.cc
Created October 22, 2016 10:19 — forked from khrona/sdl_key_translation_sample.cc
Example of how to translate SDL Key Events into Awesomium Keyboard Events
/// Forward declaration
int getWebKeyFromSDLKey(SDLKey key);
///
/// Inject an SDL Key Event into a given WebView
///
void handleSDLKeyEvent(Awesomium::WebView* webView, const SDL_Event& event) {
if (!(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP))
return;
using UnityEngine;
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
public class LSystemGenerator : MonoBehaviour
{
[Serializable]
@longde123
longde123 / UnlitTransparentColorGradient.shader
Created January 17, 2017 06:25 — forked from Sacristan/UnlitTransparentColorGradient.shader
Screen space coord Unlit/Transparent Color Gradient shader
Shader "Unlit/Transparent Color Gradient" {
Properties{
_MainTex("Base (RGB) Trans (A)", 2D) = "white" { }
_Color("Color1", Color) = (1.000000,1.000000,1.000000,1.000000)
_Color2("Color2", Color) = (1.000000,1.000000,1.000000,1.000000)
}
SubShader{
LOD 100
Tags{ "QUEUE" = "Transparent" "IGNOREPROJECTOR" = "true" "RenderType" = "Transparent" }
@longde123
longde123 / sh.glsl
Created February 10, 2017 04:29 — forked from romainguy/sh.glsl
Spherical Harmonics lighting
// Uniform array of 4 vec3 for SH environment lighting
// Computed from "Ditch River" (http://www.hdrlabs.com/sibl/archive.html)
static const vec3 sphericalHarmonics[4] = {
{ 0.754554516862612, 0.748542953903366, 0.790921515418539 },
{ -0.083856548007422, 0.092533500963210, 0.322764661032516 },
{ 0.308152705331738, 0.366796330467391, 0.466698181299906 },
{ -0.188884931542396, -0.277402551592231, -0.377844212327557 }
};
// Fragment shader, "n" is the normal at the shading point