Skip to content

Instantly share code, notes, and snippets.

View tgsstdio's full-sized avatar

David Young tgsstdio

  • Melbourne, Australia
View GitHub Profile
@louisremi
louisremi / animLoopX.js
Created July 29, 2011 17:34
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@paulmach
paulmach / serve.go
Last active January 26, 2025 18:27
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@slime73
slime73 / sdl-metal-example.m
Last active September 9, 2021 10:53
SDL + Metal example
/**
* This software is in the public domain. Where that dedication is not recognized,
* you are granted a perpetual, irrevokable license to copy and modify this file
* as you see fit.
*
* Requires SDL 2.0.4.
* Devices that do not support Metal are not handled currently.
**/
#import <UIKit/UIKit.h>
@HogJonnyMaxPlay
HogJonnyMaxPlay / gameShaderLighting.hlsl
Last active December 14, 2016 13:25
This is a typical game shader snippet for lighting/specular. It doesn't conserve energy, so I don't think it's proper PBR. It can probably use a few tweaks.
// shadertype=hlsl
float G1V(float NdotV, float k)
{
return 1.0f / (NdotV * (1.0f - k) + k);
}
float SchlickFresnel(float u)
{
float m = clamp(1 - u, 0, 1);
using System;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Security;
namespace TestPerf
{
public class Benchmark
{
@galek
galek / pbr.glsl
Created November 4, 2015 11:10
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@TheBuzzSaw
TheBuzzSaw / SDL_Vulkan.cpp
Created February 22, 2016 07:08
WIP -- SDL2 + Vulkan sample program
#include <SDL.h>
#include <SDL_syswm.h>
#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>
#include <iostream>
#include <cassert>
using namespace std;
# Electromagnetic simulation at varying timescales - simulation code to make this animation:
# https://twitter.com/bencbartlett/status/1369396941730312193
#
# Animation idea was inspired by u/cenit997's (Twitter: @__cenit) Reddit post:
# https://www.reddit.com/r/Python/comments/hxmhai/a_simulation_of_how_an_incoherent_light_source/
#---
using LinearAlgebra, Base.Threads, BenchmarkTools, LoopVectorization, CSV, DataFrames, Printf, Plots