Skip to content

Instantly share code, notes, and snippets.

View 0b5vr's full-sized avatar

0b5vr 0b5vr

View GitHub Profile
@0b5vr
0b5vr / motionblur.pde
Created September 1, 2014 19:26
Processing: Motion blur test
void setup()
{
size(240,240);
}
void draw()
{
background(0);
for(int blur=0;blur<10;blur++)
@0b5vr
0b5vr / add.glsl
Created September 2, 2014 09:48
v_gate
uniform ivec2 size;
uniform float m;
uniform sampler2D texture;
uniform sampler2D tex;
void main()
{
ivec2 p=ivec2(gl_FragCoord.xy);
gl_FragColor=texelFetch(texture,p,0)+texelFetch(tex,p,0)*m;
}
@0b5vr
0b5vr / pm.pde
Last active August 29, 2015 14:06
Basic of Projection Mapping
// you must prepare image
PImage image;
int[] x=new int[4];
int[] y=new int[4];
void setup()
{
size(displayWidth,displayHeight,P2D);
@0b5vr
0b5vr / k2n.js
Last active August 29, 2015 14:07
苦行 ( keyCode -> note )
function k2n(key)
{
switch(key)
{
case 90:return 48; // C4
case 83:return 49; // C#4
case 88:return 50; // D4
case 68:return 51; // D#4
case 67:return 52; // E4
case 86:return 53; // F4
@0b5vr
0b5vr / star.pde
Created October 13, 2014 04:46
void star(int x,int y)
{
pushMatrix();
translate(x,y);
beginShape();
for(int i=0;i<10;i++)
{
float th=i*0.1*PI*2;
@0b5vr
0b5vr / rm.frag
Created November 13, 2014 13:07
Simple ray marching
precision mediump float;
uniform float t; // time
uniform vec2 r; // resolution
vec2 v=vec2(0.,1.);
float f(vec3 p)
{
return length(p)-.6;
}
@0b5vr
0b5vr / 20141205.fs
Created December 5, 2014 08:58
20141205
#define PI 3.1415926
void main(void)
{
vec2 uv=vec2(gl_FragCoord.xy-iResolution.xy/2.0);
vec2 mouse=vec2(iMouse.xy-iResolution.xy/2.0);
if(length(uv)<100.0)
{
vec3 nor=vec3(0.0);
@0b5vr
0b5vr / shader.frag
Created May 27, 2015 12:23
GLSL Hello World
// gl_FragColor : ここに色()[vec4]を代入する
// gl_FragCoord.x : 実行中のピクセルのx座標 [float]
// gl_FragCoord.y : 実行中のピクセルのy座標 [float]
// gl_FragCoord.xy : 実行中のピクセルのxy座標 [vec2]
// おまじない(しっかり説明すると、GLESで浮動小数点の精度を低めないと動かない端末が多い)
#ifdef GL_ES
precision mediump float;
#endif
@0b5vr
0b5vr / shader.frag
Created May 27, 2015 13:02
GLSL Raymarching Basic
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 resolution;
float distFunc( vec3 p )
{
return length( p ) - 0.3; // 半径0.3の球体
}
@0b5vr
0b5vr / wav.pde
Created June 7, 2015 03:54
Processing wav generator
final int SIZE = 44100;
final int RATE = 44100;
byte[] file = new byte[ 44+SIZE*4 ];
float wave( float _time, float _right ){
return sin( _time * PI * 2.0 * 440.0 );
}
void setup(){
// "RIFF"