-
-
Save corybarr/4212db2d8b62ddc1aea0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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