Hi everyone,
Upon reading this interview (japanese only) of Satoshi Horii, “Rhyzomatics” main creative coder, about one of his latest work involving 3D scanning, I started to wonder if such project was possible with Processing. In the article he explains how he spent a week scanning the entire underground of the Shibuya station and gathered no less than 3.5 billion points in .pts
format (for a total of 216GB).
While he doesn’t explicitly mention what sofware he used to display all these points, I suspect OpenFrameworks (his daily coding platform) to be the main toolkit here.
QUESTIONS:
- Is it technically possible to display billions of points using Processing ?
- What are the limits (software/hardware) ?
I did a little test on my 2012 entry-level iMac (8 gb RAM, NVIDIA GeForce GT 650M 512 Mo). I used a point shader and stored the largest amount of point Processing/my computer could handle in a PShape (see example sketch below). This way, I could display up to only 1 million points. Exceding that threshold would systematically throw the following error message:
processing.app.SketchException: java.lang.RuntimeException: Waited 5000ms for: <1ebe2967, 1079c4c0>
Is that threshold impossible to exceed ?
Western Shinjuku, 800 000 points (not enough for details)
Example sketch with 100 000 points
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
PShader pointShader;
PShape shp;
ArrayList<PVector> vectors = new ArrayList<PVector>();
void setup() {
size(900, 900, P3D);
frameRate(1000);
smooth(8);
cam = new PeasyCam(this, 500);
cam.setMaximumDistance(width);
perspective(60 * DEG_TO_RAD, width/float(height), 2, 6000);
double d = cam.getDistance()*3;
pointShader = loadShader("pointfrag.glsl", "pointvert.glsl");
pointShader.set("maxDepth", (float) d);
for (int i = 0; i < 100000; i++) {
vectors.add(new PVector(random(width), random(width), random(width)));
}
shader(pointShader, POINTS);
strokeWeight(2);
stroke(255);
shp = createShape();
shp.beginShape(POINTS);
shp.translate(-width/2, -width/2, -width/2);
for (PVector v: vectors) {
shp.vertex(v.x, v.y, v.z);
}
shp.endShape();
}
void draw(){
background(0);
shape(shp, 0, 0);
println(frameRate);
}
pointvert.glsl
uniform mat4 projection;
uniform mat4 modelview;
attribute vec4 position;
attribute vec4 color;
attribute vec2 offset;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main() {
vec4 pos = modelview * position;
vec4 clip = projection * pos;
gl_Position = clip + projection * vec4(offset, 0, 0);
vertColor = color;
}
pointfrag.glsl
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
varying vec4 vertColor;
uniform float maxDepth;
void main() {
float depth = gl_FragCoord.z / gl_FragCoord.w;
gl_FragColor = vec4(vec3(vertColor - depth/maxDepth), 1) ;
}