removed FishEye example

This commit is contained in:
codeanticode
2013-09-03 20:31:40 -04:00
parent 3441ea7fa4
commit 55a23cb5fb
2 changed files with 0 additions and 111 deletions

View File

@@ -1,52 +0,0 @@
/**
* Fish Eye
*
* This fish-eye shader is useful for dome projection.
*/
PShader fisheye;
PGraphics canvas;
PImage img;
boolean useFishEye = true;
void setup() {
size(640, 640, P3D);
canvas = createGraphics(width, height, P3D);
fisheye = loadShader("FishEye.glsl");
fisheye.set("aperture", 180.0);
}
void draw() {
canvas.beginDraw();
canvas.background(0);
canvas.stroke(255, 0, 0);
for (int i = 0; i < width; i += 10) {
canvas.line(i, 0, i, height);
}
for (int i = 0; i < height; i += 10) {
canvas.line(0, i, width, i);
}
canvas.lights();
canvas.noStroke();
canvas.translate(mouseX, mouseY, 100);
canvas.rotateX(frameCount * 0.01);
canvas.rotateY(frameCount * 0.01);
canvas.box(100);
canvas.endDraw();
if (useFishEye == true) {
shader(fisheye);
}
image(canvas, 0, 0, width, height);
}
void mousePressed() {
if (useFishEye) {
useFishEye = false;
resetShader();
} else {
useFishEye = true;
}
}

View File

@@ -1,59 +0,0 @@
// Inspired by the "Angular Fisheye à la Bourke" sketch from
// Jonathan Cremieux, as shown in the OpenProcessing website:
// http://openprocessing.org/visuals/?visualID=12140
// Using the inverse transform of the angular fisheye as
// explained in Paul Bourke's website:
// http://paulbourke.net/miscellaneous/domefisheye/fisheye/
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform mat4 texMatrix;
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform float aperture;
const float PI = 3.1415926535;
void main(void) {
float apertureHalf = 0.5 * aperture * (PI / 180.0);
// This factor ajusts the coordinates in the case that
// the aperture angle is less than 180 degrees, in which
// case the area displayed is not the entire half-sphere.
float maxFactor = sin(apertureHalf);
// The st factor takes into account the situation when non-pot
// textures are not supported, so that the maximum texture
// coordinate to cover the entire image might not be 1.
vec2 stFactor = vec2(1.0 / abs(texMatrix[0][0]), 1.0 / abs(texMatrix[1][1]));
vec2 pos = (2.0 * vertTexCoord.st * stFactor - 1.0);
float l = length(pos);
if (l > 1.0) {
gl_FragColor = vec4(0, 0, 0, 1);
} else {
float x = maxFactor * pos.x;
float y = maxFactor * pos.y;
float n = length(vec2(x, y));
float z = sqrt(1.0 - n * n);
float r = atan(n, z) / PI;
float phi = atan(y, x);
float u = r * cos(phi) + 0.5;
float v = r * sin(phi) + 0.5;
gl_FragColor = texture2D(texture, vec2(u, v) / stFactor) * vertColor;
}
}