Skip to content

Instantly share code, notes, and snippets.

@corybarr
Created February 23, 2015 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corybarr/4212db2d8b62ddc1aea0 to your computer and use it in GitHub Desktop.
Save corybarr/4212db2d8b62ddc1aea0 to your computer and use it in GitHub Desktop.
//get the current vertices of the sphere
vector<ofPoint> &sphereVerts = sphere.getMesh().getVertices();
//calculate how much to displace them
float extrusionAmount = sin(ofGetElapsedTimef() * deformSpeed) * extrusionRange;
for (int i=0; i<sphereVerts.size(); i++) {
ofVec2f t = sphere.getMesh().getTexCoords()[i];
t.x = ofClamp( t.x, 0, pixels.getWidth()-1 );
t.y = ofClamp( t.y, 0, pixels.getHeight()-1 );
//get the brightness of the pixel at that vertex's position
float br = pixels.getColor(t.x, t.y).getBrightness();
//multiply how much to displace it by the brightness
sphereVerts[i] = origVertices[i] * (1 + br / 255.0 * extrusionAmount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment