Created
April 14, 2014 03:57
-
-
Save anonymous/10614782 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
// fragment shader | |
precision lowp float; | |
//varying vec4 outputColor; | |
varying vec3 cnormal; | |
void main() | |
{ | |
vec3 col = cnormal.xyz;//vec3(1,1,1) * dot(cnormal, vec3(0,1,0)); | |
gl_FragColor = vec4(col.x, col.y, col.z, 1); | |
} |
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
// vertex shader | |
precision lowp float; | |
uniform mat4 modelViewProjectionMatrix; | |
uniform mat4 normalMatrix; | |
attribute vec4 position; | |
attribute vec4 normal; | |
varying vec3 cnormal; | |
void main(){ | |
gl_Position = modelViewProjectionMatrix * position; | |
cnormal = normal.xyz;//normalize( normalMatrix * normal ).xyz; | |
} |
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
ofSpherePrimitive cp; | |
ofShader shader; | |
//-------------------------------------------------------------- | |
void ofApp::setup(){ | |
cp.enableNormals(); | |
cp.enableColors(); | |
cp.set(10, 20); | |
cp.setScale(10); | |
cp.setPosition(0,0,-500); | |
if(!shader.load("lambert")) | |
return; | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update(){ | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw(){ | |
static float rot = 0.0f; | |
ofSetColor(255); | |
cp.setOrientation(ofVec3f(0,rot,rot)); | |
shader.begin(); | |
cp.draw(); | |
shader.end(); | |
rot += 1.0f; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment