Skip to content

Instantly share code, notes, and snippets.

View tiagosr's full-sized avatar
🕺

Tiago Rezende tiagosr

🕺
View GitHub Profile
@tiagosr
tiagosr / SplineSection.cs
Created April 28, 2014 03:22
Hermite Spline for Unity3D
using UnityEngine;
using System.Collections;
public class SplineSection : MonoBehaviour {
public Transform startPoint, startTangent, endPoint, endTangent;
public SplineSection prev, next;
public Vector3 GetPositionAt(float t) {
@tiagosr
tiagosr / AntiAliasedPointSampled.shader
Last active October 31, 2023 10:44
Unity3D point-sampled shader with subpixel multisampling
Shader "esque.ma/Anti-Aliased Point-Sampled"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Feather ("Feather", Range(0.1, 0.9)) = 0.25
_Ratio ("Ratio", Range(0.0, 0.25)) = 0.15
}
SubShader
{
@tiagosr
tiagosr / NavmeshMovement.cs
Last active August 23, 2019 20:12
Navmesh-using movement pseudocode
/*
This code works well for an ostensibly-static world in Unity, to avoid doing raycasts or anything similar.
Might need some adjustment to the specifics of how it currently works in Unity or your scene
(and this was written without proper checking, but it's informed pseudocode)
*/
Vector3[] current_move_path = null;
int current_move_path_index = 0;
...
@tiagosr
tiagosr / ps2_msx.ino
Created December 10, 2014 03:56
PS/2 keyboard reader and Gradiente Expert 1.1 MSX keyboard adapter
/*
* ABNT2 PS/2 keyboard to Gradiente Expert 1.1 keyboard mapper
* (c) 2014 Tiago Rezende
*/
static const uint8_t ps2data = 2;
static const uint8_t ps2clk = 3;
//#define K(x) (uint8_t)((x>=0x80)?(x+0x8):((x<=0x07)?(x+0x80):(x-0x10)))
#define K(x) x
@tiagosr
tiagosr / bamboo-fix.reg
Last active December 22, 2015 23:29
Remove lag and visual feedback on Windows 8 Home edition with Wacom Bamboo tablets
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Cursors]
"GestureVisualization"=dword:00000000
"ContactVisualization"=dword:00000000
[HKEY_CURRENT_USER\Software\Policies\Microsoft\TabletPC]
"TurnOffPenFeedback"=dword:00000000
[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\TabletPC]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exemplo 01: Setup do WebGL</title>
<script src="jquery-1.9.1.min.js"></script>
<script type="text/x-glsl-vertex" id="simple-vertex">
</script>
<script type="text/x-glsl-fragment" id="simple-fragment">
</script>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Exemplo 02: Primitivos básicos</title>
<script src="jquery-1.9.1.min.js"></script>
<script src="gl-matrix-min.js"></script>
<script type="text/x-glsl-vertex" id="simple-vertex">
uniform mat4 projectionMtx, modelViewMtx;
@tiagosr
tiagosr / MoogVCF.as
Created May 11, 2011 00:29
A Moog-like filter for audio signals
package com.pixelofview.audio.analog
{
/**
* Simulation of a Moog-like voltage-controlled filter
* based on the [moog~] external for Pd
*/
public class MoogVCF
{
public static const GainTable:Vector.<Number> = new Vector.<Number>();
@tiagosr
tiagosr / gist:835212
Created February 19, 2011 17:35
Truetype header struct description
typedef int32_t Fixed;
typedef int16_t FWord;
typedef struct
{
Fixed Table; // version number 0x00010000 for version 1.0.
Fixed fontRevision; // Set by font manufacturer.
uint32_t checkSumAdjustment; // To compute: set it to 0, sum the entire font as ULONG, then store 0xB1B0AFBA - sum.
uint32_t magicNumber; // Set to 0x5F0F3CF5.
uint16_t flags; // Bit 0 - baseline for font at y=0;
@tiagosr
tiagosr / jsFuncTest.js
Created February 4, 2011 21:53
A quick test for javascript object method declaration "modes".
function TestObj1() { this.counter = 0; this.doit = function() { return this.counter++ } };
function TestObj2() { this.counter = 0; };
TestObj2.prototype.doit = function() { return this.counter++; };
testit = function() { var testobj1 = new TestObj1(); var counter = 0; var startt1 = (new Date).getTime(); while(testobj1.doit()<1000000) { counter++ }; console.log("time for test 1: "+((new Date).getTime()-startt1)); var testobj2 = new TestObj2(); var startt2 = (new Date).getTime(); while(testobj2.doit()<1000000) { counter++ }; console.log("time for test 2: "+((new Date).getTime()-startt2));};
testit();
// Firefox 3.6 is awful slow on both methods, but the first one is a tiny bit faster than the second one (on winXP 32, AMD x2 2.2GHz 4GB ram, it does 522ms vs. 534ms).
// Firefox 4.0 is some sort of improvement, but is still godawful slow. 340ms and 350ms, respectively. I guess Tamarin does not help much on this.
// Chrome Canary Build flies on both methods, and the second one is almost 2x faster - 45ms vs. 27ms