Skip to content

Instantly share code, notes, and snippets.

View Flafla2's full-sized avatar

Adrian Biagioli Flafla2

View GitHub Profile
@Flafla2
Flafla2 / pixar.cpp
Last active March 22, 2019 01:15
Modified version of Pixar's postcard renderer. Runs 4 times faster and says "HIRE ME" instead of "PIXAR"
// pixar.cpp
// Ran through clang-format, then commented
// Also changed text to "HIRE ME" and used fork()
// to have 4 child processes for easy multithreading
//
// Original by Andrew Kensler
// Edits by Adrian Biagioli
#include <stdlib.h> // card > pixar.ppm
@Flafla2
Flafla2 / hid_ms_stack.c
Created April 9, 2015 01:08
A modified version of hid.c for windows, edited to fix a regression in hid_write on the MS bluetooth stack
// hid.c, edited to fix a regression in hid_write on the MS bluetooth stack
// For brevity irrelevant code has been omitted.
// Additions are marked with !!ADDED!!
// There are no modifications except for hid_write()
// ...
#ifndef HIDAPI_USE_DDK
/* Since we're not building with the DDK, and the HID header
files aren't part of the SDK, we have to define all this
@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active February 19, 2024 16:29
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
@Flafla2
Flafla2 / Perlin.cs
Last active November 3, 2023 18:31
Improved Perlin Noise Implementation in C#
public class Perlin {
public static double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
double frequency = 1;
double amplitude = 1;
for(int i=0;i<octaves;i++) {
total += perlin(x * frequency, y * frequency, z * frequency) * amplitude;
amplitude *= persistence;